Destroy car when player leaves it
#4

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.
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;
}
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...
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;
}
may need some fine tuning
Reply


Messages In This Thread
Destroy car when player leaves it - by Scenario - 16.10.2010, 01:17
Re: Destroy car when player leaves it - by Austin - 16.10.2010, 01:20
Re: Destroy car when player leaves it - by Austin - 16.10.2010, 01:22
Re: Destroy car when player leaves it - by Rachael - 16.10.2010, 02:16
Re: Destroy car when player leaves it - by Scenario - 16.10.2010, 02:18
Re: Destroy car when player leaves it - by Rachael - 16.10.2010, 02:28
Re: Destroy car when player leaves it - by Scenario - 16.10.2010, 14:24

Forum Jump:


Users browsing this thread: 1 Guest(s)