OnPlayerExitVehicle Help
#1

Hello, I v searched about many functions which destroy player vehicle when they leave his car by setting an timer but i wondered that if you set a timer it's will lag the server if you dont kill it how to get function which kill the timer or reduce lags iv already this in my script:

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetTimerEx("DesVeh", 6000, 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 SetVehicleToRespawn(vehid);
}
Reply
#2

You don't need to kill non-repeating timer. It will be called just once, when given time passes
Reply
#3

Quote:
Originally Posted by Scottas
Посмотреть сообщение
You don't need to kill non-repeating timer. It will be called just once, when given time passes
Thanks but the function which i gived is makes loop for all the players can i make it for 1 player?
Reply
#4

Why u use the loop?
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetTimerEx("DesVeh", 6000, 0, "i", vehicleid);
    return 1;
}

forward DesVeh(vehid);
public DesVeh(vehid)
{
    SetVehicleToRespawn(vehid);
}
Reply
#5

Quote:
Originally Posted by Syncro
Посмотреть сообщение
Why u use the loop?
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetTimerEx("DesVeh", 6000, 0, "i", vehicleid);
    return 1;
}

forward DesVeh(vehid);
public DesVeh(vehid)
{
    SetVehicleToRespawn(vehid);
}
He's using it so that if any player is in vehicle, it doesn't get respawned so removing that can make a flaw.

Quote:
Originally Posted by MahdiGames
Посмотреть сообщение
Thanks but the function which i gived is makes loop for all the players can i make it for 1 player?
Making it for 1 player is the wrong way to go since basically you can't tell who's in vehicle without looping through MAX_PLAYERS and making the checks. Stop worrying! Your code is all good, if you notice something in performence while running it then come here and make a report otherwise it's all nice!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)