[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


Messages In This Thread
How To Make simple GPS system - by Patrick - 23.12.2012, 09:55
Re: How To Make simple GPS system - by DarkyTheAngel - 23.12.2012, 10:15
Re: How To Make simple GPS system - by Patrick - 23.12.2012, 10:33
Re: How To Make simple GPS system - by NicholasA - 23.12.2012, 11:05
Re: How To Make simple GPS system - by gtakillerIV - 23.12.2012, 12:20
Re: How To Make simple GPS system - by Patrick - 23.12.2012, 12:37
Re: How To Make simple GPS system - by [CG]Milito - 23.12.2012, 16:53
Re: How To Make simple GPS system - by Patrick - 24.12.2012, 16:49
Re: How To Make simple GPS system - by [CG]Milito - 27.12.2012, 19:28

Forum Jump:


Users browsing this thread: 2 Guest(s)