How do I make it wait for 3 seconds?
#1

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;
}
Reply
#2

Use a timer is my advice. https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

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?
Reply
#4

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.
Reply
#5

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
Reply
#6

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.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)