[Tutorial] [TUT]How to create a vehicle dialog menu
#1

Creating Dialog Vehicle Menu
Hello,

This is a tutorial on how to create a dialog, that spawns vehicles at your location.

First off lets assign a ID to the dialog:

pawn Код:
#define vmenu 159156
Then next we are gonna make our dialog list (of course with a command):

pawn Код:
if(!strcmp(cmdtext, "/vmenu", true))
{
    ShowPlayerDialog(playerid, vmenu, DIALOG_STYLE_LIST, "Vehicle Menu", "Andromada \nDodo \nSultan \nInfernus", "Spawn", "Cancel");
    return 1;
}
Now that we have a list of vehicles (you can add more later, and into categories by adding more dialog lists).

Now lets create a declaration, and make it global so we don't have to keep creating more.

pawn Код:
new Float:X, Float:Y, Float:Z, Float:Angle, pInt;
Now that we have all that, lets go create the vehicles (we add it to the callback OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) )
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, Angle);
    pInt = GetPlayerInterior(playerid);
    switch(dialogid) {
    case: vmenu
    {
        if(response)
        {
            if(listitem == 0)   // The Andromada
            {
                CreateVehicle(592, X+5, Y, Z+1, Angle, random(100), random(100), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid), pInt);
            }
            if(listitem == 1)   // Dodo
            {
                CreateVehicle(593, X+5, Y, Z+1, Angle, random(100), random(100), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid), pInt);
            }
            if(listitem == 2)   // Sultan
            {
                CreateVehicle(560, X+5, Y, Z+1, Angle, random(100), random(100), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid), pInt);
            }
            if(listitem == 3)   // Infernus
            {
                CreateVehicle(411, X+5, Y, Z+1, Angle, random(100), random(100), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid), pInt);
            }
        }
        return 1;
    }
    return 0;
}
Now, lets cut it down into sections.

GetPlayerPos(playerid, X, Y, Z); - That function gets the player's X, Y, Z position, so the script knows where to create the vehicle.

GetPlayerFacingAngle(playerid, Angle); - That function will get your angle so it can spawn the vehicle the same angle as your angle.

pInt = GetPlayerInterior(playerid); - That function will get your interior so if you are somewhere else, it may be spawned there as well.

switch(dialogid) { }
case: vmenu - That function will check if the menu is the vehicle dialog.

if(response) - will check if the player responded to the dialog or not.

if(listitem == 0) - Will check the item id on the list (as the andromada is now the first one on the list, so it is item 0.

CreateVehicle(); - Will create the vehicle at your position. (The parameters are below)
pawn Код:
592 = Vehicle Model
X+5 = The Player's X position, + 5 X unit's
Y   = The Player's Y position.
Z+1 = The Player'
s Z position, + 1 Z Unit
Angle = The Player's Angle.
random(100) = Vehicle Color 1, but random colors 0 through 100
random(100) = Vehicle Color 2, but random colors 0 through 100
-1 = Never Respawn again
LinkVehicleToInterior = that one is self explanatory.
GetPlayerVehicleID(playerid) = Get the players vehicle id that they spawned
pInt = The declaration that gets the player's interior

Thats it! Just repeat those if(listitem == ) id's the item's ID
and the Create vehicle function!

Hoped that help a lot

- Toni

Updated recently, I didn't have an editor to actually format it so it's a little derp and out dated. This is not a recommended tutorial for first off beginners that don't know basic coding.
Reply
#2

Nice,Tut,Congratulations!
Reply
#3

Quote:
Originally Posted by [Full]Garfield[XDB]
Посмотреть сообщение
Nice,Tut,Congratulations!
Thanks its my first
Reply
#4

i get erros can u help me out?
Reply
#5

Quote:
Originally Posted by Vampiruue
Посмотреть сообщение
i get erros can u help me out?
Can you show me the errors ?
Reply
#6

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Can you show me the errors ?
i can and here they r idk awt happen i just copyed from the thing and followed the instructions
heres my errors
Код:
 D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(2) : error 010: invalid function or declaration
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(4) : error 010: invalid function or declaration
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(7) : error 010: invalid function or declaration
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(11) : warning 235: public function lacks forward declaration (symbol "OnDialogResponse")
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(13) : error 017: undefined symbol "GetPlayerPos"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(14) : error 017: undefined symbol "GetPlayerFacingAngle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(15) : error 017: undefined symbol "GetPlayerInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(23) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(23) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(27) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(27) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(31) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(31) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(35) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(35) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(39) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(39) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(41) : warning 217: loose indentation
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(43) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(43) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(47) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(47) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(51) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(51) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(55) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(55) : error 017: undefined symbol "LinkVehicleToInterior"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(59) : error 017: undefined symbol "CreateVehicle"
D:\downloads\GTA\samp 0.3 server\filterscripts\Carmenu.pwn(59) : error 017: undefined symbol "LinkVehicleToInterior"
Reply
#7

Download the new SA-MP server version.

Few things:
Random(bla) starts at 0 and ends at bla-1, so if you'd the random(100), the minimum would be 0 and the maximum would be 99.

Other to that, use '-1' for a default random color (A colour San Andreas randomly gives to its cars, not pink to trucks or something but just darkgreen etc. etc.)

One last suggestion: Use switch(listitem) with cases, instead of if(listitem == 0)

Looks nice, good job.
Reply
#8

You may want to get the XY in front of the player in order the car to spawn in the front
Nice tut anyway.
Reply
#9

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
You may want to get the XY in front of the player in order the car to spawn in the front
Nice tut anyway.
You might also want to put the player in the vehicle :P
Reply
#10

Nice work
Reply
#11

i have 1 problem.
as i spawn the car and drive and it explodes and then i go back to the spawnpoint of the vehicle the car is back.
but i want as the car explodes that the vehicle is gone.

please help me!

srry for bad English. it's cause i'm Dutch
Reply
#12

Nice work but for beginners they wouldn't know where to put like the

#define vmenu 159156
and the
new Float:X, Float:Y, Float:Z, Float:Angle, pInt

other than that great tut

suggestion:
make a car dialog exactly Luke this but how to make categories like cars planes etc...
Coz I wanna know how to make categories so I can make a full vehicle menu with every vehicle


-Thankyou
Reply
#13

Not bad. Simple, but useful.
Reply
#14

Quote:
Originally Posted by Shockey
View Post
Nice work but for beginners they wouldn't know where to put like the

#define vmenu 159156
and the
new Float:X, Float:Y, Float:Z, Float:Angle, pInt

other than that great tut

suggestion:
make a car dialog exactly Luke this but how to make categories like cars planes etc...
Coz I wanna know how to make categories so I can make a full vehicle menu with every vehicle


-Thankyou
Yeah...ermm I'll do that when I have a little free time

Quote:
Originally Posted by RealCop228
View Post
Not bad. Simple, but useful.
Thanks.
Reply
#15

plz have free time fast coz I need to know in a hurry or could u just tell mr how to with just the listitem part and don't explain anything just post a category say cars

and then just do the listitem part plzz and with only 2"1 vehicle and dint explain anything

just fof Now so I can make my menu pllllzzzz
Reply
#16

I'll make it 2morrow, I just spent a day playing The Sims 3 <3333

that game is addicting O.O I bought it 3 hr's ago, and I already am married and have 1 million $$'s
Reply
#17

Wow already , and ty but I know how now
Reply
#18

Sorry but where does this go again?

if(!strcmp(cmdtext, "/vmenu", true))
{
if(!strcmp(cmdtext, "/vmenu", true))
{
ShowPlayerDialog(playerid, vmenu, DIALOG_STYLE_LIST, "Vehicle Menu", "Andromada \nDodo \nSultan \nInfernus", "Spawn", "Cancel");
return 1;
}
}
Reply
#19

Quote:
Originally Posted by [BC]mrblonde
View Post
Sorry but where does this go again?

if(!strcmp(cmdtext, "/vmenu", true))
{
ShowPlayerDialog(playerid, vmenu, DIALOG_STYLE_LIST, "Vehicle Menu", "Andromada \nDodo \nSultan \nInfernus", "Spawn", "Cancel");
return 1;
}
OnPlayerCommandText.
Reply
#20

Nice , but when i click on, for example, Infernus, it doesn't spawn anything . Any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)