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



AFKTIME - Zeus666 - 30.09.2018

PHP код:
CMD:afktime(playerid,params[])
{
        new 
targetid,string[128];
        if(
sscanf(params"ui",targetid)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /afktime [playerid]");
        
format(string,sizeof(string),""COL_RED"%s is afk for %s seconds.",PlayerName(targetid), Afktime);
        
SendClientMessage(playerid,-1,string);
    }
    else {
        
SendClientMessage(playerid,-1,""COL_RED"ERROR: This player is not afk!");
    }
    return 
1;

How can I make this work?


Re: AFKTIME - UFF - 30.09.2018

Use your variable to set in afk and not in afk. I take my own variable as InAFK.

Код:
new bool:InAFK[MAX_PLAYERS]; // my variable for example 

CMD:afktime(playerid,params[]) 
{ 
        new targetid,string[128]; 
        if(sscanf(params, "u",targetid)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /afktime [playerid]"); 
         if(InAFK[targetid] == false) return SendClientMessage(playerid,-1,""COL_RED"ERROR: This player is not afk!");
        format(string,sizeof(string),""COL_RED"%s is afk for %s seconds.",PlayerName(targetid), Afktime); 
        SendClientMessage(playerid,-1,string); 
    } 
    return 1; 
}



Re: AFKTIME - Zeus666 - 30.09.2018

Do I need some public for "seeing" if player is afk or not? Because AFKTIME it's not definied


Re: AFKTIME - UFF - 30.09.2018

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
Do I need some public for "seeing" if player is afk or not?
Yeah, you need to use a variable for the player to set whether he/she is in AFK or not.


Re: AFKTIME - Zeus666 - 30.09.2018

Quote:
Originally Posted by UFF
Посмотреть сообщение
Yeah, you need to use a variable for the player to set whether he/she is in AFK or not.
And that variable I can find it in em_callbacks as

IsPlayerPaused(playerid)

?

/

OnPlayerPause