Spawning a car question +Rep
#1

So, this is what im doing


pawn Код:
CMD:givecar(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] <= 2)
    return SendClientMessage)playerid, 0xFF0000FF, "Your not a high enough level to use this command");
    {
    ShowPlayerDialog(playerid, DIALOG_CAR, DIALOG_STYLE_INPUT, "Spawn A Car", "Please Type A Car ID To Spawn","Select","Cancel");
    }
    return 1;
}

My question is would i be able to make that into a DIALOG_STYLE_LIST and if i did would i have to do this for every single car


pawn Код:
if(dialogid == DIALOG_CAR)
    {
        if(response)
        {
            new message[256+1];
            if(listitem == 0)
            {
            format(message, 256, "You selected a Landstalker", listitem);
            SendClientMessage(playerid, 0xFFFFFFFF, message);
            CreateVehicle(1);
            }
            if(listitem == 1)
            {
              format(message, 256, "You selected a Bravura", listitem);
              SendClientMessage(playerid, 0xFFFFFFFF, message);
              CreateVehicle(2);
            }
            if(listitem == 2)
            {
              format(message, 256, "You have selected a Buffalo", listitem);
              SendClientMessage(playerid, 0xFFFFFFFF, message);
              CreateVehicle(3);
            }
            if(listitem == 3)
            {
              format(message, 256, "You have selected a Manana", listitem);
              SendClientMessage(playerid, 0xFFFFFFFF, message);
              CreateVehicle(4);
            }
            if(listitem == 4)
            {
              format(message, 256, "You have selected a Infernus", listitem);
              SendClientMessage(playerid, 0xFFFFFFFF, message);
              CreateVehicle(5);
            }
            if(listitem == 5)
            {
              format(message, 256, "You have selected a Voodoo", listitem);
              SendClientMessage(playerid, 0xFFFFFFFF, message);
              CreateVehicle(6);
            }
        }
    }

Thank You
Reply
#2

I wouldn't suggest doing it because it takes more time your way is the way i do it
Reply
#3

Yes you would have to do it for every vehicle.
Reply
#4

Quote:
Originally Posted by Tee
Посмотреть сообщение
Yes you would have to do it for every vehicle.
Is there no quicker way
Reply
#5

Why does this not work


pawn Код:
if(dialogid == DIALOG_CAR)
    {
        if(response)
        {
            new car = strval(inputtext);
            {
             CreateVehicle( playerid, strval(inputtext));
             SendClientMessage(playerid, COLOR_GOLD, "Car Spawned");
             }
        }
    }
 }
Reply
#6

No that wouldn't work, do you want to create a vehicle by typing it's name?
Reply
#7

Quote:
Originally Posted by Tee
Посмотреть сообщение
No that wouldn't work, do you want to create a vehicle by typing it's name?
No when i do /givecar


A dialog pops up and it tells me to enter a car ID i do but nothing happens
Reply
#8

Here: http://pastebin.com/raw.php?i=ppTY73n6
That's Garsino's vehicle spawn dialog (with some changes), so credits go to him. You should know where to put the snippets.
All vehicles are in it.
Reply
#9

Quote:
Originally Posted by Tee
Посмотреть сообщение
Here: http://pastebin.com/raw.php?i=ppTY73n6
That's Garsino's vehicle spawn dialog (with some changes), so credits go to him. You should know where to put the snippets.
All vehicles are in it.
I have this but it still dont work

pawn Код:
#include <a_vehicles>
pawn Код:
#define DIALOG_CAR 10

pawn Код:
new CurrentSpawnedVehicle[MAX_PLAYERS],Float:X,Float:Y,Float:Z,Angle;

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

if(dialogid == DIALOG_CAR)
    {
        if(response)
        {

            new car = strval(inputtext);
            {
             CreateVehicleEx(playerid,strval(inputtext), X,Y,Z+1, Angle, random(126), random(126), -1);
             SendClientMessage(playerid, COLOR_GOLD, "Car Spawned");
             }
        }
    }
 }
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
                return 1;
            }
        }
    }
    return 0;
}
     
stock CreateVehicleEx(playerid, modelid, Float:posX, Float:posY, Float:posZ, Float:angle, Colour1, Colour2, respawn_delay)
{
    new world = GetPlayerVirtualWorld(playerid);
    new interior = GetPlayerInterior(playerid);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        DestroyVehicle(GetPlayerVehicleID(playerid));
        GetPlayerPos(playerid, posX, posY, posZ);
        GetPlayerFacingAngle(playerid, angle);
        CurrentSpawnedVehicle[playerid] = CreateVehicle(modelid, posX, posY, posZ, angle, Colour1, Colour2, respawn_delay);
        LinkVehicleToInterior(CurrentSpawnedVehicle[playerid], interior);
        SetVehicleVirtualWorld(CurrentSpawnedVehicle[playerid], world);
        SetVehicleZAngle(CurrentSpawnedVehicle[playerid], angle);
        PutPlayerInVehicle(playerid, CurrentSpawnedVehicle[playerid], 0);
        SetPlayerInterior(playerid, interior);
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(IsVehicleOccupied(CurrentSpawnedVehicle[playerid])) {} else DestroyVehicle(CurrentSpawnedVehicle[playerid]);
        GetPlayerPos(playerid, posX, posY, posZ);
        GetPlayerFacingAngle(playerid, angle);
        CurrentSpawnedVehicle[playerid] = CreateVehicle(modelid, posX, posY, posZ, angle, Colour1, Colour2, respawn_delay);
        LinkVehicleToInterior(CurrentSpawnedVehicle[playerid], interior);
        SetVehicleVirtualWorld(CurrentSpawnedVehicle[playerid], world);
        SetVehicleZAngle(CurrentSpawnedVehicle[playerid], angle);
        PutPlayerInVehicle(playerid, CurrentSpawnedVehicle[playerid], 0);
        SetPlayerInterior(playerid, interior);
    }
    return 1;
}

Please Help Me Please
Reply
#10

Replace this:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

if(dialogid == DIALOG_CAR)
    {
        if(response)
        {

            new car = strval(inputtext);
            {
             CreateVehicleEx(playerid,strval(inputtext), X,Y,Z+1, Angle, random(126), random(126), -1);
             SendClientMessage(playerid, COLOR_GOLD, "Car Spawned");
             }
        }
    }
 }
With the one I posted. Don't replace your entire OnDialogResponse callback, only from "if(dialogid == CARMENU)"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)