01.05.2010, 14:03
First of all, you're creating a vehicle from a local variable, which means it can't be destroyed from a function out of that command, except when you use SetTimerEx.
After you created the vehicle you set a timer which was gonna destroy it, but how do you stop it
That's wrong, because what would happen if just one player has the vehicle, then it will be destroyed 500 times - 1 (haha).
THE FIX:
After you created the vehicle you set a timer which was gonna destroy it, but how do you stop it

pawn Код:
if(GetPlayerVehicleID(i) != iVehicleID) DestroyVehicle(iVehicleID);
THE FIX:
pawn Код:
new MyVehicle[MAX_PLAYERS];
new MyVehTimer[MAX_PLAYERS];
pawn Код:
dcmd_veh(playerid, params[])
{
// all your stuff to check and w/e
MyVehicle[playerid] = CreateVehicle(a, b, c, d, e, f, whatever);
MyVehTime[playerid] = SetTimerEx("DestroyVehicleEx", 1000, true, "i", playerid);
return 1;
}
pawn Код:
forward DestroyVehicleEx(playerid);
public DestroyVehicleEx(playerid)
{
static
timewithoutit;
new
doyouhave;
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(GetPlayerVehicle(i) == MyVehicle[playerid])
{
doyouhave ++;
break;
}
}
if(doyouhave < 1)
{
timewithoutit ++;
if(timewithoutit > 49)
{
DestroyVehicle(MyVehicle[playerid]);
KillTimer(MyVehTimer[playerid]);
}
}
else timewithoutit = 0;
return 1;
}

