SA-MP Forums Archive
AFK and Back - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: AFK and Back (/showthread.php?tid=186731)



AFK and Back - Garc1a - 30.10.2010

Can someone make a /afk and /back system and make /afklist to see who is AFK


Re: AFK and Back - Mike_Peterson - 30.10.2010

I've just made /afk and /back but i didnt made /afklist :P


Re: AFK and Back - <Weponz> - 30.10.2010

Код:
//Top of script 

new bool:isafk[MAX_PLAYERS];


//Under OnPlayerCommandText
        if(!strcmp(cmdtext,"/afk",true))
        {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == false)
        {
	        isafk[playerid] = true;
	  		SetPlayerHealth(playerid, 9999);
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s is now AFK.",name);
	        printf(string);
	        SendClientMessage(playerid, 0x0, "Type /back To Stop Being AFK.");
	        SendClientMessageToAll(0x0, string);
	        TogglePlayerControllable(playerid,0);
        }
        else
		{
			SendClientMessage(playerid, 0x0, "You Are Already AFK!");
        }
        return 1;
        }
        if(!strcmp(cmdtext,"/back",true))
        {
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == true)
        {
	        isafk[playerid] = false;
	        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	        format(string, sizeof(string), "%s Is No Longer AFK.",name);
	        SendClientMessageToAll(0x0, string);
	        SetPlayerHealth(playerid, 100);
	       	printf(string);
			TogglePlayerControllable(playerid,1);
		}
		else
		{
  			SendClientMessage(playerid, 0x0, "You Are Not AFK!");
        }
        return 1;
        }