OnPlayerTab? - 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: OnPlayerTab? (
/showthread.php?tid=606083)
OnPlayerTab? -
Lirbo - 29.04.2016
How could I do it?
Re: OnPlayerTab? -
Lordzy - 29.04.2016
OnPlayerUpdate won't get called when the player is paused (either tabbed / paused). There are also includes released which helps to know whether a player is paused or not. Try searching for - "OnPlayerPause".
EDIT : I'm confused whether you're asking to detect if player is pressing TAB button or in case if player's pausing the game. Be more descriptive.
Re: OnPlayerTab? -
Lirbo - 30.04.2016
Quote:
Originally Posted by Lordzy
OnPlayerUpdate won't get called when the player is paused (either tabbed / paused). There are also includes released which helps to know whether a player is paused or not. Try searching for - "OnPlayerPause".
EDIT : I'm confused whether you're asking to detect if player is pressing TAB button or in case if player's pausing the game. Be more descriptive.
|
so how i'm supposed to do that?
PHP код:
if(return 0)
{
// Script?
}
Btw there's other ways to check that instead of OnPlayerUpdate? for example with a normal timer? OnPlayerUpdate might lag.
Re: OnPlayerTab? -
Lordzy - 30.04.2016
No, it will not cause any lag. That's a false opinion by most of the users but the fact is that it's a callback that's called very frequently and having excessive amounts of code can cause lag. OnPlayerUpdate being used for necessary things should not cause any lag.
Re: OnPlayerTab? -
Lirbo - 30.04.2016
Quote:
Originally Posted by Lordzy
No, it will not cause any lag. That's a false opinion by most of the users but the fact is that it's a callback that's called very frequently and having excessive amounts of code can cause lag. OnPlayerUpdate being used for necessary things should not cause any lag.
|
I see, anyway could you explain me how i can do it properly? in addition i'd like to add it seconds (how long he's afk) so i'll have to use a timer anyway.
Re: OnPlayerTab? -
Lordzy - 30.04.2016
This is my old AutoAFK include which was never released. I wrote it a long time ago and it can be a lot optimized.
https://github.com/Lordzy/AutoAFK/bl...er/AutoAFK.inc
You don't have to use a timer to know how long a player is AFK. Just store the time when player goes AFK, then compare it with the current time and you can know how long the player's been AFK. The following code is taken from my unreleased AFK filterscript :
pawn Код:
//Here [e_PlayerLastUpdate] is the tickcount taken right before player goes afk.
temp_Tick = GetTickCount();
temp_Seconds = (temp_Tick - g_PlayerAFKData[i][e_PlayerLastUpdate]) / 1000;
temp_Mins = temp_Seconds / 60;
temp_Seconds -= temp_Mins * 60;
format(temp_dString, sizeof(temp_dString), "%s\n\
%s (ID:%d) is AFK since %d minutes, %d seconds.",
temp_dString, temp_Name, i, temp_Mins, temp_Seconds);
Re: OnPlayerTab? -
Lirbo - 30.04.2016
Quote:
Originally Posted by Lordzy
This is my old AutoAFK include which was never released. I wrote it a long time ago and it can be a lot optimized. https://github.com/Lordzy/AutoAFK/bl...er/AutoAFK.inc
You don't have to use a timer to know how long a player is AFK. Just store the time when player goes AFK, then compare it with the current time and you can know how long the player's been AFK. The following code is taken from my unreleased AFK filterscript :
pawn Код:
//Here [e_PlayerLastUpdate] is the tickcount taken right before player goes afk. temp_Tick = GetTickCount(); temp_Seconds = (temp_Tick - g_PlayerAFKData[i][e_PlayerLastUpdate]) / 1000; temp_Mins = temp_Seconds / 60; temp_Seconds -= temp_Mins * 60; format(temp_dString, sizeof(temp_dString), "%s\n\ %s (ID:%d) is AFK since %d minutes, %d seconds.", temp_dString, temp_Name, i, temp_Mins, temp_Seconds);
|
bro xD i dont wanna sound retard ok but i didnt understand shit from that.
let's say I just want to detect if the player is afk or not, how can i do it, leave the rest to me
Re: OnPlayerTab? -
Ritzy2K - 30.04.2016
Search for an include by Emmet, onPlayerPause. It has IsPlayerPaused
Re: OnPlayerTab? -
Lordzy - 30.04.2016
If you're using the one I linked, this should do it:
pawn Код:
#include <a_samp>
#include <AutoAFK>
public OnPlayerPause(playerid) {
printf("PlayerID : %d has paused.", playerid);
return 1;
}
public OnPlayerResume(playerid) {
printf("Player ID : %d is now back!", playerid);
return 1;
}
//To check if player is paused:
IsPlayerPaused(playerid);