How to make a AFK System (with back, and with strcmp)
#1

So first we need to know that public OnPlayerCommandText like everyone knows that there are the commands

Do this:

AFK:

Код:
if(strcmp(cmdtext, "/afk", true) == 0)
	{
		TogglePlayerControllable(playerid, 0);
		new string [128];
		new pName[MAX_PLAYER_NAME];
    	       GetPlayerName(playerid, pName, sizeof(pName));
    	       format(string,sizeof string,"%s is afk now (Away From Keyboard).",pName);
    	       SendClientMessageToAll(green, string);
    	       return 1;
    }
BACK:

Код:
if(strcmp(cmdtext, "/back", true) == 0)
    {
   		new string [128];
		new pName[MAX_PLAYER_NAME];
    	        GetPlayerName(playerid, pName, sizeof(pName));
    	        format(string,sizeof string,"%s is back now (Back To KeyBoard).",pName);
    	        SendClientMessageToAll(lightblue, string);
                TogglePlayerControllable(playerid, 1);
		return 1;
	}
There you go it's done :P
Reply
#2

Quote:
Originally Posted by bestr32
Посмотреть сообщение
So first we need to know that public OnPlayerCommandText like everyone knows that there are the commands

Do this:

AFK:

Код:
if(strcmp(cmdtext, "/afk", true) == 0)
	{
		TogglePlayerControllable(playerid, 0);
		new string [128];
		new pName[MAX_PLAYER_NAME];
    	       GetPlayerName(playerid, pName, sizeof(pName));
    	       format(string,sizeof string,"%s is afk now (Away From Keyboard).",pName);
    	       SendClientMessageToAll(green, string);
    	       return 1;
    }
BACK:

Код:
if(strcmp(cmdtext, "/back", true) == 0)
    {
   		new string [128];
		new pName[MAX_PLAYER_NAME];
    	        GetPlayerName(playerid, pName, sizeof(pName));
    	        format(string,sizeof string,"%s is back now (Back To KeyBoard).",pName);
    	        SendClientMessageToAll(lightblue, string);
                TogglePlayerControllable(playerid, 1);
		return 1;
	}
There you go it's done :P
Wrong section.
This should be posted in here:

http://forum.sa-mp.com/forumdisplay.php?f=70
Reply
#3

Wrong section, should be in tutorials. Also you are not explaining everything, this is just a "copy this paste there" tutorial. Please improve or delete.

Also, you did not define the color "lightblue" so n00bs will come up with all kinds of errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)