Citat: Jerenić poslato Septembar 13, 2018, 13:41:20 POSLE PODNE
Pawn format?
[pawn]Test[/pawn]
Izvini, krivo sam nesto stavio sa zagradama, može li neki admin edit? Nema veze, ja cu stavit ovamo
[pawn]
#include <a_samp>
#include <zcmd>
#include <RouteConnector>
#define GPS 10
#define GPSLS 11
#define GPSLV 12
#define GPSSF 13
new GPS_Activated[MAX_PLAYERS] = 0;
enum RouteInformation
{
Destination,
CreatedObjects[1024],
bool:calculating,
Lenght
};
new PlayerRoute[MAX_PLAYERS][RouteInformation];
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerRoute[playerid][Destination] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
{
GPS_Activated[playerid] = 0;
DisableGPS(playerid);
PlayerRoute[playerid][Lenght] = 0;
PlayerRoute[playerid][Destination] = -1;
gps_RemovePlayer(playerid);
}
return 1;
}
forward DisableGPS(playerid);
public DisableGPS(playerid)//iskljucivanje GPS
{
for(new i = 0; i < PlayerRoute[playerid][Lenght]; ++i)
{
DestroyPlayerObject(playerid,PlayerRoute[playerid][CreatedObjects]); //brisanje objekata
}
PlayerRoute[playerid][Lenght] = 0;
PlayerRoute[playerid][Destination] = -1;
gps_RemovePlayer(playerid);
return 1;
}
public GPS_WhenRouteIsCalculated(routeid,node_id_array[],amount_of_nodes,Float:distance,Float:Polygon[],Polygon_Size,Float:NodePosX[],Float:NodePosY[],Float:NodePosZ[])//Kada se ruta kreira
{
PlayerRoute[routeid][calculating] = false;// puts the route creation on false
if(amount_of_nodes > 1)
{ // if the number of points in the path is greater than 1
for(new i = 0; i < amount_of_nodes; ++i)
{
PlayerRoute[routeid][CreatedObjects] = CreatePlayerObject(routeid,1318,NodePosX,NodePosY,NodePosZ+1.0,0.0,0.0,0.0,150.0); // create objects by the way ...
}
PlayerRoute[routeid][Lenght] = amount_of_nodes; // sets the number of points on the road
PlayerRoute[routeid][Destination] = node_id_array[amount_of_nodes-1]; // sets the destination
gps_AddPlayer(routeid); // adds players to that route
SendClientMessage(routeid,-1,"Route created, happy way!");
}
else {
SendClientMessage(routeid,-1,"Satellite can not find you at this location, go to the nearest road.");
}
return 1;
}
public OnPlayerClosestNodeIDChange(playerid,old_NodeID,new_NodeID)
{ // when the player arrives at the destination
if(new_NodeID != -1)
{
if(PlayerRoute[playerid][Destination] == new_NodeID) {
SendClientMessage(playerid,-1,"You're at the destination.");
DisableGPS(playerid);
}
}
return 1;
}
CMD:gps(playerid, params[])
{
// if(!IsPlayerInAnyVehicle(playerid)) return GameTextForPlayer(playerid, "~w~You're not in a vehicle", 3000, 3);
if(PlayerRoute[playerid][calculating])
{ // This will check if the route is created
SendClientMessage(playerid,-1,"First, delete your chosen route. / gpsoff");
return 1;
}
if(PlayerRoute[playerid][Destination] != -1) // this will be a security check that does not create a player 2 routes first to turn off the old one
{
DisableGPS(playerid);
}
ShowPlayerDialog(playerid, GPS, DIALOG_STYLE_LIST, "GPS", "Los Santos\nLas Venturas\nSan Fierro", "Select", "Close");
return 1;
}
CMD:gpsoff(playerid,params[])
{
if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
{
DisablePlayerCheckpoint(playerid);
GameTextForPlayer(playerid, "GPS OFF", 3000, 3);
GPS_Activated[playerid] = 0;
DisableGPS(playerid);
PlayerRoute[playerid][Lenght] = 0;
PlayerRoute[playerid][Destination] = -1;
gps_RemovePlayer(playerid);
}
else GameTextForPlayer(playerid, "~w~GPS is not activated", 3000, 3);
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GPS_Activated[playerid] == 1 && PlayerRoute[playerid][Destination] != -1)
{
GameTextForPlayer(playerid, "You have reached your destination", 3000, 3);
DisablePlayerCheckpoint(playerid);
GPS_Activated[playerid] = 0;
DisableGPS(playerid);
PlayerRoute[playerid][Lenght] = 0;
PlayerRoute[playerid][Destination] = -1;
gps_RemovePlayer(playerid);
}
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)
{
switch(listitem)
{
case 0:
{
//==== Testing with LSPD
new PlayerClosest = NearestPlayerNode(playerid); // this will take the closest point where the player is located
new TempDestination = NearestNodeFromPoint(1533.1295, -1657.7357, 13.3828); // this is taken to the nearest point on the specified coordinates X, Y, Z
if(PlayerClosest == TempDestination)
{ // if the player is already on the target
SendClientMessage(playerid,-1,"You are already in that location.");
return 1;
}
if(PlayerClosest == -1)
{
SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
return 1;
}
if(TempDestination == -1)
{// if the player is far from the nearest point on the way
SendClientMessage(playerid,-1,"Satellite can not find a destination, please try again.");
return 1;
}
if(CalculatePath(PlayerClosest,TempDestination,playerid, .GrabNodePositions = true))
{ // if the route is created
PlayerRoute[playerid][calculating] = true;
SendClientMessage(playerid,-1,"Create a route, please wait");
GameTextForPlayer(playerid, "~w~Check Your minimap!", 3000, 1);
GPS_Activated[playerid] = 1;
SetPlayerCheckpoint(playerid, 1533.1295,-1657.7357,13.3828, 8);
}
else SendClientMessage(playerid,-1,"Unknown error, please try again.");
}
}
}
}
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);
GPS_Activated[playerid] = 1;
}
}
}
}
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);
GPS_Activated[playerid] = 1;
}
}
}
}
return 1;
}[/pawn]
Zanima me, koji do NearestPlayerNodea ti smeta, uglavnom to ti, koliko znam, služi da provjeriÅ¡ udaljenost trenutnog (najbližeg nodea) recimo te lokacije, zatim notea tog igraÄa (playerid), ali budući da nisam 100% siguran da je to taÄno, nisam kompetentan da ti dam siguran odgovor, ali mislim da je to to. ImaÅ¡ Driver-FS koji koristi taj plugin i inc, Taxiji, obicni vozaci i policija po gradu, kucaj Taxi NPC i naci ces na stranom samp forumu, i pogledaj malo za sta se to koristi.