02.02.2013, 10:54
if a player drive a car and come on the road and /q the game and i want if no one touch this car so after 10mins the car auto respawn where i added spawn places on my script. so any idea?
public OnPlayerDisconnect(playerid, reason)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetTimerEx("QuitDestroy", 600000, false, "i", GetPlayerVehicleID(playerid));
}
return 1;
}
forward QuitDestroy(vehicleid);
public QuitDestroy(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVehicleID(i) != vehicleid)
{
DestroyVehicle(vehicleid);
}
}
}
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetTimerEx("QuitDestroy", 600000, false, "i", GetPlayerVehicleID(playerid));
}
return 1;
}
forward QuitDestroy(vehicleid);
public QuitDestroy(vehicleid)
{
new Inveh = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) {continue;}
if(!IsPlayerInAnyVehicle(i)) {continue;}
if(GetPlayerVehicleID(i) == vehicleid)
{
Inveh = 1;
}
}
if(Inveh == 0) SetVehicleToRespawn(vehicleid);
}