PutPlayerInVehicle?
#1

pawn Код:
CMD:vehspawn(playerid, params[])
{
    new string[128], modelid, color1, color2;
    new Float: x, Float: y, Float: z;
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "ddd", modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vehspawn [modelid] [color 1] [color 2]");
       
        GetPlayerPos(playerid, x, y, z);
        CreateVehicle(modelid, x, y, z, 90.0, color1, color2, -1);
        format(string, sizeof(string), "You have created a vehicle! Model ID: %d, color(1): %d, color(2): %d.", modelid, color1, color2);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        PutPlayerInVehicle(playerid, , 0);
    }
    return 1;
}
How would I call the vehicle ID I just created and then place the player inside the vehicle on creation?
Thank you
Reply
#2

The vehicle creation functions return the ID as soon as the vehicle is made, so nesting the PutPlayerInVehicle function around the CreateVehicle function should work.

pawn Код:
PutPlayerInVehicle(playerid, CreateVehicle(modelid, x, y, z, 90.0, color1, color2, -1), 0);
Reply
#3

pawn Код:
CMD:vehspawn(playerid, params[])
{
    new string[128], modelid, color1, color2;
    new Float: x, Float: y, Float: z;
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(sscanf(params, "ddd", modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vehspawn [modelid] [color 1] [color 2]");
       
        GetPlayerPos(playerid, x, y, z);
        new pvehicle;
        pvehicle = CreateVehicle(modelid, x, y, z, 90.0, color1, color2, -1);
        format(string, sizeof(string), "You have created a vehicle! Model ID: %d, color(1): %d, color(2): %d.", modelid, color1, color2);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        PutPlayerInVehicle(playerid, , pvehicle);
    }
    return 1;
}
Late.
Reply
#4

Thanks Calgon, rep'd!

Worked!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)