#include <a_samp>
#include <a_samp>
new isAFK[MAX_PLAYERS]; // We will edit this soon to tell the server whether a player is AFK or not, this is just a definition before telling so.
#include <a_samp>
new isAFK[MAX_PLAYERS]; // We will edit this soon to tell the server whether a player is AFK or not, this is just a definition before telling so.
new isAFK[MAX_PLAYERS];
new string[128]; // This tells the script my text will be max. 128 bits, you can make it larger or lower for your needs...
#include <a_samp>
new isAFK[MAX_PLAYERS]; // We will edit this soon to tell the server whether a player is AFK or not, this is just a definition before telling so.
new string[128]; // This tells the script my text will be max. 128 bits, you can make it larger or lower for your needs ...
public OnPlayerConnect
isAFK[playerid] = 0; // Setting player's AFK state to 0(false) to avoid bugs
public OnPlayerConnect(blablabla)
{
isAFK[playerid] = 0; // Setting player's AFK state to 0(false) to avoid bugs on their connection period
return 1;
}
public OnPlayerCommandText
if(strcmp("/afk", cmdtext, true, 10) == 0)
{
if(strcmp("/afk", cmdtext, true, 10) == 0)
{
new Name[MAX_PLAYER_NAME]; // Defining the Player's Name
GetPlayerName(playerid, Name, sizeof(Name));
if (isAFK[playerid] == 0) // if the player is NOT AFK
{
isAFK[playerid] = 1; // Turning his state to AFK mode
format( string, sizeof(string), "%s is AFK !", Name); // Formatting the message to be sended
SendClientMessageToAll(yourcolorhere , string); // Sends message to everyone to inform he is AFK, put a color in yourcolorhere part of this code to make it work.
}
else { // if the player is already AFK
isAFK[playerid] = 0; // Turning his state to NO-AFK mode
format( string, sizeof(string), "%s is back!", Name); // Formatting the message to be sended
SendClientMessageToAll(yourcolorhere, string); // Sends message to inform he is back , put a color in yourcolorhere part of this code to make it work.
}
return 1;
}
if(strcmp("/afk", cmdtext, true, 10) == 0)
{
new Name[MAX_PLAYER_NAME]; // Defining the Player's Name
GetPlayerName(playerid, Name, sizeof(Name));
if (isAFK[playerid] == 0) // if the player is NOT AFK
{
isAFK[playerid] = 1; // Turning his state to AFK mode
format( string, sizeof(string), "%s is AFK !", Name); // Formatting the message to be sended
SendClientMessageToAll(yourcolorhere , string); // Sends message to everyone to inform he is AFK, put a color in yourcolorhere part of this code to make it work.
}
else { // if the player is already AFK
isAFK[playerid] = 0; // Turning his state to NO-AFK mode
format( string, sizeof(string), "%s is back!", Name); // Formatting the message to be sended
SendClientMessageToAll(yourcolorhere, string); // Sends message to inform he is back , put a color in yourcolorhere part of this code to make it work.
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/afk", cmdtext, true, 10) == 0)
{
new Name[MAX_PLAYER_NAME]; // Defining the Player's Name
GetPlayerName(playerid, Name, sizeof(Name));
if (isAFK[playerid] == 0) // if the player is NOT AFK
{
isAFK[playerid] = 1; // Turning his state to AFK mode
format( string, sizeof(string), "%s is AFK !", Name); // Formatting the message to be sended
SendClientMessageToAll(-1 , string); // Sends message to everyone to inform he is AFK, put a color in yourcolorhere part of this code to make it work.
}
else { // if the player is already AFK
isAFK[playerid] = 0; // Turning his state to NO-AFK mode
format( string, sizeof(string), "%s is back!", Name); // Formatting the message to be sended
SendClientMessageToAll(-1, string); // Sends message to inform he is back , put a color in yourcolorhere part of this code to make it work.
}
return 1;
}
return 0;
}
pawn Код:
|
The last should be "return 0;".
"/afk" has 4 lenght, not 10. Well, the lenght is option so it's better not to use it at all if it's gonna be incorrect or use it with the correct lenght. |
Totally forgot that, as I use ZCMD all the time :P
Thanks anyways, edited. |
new message[128], bool:AFK[MAX_PLAYERS], name[MAX_PLAYER_NAME];
if(!strcmp(cmdtext, "/AFK", true)) { AFK[playerid] = !AFK[playerid]; SetPlayerVirtualWorld(playerid, AFK[playerid]?playerid+1:0); GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(message, sizeof(message), AFK[playerid]?("%s is AFK!"):("%s isn't AFK"), name); return SendClientMessageToAll(-1, message); }