Flying time 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: Flying time help? (
/showthread.php?tid=650180)
Flying time help? -
Biro - 22.02.2018
Hi, me and my team are working on one CnR script and to get straight to the point, im interested in how to make for example. how many hours did player fly? Like we have team army and I want to make a function when player enters a hydra he gets message he doesn't have enough fying time or it can be called skill to fly it (example 30mins needed) and to track that everytime he is in plane, but just in plane and flying... so I don't want to player just enters plane go for a lunch come back and fly hydra if you understand what I'm trying to say
..
Re: Flying time help? -
DobbysGamertag - 22.02.2018
Yeah don't do what DeMoo posted. Bad idea. OnPlayerUpdate(); is called 30 times a second. Its pointless checking this way.
As for what you want;
You might want to do it via a one second timer, looping through all players and checking if they're in a plane, and if they're actually moving and then increment some variable.
Re: Flying time help? -
DeMoo - 22.02.2018
PHP код:
new OneSecTime;
new Float:ZPos[MAX_PLAYERS];
stock IsAPlane(carid){switch(GetVehicleModel(carid)){case 592,577,511,512,593,520,553,476,519,460,513,548,417,487,488,497,563,447,469:return true;}return false;}
public OnGameModeInit()
{
OneSecTime = SetTimer("OneSec", 1000,1);
return 1;
}
forward OneSec();
public OneSec()
{
foreach(new i : Player)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(i, x, y, z);
ZPos[i] = z;
if(IsAPlane(GetPlayerVehicleID(i) && ZPos[i] > 30) // Change ZPos as you want
{
// Your Time Script
}
}
}