Spawn a vehicle close to my player
#5

Quote:
Originally Posted by kirollos
Посмотреть сообщение
you should use CreateVehicle instead as AddStaticVehicle is only used in OnGameModeInit

as written here https://sampwiki.blast.hk/wiki/AddStaticVehicle
Oh I am so sorry. Should have given this guy the code with CreateVehicle

Quote:
Originally Posted by Dugzor
Посмотреть сообщение
Thank you for the response. It worked! This is the final code I am using:
pawn Код:
CMD:veh(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:angle;
    new vehid, color1, color2;
       
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, angle);
       
    if (sscanf(params, "iii", vehid, color1, color2))
    {
        return SendClientMessage(playerid, -1, "Command usage: /veh [model id] [color 1] [color 2]");
    }
       
    if (IsPlayerInAnyVehicle(playerid))
    {
        return SendClientMessage(playerid, -1, "You can't spawn a vehicle while being inside one.");
    }
       
    AddStaticVehicle(vehid, (x + 5), (y + 5), z, angle, color1, color2);
    SendClientMessage(playerid, -1, "Vehicle was spawned.");
       
    return 1;
}
I would appreciate if someone listed down the improvements that need to be done and the mistakes I did.
Changed to createvehicle
pawn Код:
CMD:veh(playerid, params[])
{
    new Float:x, Float:y, Float:z, Float:angle;
    new vehid, color1, color2;
       
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, angle);
       
    if (sscanf(params, "iii", vehid, color1, color2))
    {
        return SendClientMessage(playerid, -1, "Command usage: /veh [model id] [color 1] [color 2]");
    }
       
    if (IsPlayerInAnyVehicle(playerid))
    {
        return SendClientMessage(playerid, -1, "You can't spawn a vehicle while being inside one.");
    }
       
    CreateVehicle(vehid, (x + 5), (y + 5), z, angle, color1, color2, 60);
    SendClientMessage(playerid, -1, "Vehicle was spawned.");
       
    return 1;
}
Reply


Messages In This Thread
Spawn a vehicle close to my player - by Dugzor - 11.09.2013, 05:18
Re: Spawn a vehicle close to my player - by [HK]Ryder[AN] - 11.09.2013, 05:31
Re: Spawn a vehicle close to my player - by Dugzor - 11.09.2013, 09:11
Re: Spawn a vehicle close to my player - by Kirollos - 11.09.2013, 11:03
Re: Spawn a vehicle close to my player - by [HK]Ryder[AN] - 11.09.2013, 13:10

Forum Jump:


Users browsing this thread: 5 Guest(s)