repsawn car - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: repsawn car (
/showthread.php?tid=412536)
repsawn car -
pelani - 02.02.2013
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?
Re: repsawn car -
iGetty - 02.02.2013
Use
pawn Код:
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);
}
}
}
}
Should work, just tested it and it did for me.
Re: repsawn car -
Jewell - 02.02.2013
^ SetVehicleToRespawn(vehicleid);
Re: repsawn car -
pelani - 02.02.2013
thanx to getty but getty this is just destroy codes and i want the car respawn again? and jewell explain more please.
Re: repsawn car -
pelani - 02.02.2013
nothing work getty i put timer on 1mins and i /q my game and login again after 1 mins and still car have
Re: repsawn car -
Jewell - 02.02.2013
actually, iGetty's code great but it has a little mistake, atfer 10 min it will destroy every other vehicles which has a driver.. xD
make a little changes
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetTimerEx("QuitDestroy", 600000, false, "i", GetPlayerVehicleID(playerid));
}
return 1;
}
I'm not sure this code works or not, i couldn't test it, let's have a try
pawn Код:
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);
}
Re: repsawn car -
pelani - 02.02.2013
thanx let me check.