[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


Messages In This Thread
[TUT]How to create a vehicle dialog menu - by Toni - 15.07.2010, 00:47
Re: [TUT]How to create a vehicle dialog menu - by zSuYaNw - 15.07.2010, 00:58
Re: [TUT]How to create a vehicle dialog menu - by Toni - 15.07.2010, 01:00
Re: [TUT]How to create a vehicle dialog menu - by Vampiruue - 09.08.2010, 00:56
Re: [TUT]How to create a vehicle dialog menu - by Toni - 09.08.2010, 03:26
Re: [TUT]How to create a vehicle dialog menu - by Vampiruue - 09.08.2010, 04:15
Re: [TUT]How to create a vehicle dialog menu - by Hiddos - 09.08.2010, 08:46
Re: [TUT]How to create a vehicle dialog menu - by [XST]O_x - 09.08.2010, 08:52
Re: [TUT]How to create a vehicle dialog menu - by Hiddos - 09.08.2010, 08:53
Re: [TUT]How to create a vehicle dialog menu - by hab2ever - 09.08.2010, 10:28
Re: [TUT]How to create a vehicle dialog menu - by jpboy1 - 18.08.2010, 09:24
Re: [TUT]How to create a vehicle dialog menu - by Shockey - 06.09.2010, 02:53
Re: [TUT]How to create a vehicle dialog menu - by Scenario - 06.09.2010, 03:13
Re: [TUT]How to create a vehicle dialog menu - by Toni - 06.09.2010, 03:14
Re: [TUT]How to create a vehicle dialog menu - by Shockey - 06.09.2010, 03:18
Re: [TUT]How to create a vehicle dialog menu - by Toni - 06.09.2010, 03:40
Re: [TUT]How to create a vehicle dialog menu - by Shockey - 06.09.2010, 08:18
Re: [TUT]How to create a vehicle dialog menu - by [BC]mrblonde - 19.09.2010, 19:09
Re: [TUT]How to create a vehicle dialog menu - by Toni - 19.09.2010, 19:18
Re: [TUT]How to create a vehicle dialog menu - by ExeC - 13.11.2010, 13:28
Re: [TUT]How to create a vehicle dialog menu - by HyperZ - 13.11.2010, 14:55
Re: [TUT]How to create a vehicle dialog menu - by maycore - 25.02.2011, 18:32
Re: [TUT]How to create a vehicle dialog menu - by tim10000 - 28.02.2011, 16:17
Re: [TUT]How to create a vehicle dialog menu - by tim10000 - 28.02.2011, 17:01
Re: [TUT]How to create a vehicle dialog menu - by bestr32 - 15.03.2011, 20:10
Re: [TUT]How to create a vehicle dialog menu - by SkizzoTrick - 15.03.2011, 20:21
Re: [TUT]How to create a vehicle dialog menu - by IvancheBG - 27.03.2011, 09:04
Re: [TUT]How to create a vehicle dialog menu - by NeymarJr - 30.05.2012, 11:46
Re: [TUT]How to create a vehicle dialog menu - by NeymarJr - 30.05.2012, 11:50
Re: [TUT]How to create a vehicle dialog menu - by SkL_MD - 30.05.2012, 16:05
Re: [TUT]How to create a vehicle dialog menu - by mickos - 04.06.2012, 16:54
Re: [TUT]How to create a vehicle dialog menu - by samlockyer - 17.06.2012, 11:14
Re: [TUT]How to create a vehicle dialog menu - by Povis - 18.08.2012, 09:16
Re: [TUT]How to create a vehicle dialog menu - by Pilip93 - 08.07.2013, 23:38
Re: [TUT]How to create a vehicle dialog menu - by Mindcode - 09.07.2013, 12:45

Forum Jump:


Users browsing this thread: 5 Guest(s)