How do I make it wait for 3 seconds? -
ExtendedCarbon - 08.09.2013
I have a respawn vehicle code set up, but when they exit the vehicle it respawns right away, causing the player to get trapped. I want it to wait for about 3 seconds before respawning the vehicle to give the player enough time to move.
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
return 1;
}
Re: How do I make it wait for 3 seconds? -
Don_Cage - 08.09.2013
Use a timer is my advice.
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: How do I make it wait for 3 seconds? -
ExtendedCarbon - 08.09.2013
Quote:
Originally Posted by Don_Cage
|
I looked through it, but it looks complicated to bend it to what I want to do. Could you provide me with an example?
Re: How do I make it wait for 3 seconds? -
Konstantinos - 08.09.2013
No, it's not!
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("OnPlayerVehicleRespawn", 3000, false, "i", vehicleid);
return 1;
}
forward OnPlayerVehicleRespawn(vehicleid);
public OnPlayerVehicleRespawn(vehicleid)
{
SetVehicleToRespawn(vehicleid);
}
You used a for loop to respawn all the vehicles everytime a player exits the vehicle. It'd be better to respawn the one they exited after 3 seconds. The rest will be respawned by the respawn delay.
Re: How do I make it wait for 3 seconds? -
Jstylezzz - 08.09.2013
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("RespawnCar",3000,0,"i",vehicleid);// Set a 3 second timer
return 1;
}
forward RespawnCar(vehicleid);
public RespawnCar(vehicleid)
{
SetVehicleToRespawn(vehicleid);
return 1;
}
EDIT:
Konstantinos beat me to it ;P
Re: How do I make it wait for 3 seconds? -
ExtendedCarbon - 08.09.2013
Quote:
Originally Posted by Jstylezzz
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { SetTimerEx("RespawnCar",3000,0,"i",vehicleid);// Set a 3 second timer return 1; } forward RespawnCar(vehicleid); public RespawnCar(vehicleid) { SetVehicleToRespawn(vehicleid); return 1; }
EDIT: Konstantinos beat me to it ;P
|
Thank you both! I think I'm getting there.
Re: How do I make it wait for 3 seconds? -
doreto - 08.09.2013
CreateVehicle(modelid, Float: x, Float:y, Float:z, Float:angle, color1, color2,
respawn_delay - The delay until the car is respawned without a driver in seconds);
or
AddStaticVehicleEx(modelid, Float: x, Float:y, Float:z, Float:angle, color1, color2,
respawn_delay - The delay until the car is respawned without a driver in seconds);
When player exit from behicle after x seconds vehicle will be respawned.