[Tutorial] How To Make simple GPS system
#1

Hello guys today i am gonna show you how to make a simple gps system using RaceCheckpoint. because i tried Using Checkpoint it bugs you today i am going to release this tutorial. simple and easy when you learn how

You must also have zcmd Include by Zeex Download Link: https://sampforum.blast.hk/showthread.php?tid=91354 if you dont have one

pawn Code:
#include <zcmd>
if you are using dcmd make sure you have
pawn Code:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
This here, is ensuring that you are using the command processor that is by Zeex. You must have the zcmd.inc from the download page which is linked at the top of this tutorial, inside of your "Pawno\includes" folder, if you don't you will have an error saying that it can't read from the file. Just like this:
pawn Code:
fatal error 100: cannot read from file: "zcmd"
Then after all of that lets just define the color yellow.
pawn Code:
#define COLOR_YELLOW 0xFFFF00AA
if you didn't define some error will show
Code:
Undefined "COLOR_YELLOW"
You already have that? Lets begin!!

1st - we need to get all X,Y,Z position 'how to get those? enter command go ingame and type the /save [TEXT] it will directly save to your
Documents/GTA San Andreas User Files/SAMP/savedpositions.txt' or if you are lazy you can use Xtremer xyzTaker Download Link: http://forum.sa-mp.com/showthread.ph...light=xyzTaker

after you got all of your positions/X,Y,Z now!

2nd- we need to make DIALOG so player can choose different location where they want to go.

At The Top
pawn Code:
#define DIALOG_GPS 1 //Change this if you already defined a dialog to 1
After that
Ctrl + G and search public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

Have you found it? lets Begin making DIALOG
pawn Code:
if(dialogid == DIALOG_GPS)//if player types /gps the dialog will pop up
{
if(response)
{
if(listitem == 0)
{
SetPlayerRaceCheckpoint(playerid, 2,X,Y,Z, 0.0,0.0,0.0, 3.0);//only change the X,Y,Z | you can touch it if you know what you are doing
SendClientMessage(playerid, -1,"Follow the red mark on your map");//so player will know what will he follow
}
      }
}
After that we need to make a command so player can open the dialog
i will make 3 different commands that i know
Code:
 zcmd, dcmd, strmp
strcmp
pawn Code:
if (strcmp("/gps", cmdtext, true, 10) == 0)
    {
    if(!IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,0xAFAFAFAA,"You're not in  a vehicle");
    return 1;
    }
    ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Location","Choose","Cancel");
    SendClientMessage(playerid,COLOR_YELLOW,"To Cancel Gps use /gpsoff");
    return 1;
        return 1;
    }
dcmd
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
   dcmd(gps,3,cmdtext);
   return 0;
}
dcmd_gps(playerid, params[])
{
           #pragma unused params
    if(!IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,0xAFAFAFAA,"You're not in  a vehicle");
    return 1;
    }
    ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Locations,"Choose","Cancel");
    SendClientMessage(playerid,COLOR_YELLOW,"
To Cancel Gps use /gpsoff");
    return 1;
           }
        return 1;
}
zcmd
pawn Code:
cmd(gps, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid))
    {
    SendClientMessage(playerid,0xAFAFAFAA,"You're not in  a vehicle");
    return 1;
    }
    ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Location","Choose","Cancel");
    SendClientMessage(playerid,COLOR_YELLOW,"To Cancel Gps use /gpsoff");
    return 1;
    }
    return 1;
}
After you done the commands. lets move on to the public OnPlayerEnterRaceCheckpoint(playerid)
when player arrives at destination
pawn Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    GameTextForPlayer(playerid,"You Have Arrived At Your Destination",3000,5);//Show's a gametext
    DisablePlayerRaceCheckpoint(playerid);//Disable The Current Checkpoint
    return 1;
}
Extra Command: to turn your GPS off

strcmp
pawn Code:
if (strcmp("gpsoff", cmdtext, true, 10) == 0)
    {
        DisablePlayerRaceCheckpoint(playerid);//Disable The Current Checkpoint
        return 1;
    }
dcmd
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(gpsoff,6,cmdtext);
  return 0;
}

dcmd_gpsoff(playerid, params[])
{
  DisablePlayerRaceCheckpoint(playerid);//Disable The Current Checkpoint
  return 1;
}
zcmd
pawn Code:
cmd(gpsoff, playerid, params[])
{
           DisablePlayerRaceCheckpoint(playerid);//Disable The Current Checkpoint
    return 1;
}
Reply
#2

First.
Nice one buddy.
Reply
#3

Thanks
Reply
#4

Nice but a bit shady at this point:

Quote:

1st - we need to get all X,Y,Z position 'how to get those? enter command /save and it will automatically save to your Documents/GTA San Andreas User Files/SAMP/savedpositions.txt'

Newbos might not know where to input the /save command so you should've told us/them to go ingame and type the /save [TEXT] command! But nice one buddy
Reply
#5

Not much is really explained, explain more.
Reply
#6

Quote:
Originally Posted by phantomcraft
View Post
Nice but a bit shady at this point:



Newbos might not know where to input the /save command so you should've told us/them to go ingame and type the /save [TEXT] command! But nice one buddy
Thanks ill try to explain it more further

Quote:
Originally Posted by gtakillerIV
View Post
Not much is really explained, explain more.
ill try to explain it more further
Reply
#7

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(gps,3,cmdtext);
return 0;
}
dcmd_gps(playerid, params[])
{
#pragma unused params
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,0xAFAFAFAA,"You're not in a vehicle");
return 1;
}
ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Locations,"Choose","Cancel");
SendClientMessage(playerid,COLOR_YELLOW,"To Cancel Gps use /gpsoff");
return 1;
return 1;
}

Wrong!, if you compile it, you would get atleast 1 error

pawn Code:
ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Locations","Choose","Cancel");
Check it out
Reply
#8

Quote:
Originally Posted by [CG]Milito
View Post
Wrong!, if you compile it, you would get atleast 1 error

pawn Code:
ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST,"GPS System","Locations","Choose","Cancel");
Check it out
Sorry for that. Fixed!!
Reply
#9

Tip: I suggest you to set the color to white (-1) because not all scripters have COLOR_YELLOW defined.

Will look like this
PHP Code:
SendClientMessage(playerid, -1"I'm awesome and you know it"); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)