#9

PHP код:
// TOP OF SCRIPT
#include <a_samp>
#include <zcmd>
new killtimer[MAX_PLAYERS], bool:IsAfk[MAX_PLAYERS];
//ADD THESE LINES INTO YOUR PUBLICS
public OnPlayerText(playeridtext[])
{
    if(
IsAfk[playerid] == true)
    {
        
IsAfk[playerid] = false;
        new 
str[180], pname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(strsizeof(str), "%s has backed from afk."pname);
        
SendClientMessageToAll(-1str);
        
TogglePlayerControllable(playerid1);
    }
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if(
IsAfk[playerid] == true)
    {
        
IsAfk[playerid] = false;
        new 
str[180], pname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(strsizeof(str), "%s has backed from afk."pname);
        
SendClientMessageToAll(-1str);
        
TogglePlayerControllable(playerid1);
    }
    return 
1;
}
//ADD THOSE LINES AT THE LAST OF YOUR SCRIPT
CMD:back(playerid)
{
    if(
IsAfk[playerid] == false) return SendClientMessage(playerid, -1"ERROR:You arn't afk.");
    
IsAfk[playerid] = false;
    new 
str[180], pname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(strsizeof(str), "%s has backed from afk."pname);
    
SendClientMessageToAll(-1str);
    
TogglePlayerControllable(playerid1);
    return 
true;
}
CMD:afk(playerid)
{
    if(
IsAfk[playerid] == true) return SendClientMessage(playerid, -1"ERROR:You are already afk.");
    if(!
IsPlayerAdmin(playerid))
    {
        
killtimer[playerid] = SetTimerEx("IdleKick"6000001"i"playerid);
    }
    
IsAfk[playerid] = true;
    new 
str[180], pname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(strsizeof(str), "%s is afk now."pname);
    
SendClientMessageToAll(-1str);
    
TogglePlayerControllable(playerid0);
    return 
1;    
}
forward IdleKick(playerid);
public 
IdleKick(playerid)
{
    
SetTimerEx("KickPlayer"5000"i"playerid);
    
SendClientMessage(playerid, -1" You have been kicked from the server for being AFK over 10 continous minutes");
    return 
1;
}
forward KickPlayer(playerid);
public 
KickPlayer(playerid)
{
    
Kick(playerid);
    return 
1;

replace LINE:
Код:
if(!IsPlayerAdmin(playerid))
in your admin system.
Reply


Messages In This Thread
AFK - by Jaua10 - 11.07.2018, 12:51
Re: AFK - by Osamakurdi - 11.07.2018, 12:55
Re: AFK - by Jaua10 - 11.07.2018, 12:58
Re: AFK - by Osamakurdi - 11.07.2018, 13:05
Re: AFK - by Osamakurdi - 11.07.2018, 13:12
Re: AFK - by Jaua10 - 11.07.2018, 13:13
Re: AFK - by Osamakurdi - 11.07.2018, 13:15
Re: AFK - by Osamakurdi - 11.07.2018, 13:21
Re: AFK - by Osamakurdi - 11.07.2018, 13:34
Re: AFK - by Jaua10 - 11.07.2018, 13:43

Forum Jump:


Users browsing this thread: 2 Guest(s)