[Tutorial] Team selecting using dialogs
#1

1) Introduction

That is my first tutorial , and i wish it will be very helpful for people who were looking for a tuto like this .

2) Requirements

The only thing you need is a_samp.inc , realy ! only that include !

3) Let's start

Step 1 - defines
put this under #include <a_samp> ( if you didn't find it use CTRL + F )
pawn Code:
#define DIALOG_TEAMS        9999
#define TEAM_GREEN      0
#define TEAM_RED         1
#define COLOR_GREEN    0x9EC73DAA
#define COLOR_RED        0xAA3333AA
what is this ? i will answer you ! DIALOG_TEAMS is the dialog name if you want to change this you will have to do alot of work , "9999" is the dialog's id , you gotta remembre this very well because you will use it again , you are able to change it but i don't wanna make this thread full of uneeded informations .
TEAM_GREEN and TEAM_RED is the team names and the number on the right is there id , you choose the id but now i'm making it simple using 0 and 1
COLOR_RED and COLOR_GREEN are color defines and all that numbres and lettres on the right in there color code
Step 2 - ShowPlayerDialog
oh ! the most importent thing ! you don't need a dialog if you won't show it to some one !
it is used like this :
ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[])
playerid : it is the player who we will show the dialog for
dialogid : still remembre what i said before ? ' 9999 is the dialog's id , you gotta remembre this very well because you will use it again '
style : it is the dialog's style and you can see all the styles here
caption[] : i like calling it the title , it appears up the dialog change this to any dialog title , i will be using "teams" .
info[] : if this is a DIALOG_STYLE_LIST this is his menu items .
button1[] : in the Down-Left of the dialog change it to what ever you like . i'm changing it to "select" .
button2[] : i'm not using it in this tuto but i'm gonna explain it to you . same as button1 but it is on the Down-Right of the dialog to just remove it leave it like this ""

ok enough explain ! let's go to the real deal !
add this to OnPlayerRequestClass ( if you didn't find it use CTRL + F )
why exactly OnPlayerRequestClass ? because it is called when the player can shoose his team genuis !
pawn Code:
ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_LIST, "Teams", "teamgreen\nteamred", "Select","");
/* this green things are not codes or some thing like that , it is just some comments can be added to the script .
now explaining to you :
playerid : means the player that we gonna show the dialog to him
9999 : you can't let me spam in this thread i allready told you !
DIALOG_STYLE_LIST : is the style that makes you use list items .
"teams" : i allready told about the title . make sure you DO NOT delete " " or it won't work !
"teamgreen\nteamred" : teamgreen is our first team change it to the team you need in your script but since it is a tuto i'm shooing you an example , \n is what makes you jump from teamgreen and teamred , if you won't add it both teams will be in one item ( changing \n with /n makes alot of diffrence , i don't want some one to replace \n with /n and tell me that this isn't working so all ways make sure your code is right ) same as "teams" don't delete " "
"select" : in the Down-Left of the dialog , will be used in OnDialogReponse ( i will explain what is it later )
"" ( an empty thing ? ) : that empty thing is button2[] and i explainded it before .
*/
very common probleme :
error 001: expected token: ";", but found "return" what i do !!! an error !!! i can't compile with an error in my script !!
don't worry make sure you added ; in the end of the code , if you didn't it will show you this error while compiling .

Step 3 - OnDialogResponse
why exactly OnPlayerRequestClass ? because it is called when the player answer a dialog , it explain it self by it self !

add all of these and i will explain later OK ?

pawn Code:
if(dialogid == 9999)
{
        if(response) // means that they selected the button1[] wish is "select"
        {
                 if(listitem == 0) // They selected the first team - green
                 {
                         SetSpawnInfo(playerid,0,179,-797.4404,1556.8363,27.1244,91.0125,31,250,27,50,24,150);
                         SetPlayerColor(playerid, COLOR_GREEN);
                 }
                 if(listitem == 1) // They selected the second team - red
                 {
                         SetSpawnInfo(playerid,1,206,1290.1151,270.7815,19.5547,249.2941,31,250,27,50,24,150);
                         SetPlayerColor(playerid, COLOR_RED);
                 }
        }
}

/*
SetSpawnInfo(playerid , teamid , skin , float:x , float:y , float:z , float:rotation , weapon1 , weapon1_ammo , weapon2 , weapon2_ammo , weapon3 , weapon3_ammo );
playerid : the player who we will set his spawn co-ordinates
team : we defined some teams in the beginning still remembre them ?
skin : all the skin id's can be found in the [URL="https://sampwiki.blast.hk/wiki/Skins"]wiki[/URL]
float:x , float:y , float:z , float:rotation  : are all co-ordinates , you can use mien or go to sa-mp , ( i recommend debug ) and use save in any place you want
weapon1 , weapon1_ammo : weapon1 , change it to the weapon id you want , all weapon id's can be found in the [URL="https://sampwiki.blast.hk/wiki/Weapons"]wiki[/URL] and weapon1_ammo is this previos weapon's ammo , (e.g i give him AK47 [id 30] and give him 250 ammo , simple !
weapon2 , weapon2_ammo + weapon3 , weapon3_ammo : as i explaind before

NOTE : If you don't wanna give them any weapons put 0 instend of the weapon id */
Voilа ! you can now select teams with dialogs !


now and just because i'm not busy i will tell you how to make a /reclass command !

Go to OnPlayerCommandText ( if you didn't find it use CTRL + F )
pawn Code:
if (strcmp("/reclass", cmdtext, true, 10) == 0)
    {
        ForceClassSelection(playerid);
        return 1;
    }
}
/* and for ZCMD users ! ( unlike me )

CMD:reclass(playerid, params[])
{
    ForceClassSelection(playerid);
    return 1;
}
Hope you find this useful !
Reply
#2

come on ! any reply ? please ?
Reply
#3

It has some grammar and sentence structure errors, but it is MUCH better than any of the wiki articles, which tend to be misleading. Overall, I would give it a 7.5, because it is a good tutorial, but the typing is a little messy.
Reply
#4

I better use case in you'r script ;/
Reply
#5

you mean menus instend of dialogs ? nah i tried it and it is not so good
Reply
#6

Very good for a first tutorial, I was the same,

8/10
Reply
#7

Quote:
Originally Posted by MrCoder
View Post
Very good for a first tutorial, I was the same,

8/10
Thank you very mush
Reply
#8

Great as a beginner tutorial but it could have been more better.
Reply
#9

Piece of cake !
Reply
#10

Quote:
Originally Posted by Nirzor
View Post
Great as a beginner tutorial but it could have been more better.
How ?
Reply
#11

Dude, This is good tutorial

TWO THUMBS UP FOR THIS!
Reply
#12

(971) : error 017: undefined symbol "dialogid"
(973) : error 017: undefined symbol "response"
(975) : error 017: undefined symbol "listitem"
(980) : error 017: undefined symbol "listitem"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
how to fix these?
Reply
#13

please show me ShowPlayerDialog and #define DIALOG_TEAMS 9999

maybe you put it in a ronge callback , check if the callback is OnDialogResponse
Reply
#14

nicely done, Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)