plakapenka
Специалист
Особенности:
- Добавления gps прямо из игры ( /addgps )
- Стрелочка над машиной показывает куда ехать ( как в NFS )
К new добавляем:
В OnGameModeInit()
В public OnPlayerDisconnect(playerid, reason)
В OnPlayerDeath(playerid, killerid, reason)
public OnPlayerStateChange(playerid, newstate, oldstate)
OnPlayerEnterRaceCheckpoint(playerid)
В OnPlayerUpdate(playerid)
В OnDialogResponse
Ко всем командам:
В конец мода:
В папку scriptfiles скачиваем вот этот файл:
- Добавления gps прямо из игры ( /addgps )
- Стрелочка над машиной показывает куда ехать ( как в NFS )
К new добавляем:
PHP:
#define D_GPS 46
#define D_ADDNED 11 // Добавление домов, бизнесов + 10
#define D_JOB 131
new TOTALGPS;
#define MAX_GPS 30
enum FGPS
{
gpsid,
Float: gpsLocationX,
Float: gpsLocationY,
Float: gpsLocationZ,
gpsName[64]
};
new GPSInfo[MAX_GPS][FGPS];
new GPSObject[MAX_PLAYERS];
PHP:
LoadGPS();
PHP:
if(GetPVarInt(playerid,"YEAH") == 1)
{
DisablePlayerRaceCheckpoint(playerid);
DestroyObject(GPSObject[playerid]);
SetPVarInt(playerid,"YEAH",0);
DeletePVar(playerid,"Spongebob");
DeletePVar(playerid,"Mario");
DeletePVar(playerid,"SpiderPig");
DeletePVar(playerid, "GPSID");
}
PHP:
if(GetPVarInt(playerid,"YEAH") == 1)
{
DisablePlayerRaceCheckpoint(playerid);
DestroyObject(GPSObject[playerid]);
SetPVarInt(playerid,"YEAH",0);
DeletePVar(playerid,"Spongebob");
DeletePVar(playerid,"Mario");
DeletePVar(playerid,"SpiderPig");
DeletePVar(playerid, "GPSID");
}
PHP:
if(newstate == PLAYER_STATE_ONFOOT)
{
if(GetPVarInt(playerid, "YEAH"))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Вы отменили GPS");
DisablePlayerRaceCheckpoint(playerid);
DestroyObject(GPSObject[playerid]);
SetPVarInt(playerid,"YEAH",0);
DeletePVar(playerid,"Spongebob");
DeletePVar(playerid,"Mario");
DeletePVar(playerid,"SpiderPig");
DeletePVar(playerid, "GPSID");
}
}
PHP:
if(GetPVarInt(playerid,"YEAH") == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "Вы достигли места назначения");
DestroyObject(GPSObject[playerid]);
SetPVarInt(playerid,"YEAH",0);
DeletePVar(playerid,"Spongebob");
DeletePVar(playerid,"Mario");
DeletePVar(playerid,"SpiderPig");
DeletePVar(playerid, "GPSID");
DisablePlayerRaceCheckpoint(playerid);
}
PHP:
if(GetPVarInt(playerid,"YEAH") == 1)
{
new Float:VPos[3], Float:Rotation;
GetVehiclePos(GetPlayerVehicleID(playerid),VPos[0],VPos[1],VPos[2]);
Rotation = PointAngle(playerid, VPos[0],VPos[1], GetPVarFloat(playerid,"Spongebob"), GetPVarFloat(playerid,"Mario"));
AttachObjectToVehicle(GPSObject[playerid], GetPlayerVehicleID(playerid), 0.0, 0.0, 1.5, 0.0, 90.0, Rotation);
}
PHP:
if(dialogid == D_GPS)
{
if(!response) return 1;
new str[128], varv[2048];
switch(listitem)
{
case 0:
{
for(new g = 1; g <= 3; g++)
{
format(str, 64, "Локация - %s\n", GPSInfo[g][gpsName]);
strcat(varv,str);
}
SetPVarInt(playerid, "GPSID", 1);
}
case 1:
{
for(new g = 4; g <= 19; g++)
{
format(str, 64, "Локация - %s\n", GPSInfo[g][gpsName]);
strcat(varv,str);
}
SetPVarInt(playerid, "GPSID", 4);
}
case 2:
{
for(new g = 20; g <= TOTALGPS; g++)
{
format(str, 64, "Локация - %s\n", GPSInfo[g][gpsName]);
strcat(varv,str);
}
SetPVarInt(playerid, "GPSID", 20);
}
}
ShowPlayerDialog(playerid, D_JOB+65, 2, "Навигация", varv, "Принять", "Отмена");
}
if(dialogid == D_JOB+65)
{
if(!response) return 1;
new Float:VPos[3];
SetPVarFloat(playerid,"Spongebob",GPSInfo[listitem+GetPVarInt(playerid, "GPSID")][gpsLocationX]);
SetPVarFloat(playerid,"Mario",GPSInfo[listitem+GetPVarInt(playerid, "GPSID")][gpsLocationY]);
SetPVarFloat(playerid,"SpiderPig",GPSInfo[listitem+GetPVarInt(playerid, "GPSID")][gpsLocationZ]);
GetPlayerPos(playerid, VPos[0], VPos[1], VPos[2]);
SetPVarInt(playerid,"YEAH",1);
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 1, GetPVarFloat(playerid,"Spongebob"), GetPVarFloat(playerid,"Mario"), GetPVarFloat(playerid,"SpiderPig"), 0, 0, 0, 5.0);
new string[242];
format(string, sizeof(string), "Вы отметили на карте: %s. Расстояние: %.1f метров",GPSInfo[listitem+GetPVarInt(playerid, "GPSID")][gpsName],GetDistanceBetweenPoints(VPos[0], VPos[1], VPos[2], GetPVarFloat(playerid,"Spongebob"), GetPVarFloat(playerid,"Mario"),GetPVarFloat(playerid,"SpiderPig")));
SendClientMessage(playerid, COLOR_YELLOW, string);
GPSObject[playerid] = CreateObject(1559, 0, 0, 0, 0.0, 0.0, 0);
return 1;
}
if(dialogid == D_ADDNED+3)
{
if(!response) return 1;
new Float:x, Float:y, Float:z;
if(!strlen(inputtext))return ShowPlayerDialog(playerid, D_ADDNED+3, 1, "Добавить GPS", "Введите название локации и тип:", "Принять", "Отмена");
TOTALGPS++;
strmid(GPSInfo[TOTALGPS][gpsName], inputtext, 0, 32, 32);
GetPlayerPos(playerid, x, y, z);
GPSInfo[TOTALGPS][gpsLocationX] = x;
GPSInfo[TOTALGPS][gpsLocationY] = y;
GPSInfo[TOTALGPS][gpsLocationZ] = z;
SendClientMessage(playerid,COLOR_ORANGE,"GPS номер создан");
savegps();
}
PHP:
if(strcmp(cmd, "/gps", true) == 0)
{
if(GetPVarInt(playerid,"YEAH") == 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Вы отменили GPS");
DisablePlayerRaceCheckpoint(playerid);
DestroyObject(GPSObject[playerid]);
SetPVarInt(playerid,"YEAH",0);
DeletePVar(playerid,"Spongebob");
DeletePVar(playerid,"Mario");
DeletePVar(playerid,"SpiderPig");
DeletePVar(playerid,"FAIL");
DeletePVar(playerid, "GPSID");
}
else
{
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, COLOR_GREY, "Вы должны находиться за рулем транспорта!");
/*new str[128], varv[2048];
for(new g = 1; g <= TOTALGPS; g++)
{
format(str, 64, "Локация - %s\n", GPSInfo[g][gpsName]);
strcat(varv,str);
}*/
ShowPlayerDialog(playerid, D_GPS, DIALOG_STYLE_LIST, "Навигация", "1. Важные места\n2. Спауны организаций\n3. Другое", "Принять", "Отмена");
}
return 1;
}
if(strcmp(cmd, "/addgps", true) == 0)
{
ShowPlayerDialog(playerid, D_ADDNED+3, 1, "Добавить GPS", "Введите название локации:", "Принять", "Отмена");
return true;
}
PHP:
stock LoadGPS()
{
new arrCoords[5][64];
new strFromFile2[256];
new File: file = fopen("gps.cfg", io_read);
new idx;
if(file)
{
while(idx < sizeof(GPSInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
if(strval(arrCoords[0]) != 0)
{
GPSInfo[idx][gpsid] = strval(arrCoords[0]);
strmid(GPSInfo[idx][gpsName], arrCoords[1], 0, strlen(arrCoords[1]), 255);
GPSInfo[idx][gpsLocationX]= floatstr(arrCoords[2]);
GPSInfo[idx][gpsLocationY]= floatstr(arrCoords[3]);
GPSInfo[idx][gpsLocationZ]= floatstr(arrCoords[4]);
TOTALGPS++;
}
idx++;
}
}
printf(" [Загрузка GPS]: Было загружено - %d", TOTALGPS);
fclose(file);
return true;
}
stock savegps()
{
new idx;
new File: file2;
while(idx < sizeof(GPSInfo))
{
if(GPSInfo[idx][gpsid] != 0)
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d|%s|%f|%f|%f\n",
GPSInfo[idx][gpsid],
GPSInfo[idx][gpsName],
GPSInfo[idx][gpsLocationX],
GPSInfo[idx][gpsLocationY],
GPSInfo[idx][gpsLocationZ]);
if(idx == 0)
{
file2 = fopen("gps.cfg", io_write);
}
else
{
file2 = fopen("gps.cfg", io_append);
}
fwrite(file2, coordsstring);
fclose(file2);
}
idx++;
}
return true;
}
stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ)
{
new Float:Distance;Distance = floatabs(floatsub(X, PointX)) + floatabs(floatsub(Y, PointY)) + floatabs(floatsub(Z, PointZ));
return Distance;
}
stock Float:PointAngle(playerid, Float:xa, Float:ya, Float:xb, Float:yb)
{
new Float:carangle;
new Float:xc, Float:yc;
new Float:angle;
xc = floatabs(floatsub(xa,xb));
yc = floatabs(floatsub(ya,yb));
if (yc == 0.0 || xc == 0.0)
{
if(yc == 0 && xc > 0) angle = 0.0;
else if(yc == 0 && xc < 0) angle = 180.0;
else if(yc > 0 && xc == 0) angle = 90.0;
else if(yc < 0 && xc == 0) angle = 270.0;
else if(yc == 0 && xc == 0) angle = 0.0;
}
else
{
angle = atan(xc/yc);
if(xb > xa && yb <= ya) angle += 90.0;
else if(xb <= xa && yb < ya) angle = floatsub(90.0, angle);
else if(xb < xa && yb >= ya) angle -= 90.0;
else if(xb >= xa && yb > ya) angle = floatsub(270.0, angle);
}
GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle);
return floatadd(angle, -carangle);
}
В папку scriptfiles скачиваем вот этот файл:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
Последнее редактирование:
