25.08.2017, 20:02
Hello!
Hi Guys! I'm Brazilian!
I came to the American topic, to share a bit of my knowledge for you, and I came also to help some people who have a hard time producing this command, so I made that base for you. Thank you!
I am a beginner in programming pawno, This is my first tutorial, but I came to give you a GPS base in dialog, but I will also be teaching how I made this base.
I accept criticism and suggestions!
Includes Used: <a_samp> || <zcmd>
First Step:
Create a definition for your DIALOG with a numbering.
Second step:
Let's create a variable to be recognized when the player arrives at the location and the point is removed.
Third step
Let's call OnPlayerEnterCheckPoint (playerid) and we'll do the checks inside the variable.
Explanation of the above actions:
Fourth step:
Let's create the command, in case to show the DIALOG of the locations. I made an example to go to a lottery house.
Note: The only function used was the ShowPlayerDialog, which is to show a Dialog box for the player that typed the command.
Briefly, I'll bring you a tutorial explaining more about the function.
If you want to study: ShowPlayerDialog
Fifth step:
Let's go to the callback that is responsible for answering the dialogs, in this case the public OnDialogResponse.
Explanation of the above action:
Finally, the whole function will be as follows:
@Extra:
If you want the command to turn off the gps:
Note:Just add the command
Have the option to turn off GPS in Dialog:
Note:Necessary to add another line of the ShowPlayerDialog command "/gps"
Thank You
Source: Pastebin
Hi Guys! I'm Brazilian!
I came to the American topic, to share a bit of my knowledge for you, and I came also to help some people who have a hard time producing this command, so I made that base for you. Thank you!
I am a beginner in programming pawno, This is my first tutorial, but I came to give you a GPS base in dialog, but I will also be teaching how I made this base.
I accept criticism and suggestions!
Includes Used: <a_samp> || <zcmd>
First Step:
Create a definition for your DIALOG with a numbering.
PHP код:
#define DIALOG_GPS 1
//#define DIALOG_NAME DIALOG_NUMBER
Let's create a variable to be recognized when the player arrives at the location and the point is removed.
PHP код:
new GPSLocal[MAX_PLAYERS];
//new nome_of_variable[MAX_PLAYERS]; (Refers to the maximum number of players found on the server)
Let's call OnPlayerEnterCheckPoint (playerid) and we'll do the checks inside the variable.
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
if(GPSLocal[playerid] == 1)
{
GPSLocal[playerid] = 0;
DisablePlayerCheckpoint(playerid);
}
return 1;
}
Код:
public OnPlayerEnterCheckpoint(playerid) = Callback when the player is inside a created tag. { = Callback key opening if(GPSLocal[playerid] == 1) = check, we check if the GPSLocal variable is created. { = Verification key opening GPSLocal [playerid] = 0; = We are zeroing out any markup created by some function DisablePlayerCheckpoint(playerid); = We are disabling all tags (disabling all tags that have been created at the moment) } = Closing scan key Return 1; = We returned Callback to 1 or made the true callback return } = Closing the Callback key
Let's create the command, in case to show the DIALOG of the locations. I made an example to go to a lottery house.
PHP код:
CMD:gps(playerid)
{
ShowPlayerDialog (playerid, DIALOG_GPS, DIALOG_STYLE_LIST, "GPS", "LOTTERY HOUSE", "Select", "Close");
return 1;
}
Briefly, I'll bring you a tutorial explaining more about the function.
If you want to study: ShowPlayerDialog
Fifth step:
Let's go to the callback that is responsible for answering the dialogs, in this case the public OnDialogResponse.
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_GPS)
{
if(response)
{
if(listitem == 0)
{
SetPlayerCheckpoint(playerid,1289.8077,-1654.2590,13.5469,8.0);
SendClientMessage(playerid,-1,"[INFO] - Lottery was marked on your map!");
GPSLocal[playerid] = 1;
}
}
}
return 1;
}
Код:
public OnDialogResponse (playerid, dialogid, response, listitem, inputtext []) = Is responsible for starting the function. {= Callback key opening if (dialogid == DIALOG_GPS) = You are checking if the dialog exists, and the action against it is done. {= Key Verification Opening if (response) = Verification of the responsibilities of the columns. {= Opening of the Liability Key if (listitem == 0) = Check if the item quoted in the command lines. In pawno, everything starts from number zero (zero), zero is the first line. {= Opening Items Check. SetPlayerCheckPoint(playerid, 1289.8077, -1654.2590,13.5469,8.0); = Create a checkpoint on the game map. Playerid is the player that typed the command. These numbers are the coordinates X, Y, Z, Size SendClientMessage (playerid, -1, "[INFO]: Lottery marked on Map, Go to the point"); = We send a message to the client. -1 is the color you want to appear in the message (white in pawn). Message. GPSLocal[playerid] = 1; = We give a value for the GPSLocal variable, which was 1 when we clicked on the desired location, after we arrived, the location will be cleared. } = Closes the verification of items. } = Closing the responsibility key. } = Closing the DIALOG setting check switch. return 1; = We are finalizing or giving the final (or true) return of the function. } = Closing callback function key.
PHP код:
#include <a_samp>
#include <zcmd>
#define DIALOG_GPS 1
new GPSLocal[MAX_PLAYERS];
CMD:gps(playerid)
{
ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST, "GPS", "LOTTERY HOUSE", "Select", "Close");
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GPSLocal[playerid] == 1)
{
GPSLocal[playerid] = 0;
DisablePlayerCheckpoint(playerid);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_GPS)
{
if(response)
{
if(listitem == 0)
{
SetPlayerCheckpoint(playerid,1289.8077,-1654.2590,13.5469,8.0);
SendClientMessage(playerid,-1,"[INFO] - Lottery has been marked on your map!");
GPSLocal[playerid] = 1;
}
}
}
return 1;
}
If you want the command to turn off the gps:
Note:Just add the command
PHP код:
CMD:offgps(playerid)
{
if(GPSLocal[playerid] == 1)
{
GPSLocal[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, -1, "{00BFFF}[SERVER]{FFFFFF}: GPS Turn off");
}
else
{
SendClientMessage(playerid, -1, "{FF0000}ERROR: You are not on GPS");
}
return 1;
}
Note:Necessary to add another line of the ShowPlayerDialog command "/gps"
PHP код:
CMD:gps(playerid)
{
ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST, "GPS", "TURN OFF GPS\nLOTERICA", "Selecionar", "Fechar");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_GPS)
{
if(response)
{
if(listitem == 0)
{
if(GPSLocal[playerid] == 1)
{
GPSLocal[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, -1, "{00BFFF}[SERVER]{FFFFFF}: GPS Turn off!");
}
else
{
SendClientMessage(playerid, -1, "{FF0000}ERROR: You are not on GPS");
}
}
if(listitem == 1)
{
SetPlayerCheckpoint(playerid, 1289.8077, -1654.2590, 13.5469, 8.0);
SendClientMessage(playerid,-1,"[INFO] - Lottery has been marked on your map!");
GPSLocal[playerid] = 1;
}
}
}
return 1;
}
Source: Pastebin