SA-MP Forums Archive
PutPlayerInVehicle? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PutPlayerInVehicle? (/showthread.php?tid=386938)



PutPlayerInVehicle? - RLGaming - 22.10.2012

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


Re: PutPlayerInVehicle? - Calgon - 22.10.2012

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);



Re: PutPlayerInVehicle? - Adil - 22.10.2012

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.


Re: PutPlayerInVehicle? - RLGaming - 22.10.2012

Thanks Calgon, rep'd!

Worked!