[Tutorial] How to create a simple Dialog Car Spawner.
#1

Hey SAMP users. Im going to show you how to create a Dialog Car Spawner and its pretty simple but it tends to take some time. Im going to start you off with the Basics of it, then you should be able to catch on. So here we go.

Im going to give you a little "Resource Table so you can grab these helpful post to help you out on this.

Vehicles
Car Colors (Optional)
ChangeVehicleColor(For Car Colors)

Okay, So lets get started

Were going to make a simple command for this.

ZCMD:

pawn Код:
CMD:spawncar(playerid,params[])
{
    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Cars:","Infernus\nElegy\nTurismo\n","Select","Cancel");
    return 1;
}
strcmp:

pawn Код:
if(strcmp("/spawncar", cmdtext, true) == 0)
{
    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Cars:","Infernus\nElegy\nTurismo\n","Select","Cancel");
    return 1;
}
DCMD:

pawn Код:
dcmd(spawncar,7,cmdtext);
pawn Код:
dcmd_spawncar(playerid,params[])
{
    #pragma unused params
    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Cars:","Infernus\nElegy\nTurismo\n","Select","Cancel");
    return 1;
}
Okay, these are the basic command. ShowPlayerDialog Is the dialog itself. It shows for the player (playerid). The Dialog ID is current 12 you can change that. and its a dialog_Style_List Format. Cars is the head of the Dialog and Infernus Elegy and Turismo are cars that we are going to add.
So, Now were going to go to OnDialogResponse.

pawn Код:
if(dialogid == 12)
        {
                if(response == 1)
                {
                   if(listitem == 0)
                        {
                            new Float:x, Float:y, Float:z, Float:a;
                            GetPlayerPos(playerid, x,y,z);
                            GetPlayerFacingAngle(playerid, a);
                            new vehicleid = CreateVehicle(411, x+3,y,z, a, -1, -1, -1);
                            PutPlayerInVehicle(playerid, vehicleid, 0);
                         }
                         if(listitem == 1)
                           {
                             new Float:x, Float:y, Float:z, Float:a;
                            GetPlayerPos(playerid, x,y,z);
                            GetPlayerFacingAngle(playerid, a);
                            new vehicleid = CreateVehicle(562, x+3,y,z, a, -1, -1, -1);
                            PutPlayerInVehicle(playerid, vehicleid, 0);
                                   
                         }
                        if(listitem == 2)
                           {
                               new Float:x, Float:y, Float:z, Float:a;
                               GetPlayerPos(playerid, x,y,z);
                               GetPlayerFacingAngle(playerid, a);
                               new vehicleid = CreateVehicle(451, x+3,y,z, a, -1, -1, -1);
                               PutPlayerInVehicle(playerid, vehicleid, 0);
                                }
                            }
                        }
I will tell you what this does. This will get the coordinates of where you are X,Y,Z and it will get your faceing Angle.
This will create the vehicle desired and it will spawn it move you 3 time on the X axis. Then, this will put you into the vehicle.



Thanks pretty much it guys, pretty simple but great for a stunt or admin script. :]

Thanks for reading!
Reply
#2

That code will not actually put the player in the vehicle because you are using GetVehicleID before you are putting the player in the vehicle.

You should do this:
pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
new vehicleid = CreateVehicle(411, x+3,y,z, a, -1, -1, -1);
PutPlayerInVehicle(playerid, vehicleid, 0);
Otherwise, not a bad tutorial .
Reply
#3

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
That code will not actually put the player in the vehicle because you are using GetVehicleID before you are putting the player in the vehicle.

You should do this:
pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
new vehicleid = CreateVehicle(411, x+3,y,z, a, -1, -1, -1);
PutPlayerInVehicle(playerid, vehicleid, 0);
Otherwise, not a bad tutorial .
Okay, thank you updating
Reply
#4

I would make something like this
pawn Код:
stock createVehForPlayer( playerid, vehmodel )
{
    new
        Float: pos[ 4 ]
    ;

    GetPlayerPos( playerid, pos[ 0 ], pos[ 1 ], pos[ 2 ] );

    GetPlayerFacingAngle( playerid, pos[ 3 ] );

    new
        iVeh = CreateVehicle( vehmodel, pos[ 0 ], pos[ 1 ], pos[ 2 ], pos[ 3 ], -1, -1, -1 )
    ;

    SetVehicleVirtualWorld( iVeh, GetPlayerVirtualWorld( playerid ) );

    LinkVehicleToInterior( iVeh, GetPlayerInterior( playerid ) );

    PutPlayerInVehicle( playerid, iVeh, 0 );

    return 1;
}

public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
    if ( dialogid == 12 )
    {
        if ( response )
        {
            new
                iList[ ] = { 411, 562, 451 };

            createVehForPlayer( playerid, iList[ listitem ] );
        }
   }

   return 1;
}
Not a bad tutorial.
Reply
#5

Код:
D:\Allt\SAMP RPG\gamemodes\stunt.pwn(106) : warning 203: symbol is never used: "spawncar"
?
Reply
#6

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
Код:
D:\Allt\SAMP RPG\gamemodes\stunt.pwn(106) : warning 203: symbol is never used: "spawncar"
?
You must of forget the C in CMD
Reply
#7

My pwn code... in game it says "Unknown Command"

code:

http://pastebin.com/TVSdQC1C
Reply
#8

I like how you included strcmp dcmd zcmd !!!

heres the YCMD
pawn Код:
YCMD:spawncar(playerid, params[], help)
{
#pragma unused params
    if (help)   {SendClientMessage(playerid, 0xFFCC33AA, "/spawncar : Spawn a Car");}
    else        {ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Cars:","Infernus\nElegy\nTurismo\n","Select","Cancel");}
    return 1;
}

nice tut! simple 8/10


@XphosKill3r

your onPlayerCommandText function is missing
pawn Код:
return 0;
}
at the bottom


from what i can see
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)