#include <a_samp> // We Need This Include
#include <zcmd> // We Need This Include
#include <sscanf2> // We Need This Include
new IsAfk[MAX_PLAYERS]; // Global Variable
// This CallBack Work When Player Connect
public OnPlayerConnect(playerid)
{ // Opening Bracket
IsAfk[playerid] = 0; // To Set This To 0
return 1;
} // Closing Bracket
// This CallBack Work When Player Disconnect
public OnPlayerDisconnect(playerid, reason)
{ // Opening Bracket
IsAfk[playerid] = 0; // To Set This To 0
return 1;
} // Closing Bracket
// We Will Gonna Make A AFK Command
CMD:afk(playerid,params[])
{ // Opening Bracket
new string[128], pName[MAX_PLAYER_NAME]; // Variables
if(IsAfk[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF,"You Are Already AFK"); // To Check When Player Is Already AFK
TogglePlayerControllable(playerid, 0); // To Freeze The Player
format(string,sizeof(string),"Server: %s Is Now Afk", pName); // will format a message
SendClientMessageToAll(0xFFFF00,string); // Will Send A Public Message To All
SendClientMessage(playerid, 0xFF00FFFF,"Type /back if you want to continue"); // Will Send A Message
IsAfk[playerid] = 1; // To Set This To 1
return 1;
} // Closing Bracket
// We Will Gonna Make A BACK Command
CMD:back(playerid,params[])
{ // Opening Bracket
new string[128], pName[MAX_PLAYER_NAME]; // Variables
if(IsAfk[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF,"You Are Not AFK"); // To Check When Player is Not AFK
TogglePlayerControllable(playerid, 1); // Unfreeze The Player
format(string,sizeof(string),"Server: %s Is Back!", pName); // will format a message
SendClientMessageToAll(0xFFFF00,string); // To Send A Public Message To All
IsAfk[playerid] = 0; // To Set This To 0
return 1;
} // Closing Bracket
The command is kind of useless, it just freezes you and tells everyone that you are AFK. Maybe give the player godmode or teleport him to save place and when he comes back restore his stuff. Also, you didn't use sscanf once even though you said that it's needed.
|