OnPlayerTab?
#1

How could I do it?
Reply
#2

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

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

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

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

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);
Reply
#7

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

Search for an include by Emmet, onPlayerPause. It has IsPlayerPaused
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)