16.10.2010, 02:16
I tested this in a filterscript, and it seems to work fine, although I would get the players angle and include that in the code.
the only thing did was remove the admin check, and change the variable that the carid was stored in.
as for destroying the vehicle after you get out, create a global variable...
may need some fine tuning
pawn Code:
new veh;
command(spawncar, playerid, params[])
{
new carid, color1, color2, Float: CarToX, Float: CarToY, Float: CarToZ;
if(sscanf(params, "ddd", carid, color1, color2))
{
return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /spawncar [modelid] [color1] [color2]");
}
if(carid < 400 || carid > 611)
return SendClientMessage(playerid, COLOR_GREY, "Wrong vehicle model ID! (400 - 600))!");
if(color1 < 0 || color1 > 300 || color2 < 0 || color2 > 300)
return SendClientMessage(playerid, COLOR_GREY, "Wrong color ID! (0 - 300)");
GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
veh = CreateVehicle(carid, CarToX, CarToY, CarToZ, 90, color1, color2, -1);
LinkVehicleToInterior(veh, GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, veh, 0);
return 1;
}
as for destroying the vehicle after you get out, create a global variable...
pawn Code:
new LastVeh[MAX_PLAYERS];
...
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
LastVeh[playerid] = GetPlayerVehicleID(playerid);
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
{
if(LastVeh[playerid] == AdminVehicle[playerid] && GetVehicleModel(AdminVehicle[playerid]) > 0)
{
DestroyVehicle(AdminVehicle[playerid]);
AdminVehicle[playerid] = 0;
LastVeh[playerid] = 0;
}
}
// etc etc
return 1;
}