SA-MP Forums Archive
OnPlayerExitVehicle Help - 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: OnPlayerExitVehicle Help (/showthread.php?tid=490972)



OnPlayerExitVehicle Help - MahdiGames - 28.01.2014

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);
}



Re: OnPlayerExitVehicle Help - Scottas - 28.01.2014

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


Re: OnPlayerExitVehicle Help - MahdiGames - 28.01.2014

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?


Re: OnPlayerExitVehicle Help - Syncro - 28.01.2014

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);
}



Re: OnPlayerExitVehicle Help - [KHK]Khalid - 28.01.2014

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!