08.09.2018, 12:50
Okay, i have a little simple gps system with so far no bugs. Can anyone help me to do it correctly without errors?
Next thing i want to add is this:
http://i.imgur.com/7ZK4e7T.png
Here are the codes of /GPS:
On top of script goes something like this:
OnPlayerConnect
OnPlayerDisconnect
In command i need to put this, but don't know where exactly:
On Bottom:
Also on Bottom:
We're still on Bottom, remember?
Next thing i want to add is this:
http://i.imgur.com/7ZK4e7T.png
Here are the codes of /GPS:
PHP код:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#define GPS 10
#define GPSLS 11
#define GPSLV 12
#define GPSSF 13
#pragma tabsize 0
CMD:gps(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
ShowPlayerDialog(playerid, GPS, DIALOG_STYLE_LIST, "GPS", "Los Santos\nLas Venturas\nSan Fierro", "Select", "Close");
return 1;
}
//GameTextForPlayer(playerid, "~w~You're not in a vehicle", 3000, 3);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid == GPS)
{
case 1:
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid, GPSLS, DIALOG_STYLE_LIST, "Los Santos", "Los Santos police department\n", "Select", "Close");
}
case 1:
{
ShowPlayerDialog(playerid, GPSLV, DIALOG_STYLE_LIST, "Las Venturas", "Las Venturas police department\n", "Select", "Close");
}
case 2:
{
ShowPlayerDialog(playerid, GPSSF, DIALOG_STYLE_LIST, "San Fierro", "San Fierro police department\n", "Select", "Close");
}
}
}
}
}
if(dialogid == GPSLS)
{
if(!response) return 0;
{
switch(listitem)
{
case 0:
{
SetPlayerCheckpoint(playerid, 1533.1295,-1657.7357,13.3828, 8);
GameTextForPlayer(playerid, "~w~Check Your minimap!", 3000, 1);
}
}
}
}
if(dialogid == GPSLV)
{
if(!response) return 0;
{
switch(listitem)
{
case 0:
{
SetPlayerCheckpoint(playerid, 2230.2854,2470.0540,10.8203, 8);
GameTextForPlayer(playerid, "~w~Check Your minimap", 3000, 2);
}
}
}
}
if(dialogid == GPSSF)
{
if(!response) return 0;
{
switch(listitem)
{
case 0:
{
SetPlayerCheckpoint(playerid, -1563.9243,659.6130,7.0391, 8);
GameTextForPlayer(playerid, "~w~Check Your Minimap", 3000, 3);
}
}
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
//DisablePlayerCheckpoint(playerid);
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
GameTextForPlayer(playerid, "You have reached your destination", 3000, 3);
DisablePlayerCheckpoint(playerid);
return 1;
}
PHP код:
#include < RouteConnector >
enum RouteInformation
{
Destination,
CreatedObjects[1024],
bool:calculating,
Lenght
};
new PlayerRoute[MAX_PLAYERS][RouteInformation];
PHP код:
PlayerRoute[playerid][Destination] = -1;
PHP код:
if(PlayerRoute[playerid][Destination] != -1) {
DisableGPS(playerid);
}
PHP код:
new PlayerClosest = NearestPlayerNode(playerid);
new TempDestination = NearestNodeFromPoint(X,Y,Z);
if(PlayerClosest == TempDestination)
return 1;
}
if(PlayerClosest == -1)
return 1;
}
if(TempDestination == -1)
return 1;
}
if(CalculatePath(PlayerClosest,TempDestination,playerid, .GrabNodePositions = true))
PlayerRoute[playerid][calculating] = true;
}
else {if error shows...
SendClientMessage(playerid,"error please try again.");
}
return 1;
}
PHP код:
public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID)
if(new_NodeID != -1)
if(PlayerRoute[playerid][Destination] == new_NodeID) {
DisableGPS(playerid);
}
}
return 1;
}
PHP код:
public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])
{
PlayerRoute[routeid][calculating] = false;
if(amount_of_nodes > 1) {
for(new i = 0; i < amount_of_nodes; ++i) {
PlayerRoute[routeid][CreatedObjects][i] = CreatePlayerObject(routeid,1318,NodePosX[i],NodePosY[i],NodePosZ[i]+1.0,0.0,0.0,0.0,150.0);
}
PlayerRoute[routeid][Lenght] = amount_of_nodes;
PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1];
gps_AddPlayer(routeid);
}
smthing goes here
}
return 1;
}
PHP код:
forward DisableGPS(playerid);
public DisableGPS(playerid)//iskljucivanje GPS
{
for(new i = 0; i < PlayerRoute[playerid][Lenght]; ++i)
{
DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects][i]);
}
PlayerRoute[playerid][Lenght] = 0;
PlayerRoute[playerid][Destination] = -1;
gps_RemovePlayer(playerid);
return 1;
}