alot of vehicles how to clear -
MahdiGames - 16.01.2014
I'v a problem the cars in my server when player spawn it is removed when he exit from car , but when i back after a few hours i see that many cars spawned , so i think when player leave his car is stay iv this code
Код:
//DestroyVehicle
public OnPlayerExitVehicle(playerid,vehicleid)
{
SetTimerEx("DestroyVehicle",10000,false,"i",vehicleid);
return 1;
}
forward DestroyVehicle(vehicleid);
public DestroyVehicle(vehicleid)
{
for(new i; i < MAX_PLAYERS; ++i)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return SetVehicleToRespawn(vehicleid); //DestroyVehicle(vehicleid);
}
I think i must put
Код:
SetTimerEx("DestroyVehicle",10000,false,"i",vehicleid);
at OnPlayerDisconnect shall i?
Re: alot of vehicles how to clear -
Aliassassin123456 - 16.01.2014
........
Very bad code .... but np try this:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("DesVeh", 10000, 0, "i", vehicleid);
return 1;
}
forward DesVeh(vehid);
public DesVeh(vehid)
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehid)) return 1;
}
}
return DestroyVehicle(vehid);
}
Re: alot of vehicles how to clear -
MahdiGames - 16.01.2014
Quote:
Originally Posted by Aliassassin123456
........
Very bad code .... but np try this:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { SetTimerEx("DesVeh", 10000, 0, "i", vehicleid); return 1; }
forward DesVeh(vehid); public DesVeh(vehid) { for(new i;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i)) { if(IsPlayerInVehicle(i, vehid)) return 1; } } return DestroyVehicle(vehid); }
|
is there are difference between my code? because my problem is that even the above code working but still many cars , thanks!
Re: alot of vehicles how to clear -
Aliassassin123456 - 16.01.2014
tell me what do you need? Destroy vehicle after 10 sec ? Restart vehicle after 10 sec?
Re: alot of vehicles how to clear -
Threshold - 16.01.2014
There is a parameter for this in AddStaticVehicleEx...
Код:
AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay)
If you want the vehicle to respawn after 10 seconds:
pawn Код:
AddStaticVehicleEx(modelid, 1000.0, 1000.0, 1000.0, 180.0, 0, 0, 10); //The last parameter is for the respawn delay after the vehicle no longer has a vehicle. Change this to whatever value you want in seconds.
Quote:
Originally Posted by SA-MP Wiki
respawn_delay The delay until the car is respawned without a driver, in seconds.
pawn Код:
public OnGameModeInit() { // Add a Hydra to the game that will respawn 15 seconds after being left AddStaticVehicleEx ( 520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 15 ); return 1; }
|
Re: alot of vehicles how to clear -
MahdiGames - 16.01.2014
Thanks i fixed:
OnPlayerDisconnect:
Код:
//Car Destroy for the player
new vehid;
vehid = GetPlayerVehicleID(playerid);
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehid)) return 1;
}
else DestroyVehicle(vehid);
}