SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 23/12/2012, 09:55 AM   #1
Patrick
Guest
 
Posts: n/a
Default How To Make simple GPS system

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: http://forum.sa-mp.com/showthread.php?t=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;
}

Last edited by Patrick; 27/12/2012 at 08:31 PM.
  Reply With Quote
Old 23/12/2012, 10:15 AM   #2
DarkyTheAngel
Big Clucker
 
DarkyTheAngel's Avatar
 
Join Date: Jan 2012
Location: Narnia
Posts: 130
Reputation: 44
Default Re: How To Make simple GPS system

First.
Nice one buddy.
__________________
DarkyTheAngel is offline   Reply With Quote
Old 23/12/2012, 10:33 AM   #3
Patrick
Guest
 
Posts: n/a
Default Re: How To Make simple GPS system

Thanks
  Reply With Quote
Old 23/12/2012, 11:05 AM   #4
NicholasA
Huge Clucker
 
NicholasA's Avatar
 
Join Date: Nov 2012
Location: Athene
Posts: 398
Reputation: 9
Default Re: How To Make simple GPS system

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
__________________
CoMiC SaNs
NicholasA is offline   Reply With Quote
Old 23/12/2012, 12:20 PM   #5
gtakillerIV
Gangsta
 
gtakillerIV's Avatar
 
Join Date: Sep 2011
Location: UAE, Sharjah.
Posts: 985
Reputation: 201
Default Re: How To Make simple GPS system

Not much is really explained, explain more.
gtakillerIV is offline   Reply With Quote
Old 23/12/2012, 12:37 PM   #6
Patrick
Guest
 
Posts: n/a
Default Re: How To Make simple GPS system

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 With Quote
Old 23/12/2012, 04:53 PM   #7
[CG]Milito
Huge Clucker
 
[CG]Milito's Avatar
 
Join Date: Sep 2012
Posts: 329
Reputation: 14
Default Re: How To Make simple GPS system

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
__________________
[CG]Milito is offline   Reply With Quote
Old 24/12/2012, 04:49 PM   #8
Patrick
Guest
 
Posts: n/a
Default Re: How To Make simple GPS system

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 With Quote
Old 27/12/2012, 07:28 PM   #9
[CG]Milito
Huge Clucker
 
[CG]Milito's Avatar
 
Join Date: Sep 2012
Posts: 329
Reputation: 14
Default Re: How To Make simple GPS system

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"); 
__________________
[CG]Milito is offline   Reply With Quote
Old 22/01/2020, 11:55 AM   #10
MayankBoss
Banned
 
Join Date: Dec 2019
Posts: 5
Reputation: 0
Default Re: How To Make simple GPS system

i want to add another gps i cant do it help me out
MayankBoss is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] How to make simple gps system. Gangster-rocks Tutorials 17 24/01/2015 06:30 AM
How can I make a simple phone system? davelord Scripting Help 3 30/09/2012 02:52 PM
[Tutorial] How to Make a Simple payday system Dare Devil..... Tutorials 2 10/06/2012 11:32 PM


All times are GMT. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.