SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/08/2017, 09:02 PM   #1
fxckshzt
Huge Clucker
 
Join Date: Jul 2017
Location: 127.0.0.1
Posts: 272
Reputation: 11
Post Base of GPS in Dialog

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.
PHP Code:
#define DIALOG_GPS    1
//#define DIALOG_NAME      DIALOG_NUMBER 
Second step:
Let's create a variable to be recognized when the player arrives at the location and the point is removed.
PHP Code:
new GPSLocal[MAX_PLAYERS];
//new nome_of_variable[MAX_PLAYERS]; (Refers to the maximum number of players found on the server) 
Third step
Let's call OnPlayerEnterCheckPoint (playerid) and we'll do the checks inside the variable.
PHP Code:
public OnPlayerEnterCheckpoint(playerid)
{
    if(
GPSLocal[playerid] == 1)
    {
        
GPSLocal[playerid] = 0;
        
DisablePlayerCheckpoint(playerid);
    }
    return 
1;

Explanation of the above actions:
Code:
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
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.
PHP Code:
CMD:gps(playerid)
{
ShowPlayerDialog (playeridDIALOG_GPSDIALOG_STYLE_LIST"GPS""LOTTERY HOUSE""Select""Close");
return 
1;

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.
PHP Code:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    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;

Explanation of the above action:
Code:
 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.
Finally, the whole function will be as follows:

PHP Code:
#include <a_samp>
#include <zcmd>

#define DIALOG_GPS      1

new GPSLocal[MAX_PLAYERS];

CMD:gps(playerid)
{
    
ShowPlayerDialog(playeridDIALOG_GPSDIALOG_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(playeriddialogidresponselistiteminputtext[])
{
    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;

@Extra:

If you want the command to turn off the gps:
Note:Just add the command

PHP Code:
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;


Have the option to turn off GPS in Dialog:
Note:Necessary to add another line of the ShowPlayerDialog command "/gps"

PHP Code:
CMD:gps(playerid)
{
    
ShowPlayerDialog(playeridDIALOG_GPSDIALOG_STYLE_LIST"GPS""TURN OFF GPS\nLOTERICA""Selecionar""Fechar");
    return 
1;
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    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(playerid1289.8077, -1654.259013.54698.0);
                   
SendClientMessage(playerid,-1,"[INFO] - Lottery has been marked on your map!");
                 
GPSLocal[playerid] = 1;
               }
           }
       }
    return 
1;

Thank You

Source: Pastebin
__________________
Paz & Amor
fxckshzt is offline   Reply With Quote
Old 26/08/2017, 01:39 AM   #2
STRIKER19501
Little Clucker
 
STRIKER19501's Avatar
 
Join Date: Aug 2017
Location: Behind you
Posts: 32
Reputation: 6
Default Re: Base of GPS in Dialog

Nyc explaination ,good for newbies like me ,thnx and +rep for teaching us sharing ur knowledge
STRIKER19501 is offline   Reply With Quote
Old 26/08/2017, 03:35 AM   #3
fxckshzt
Huge Clucker
 
Join Date: Jul 2017
Location: 127.0.0.1
Posts: 272
Reputation: 11
Default Re: Base of GPS in Dialog

Thank You
__________________
Paz & Amor
fxckshzt is offline   Reply With Quote
Old 26/08/2017, 03:40 AM   #4
GuilhermeNunes
Gangsta
 
Join Date: Feb 2017
Posts: 586
Reputation: 8
Default Re: Base of GPS in Dialog

Good Base.
GuilhermeNunes is offline   Reply With Quote
Old 27/08/2017, 10:21 AM   #5
SuperHelper
Banned
 
Join Date: Aug 2017
Posts: 43
Reputation: 1
Default Re: Base of GPS in Dialog

Good Tutorial
SuperHelper 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] Base de GPS em dialog fxckshzt Lançamentos/Releases 6 23/08/2017 03:56 AM
[FilterScript] [BASE DA BASE] aProp - Sistema de Propriedades(casas) v0.0001 Axll Lançamentos/Releases 63 02/08/2014 07:57 PM
[Map] Desert Admin Base or Team Base fanta291327 Maps 16 07/12/2013 05:30 AM
[GameMode] [BASE]Brasil Ultimate Deathmatch[BASE] Jake_Dunlapp Lançamentos/Releases 27 12/05/2012 01:54 PM
[Map] Rock Base/Cave/Admin Base/Garage (whatever you want to call it) Firzendxiw Maps 11 21/06/2011 01:27 AM


All times are GMT. The time now is 07:38 PM.


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