Don't like ads? PRO users don't see any ads ;-)
Guest

AFK system

By: a guest on Jul 29th, 2012  |  syntax: PAWN  |  size: 1.64 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //                              Simple afk system by Joker
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <zcmd>
  6.  
  7. #if defined FILTERSCRIPT
  8. #define DRED 0xFF00000
  9. #define WHITE 0xFFFFFFFF
  10. new AFK[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.         print("\n--------------------------------------");
  15.         print(" AFK system by Joker loaded");
  16.         print("--------------------------------------\n");
  17.         return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.         print("\n--------------------------------------");
  23.         print(" AFK system by Joker unloaded");
  24.         print("--------------------------------------\n");
  25.         return 1;
  26. }
  27. public OnPlayerConnect(playerid)
  28. {
  29.         AFK[playerid] = 0;
  30.         return 1;
  31. }
  32. CMD:afk(playerid)
  33. {
  34.         if (AFK[playerid] == 1)
  35.         {
  36.             SendClientMessage(playerid,DRED,"You are already AFK!");
  37.         }
  38.         else
  39.         {
  40.             new string[128];
  41.                 format(string,sizeof(string)," %s is now Away From Keyboard (AFK)",GetPlayerNameEx(playerid));
  42.                 SendClientMessageToAll(WHITE,string);
  43.         TogglePlayerControllable(playerid,0);
  44.         SendClientMessage(playerid,WHITE,"You are now AFK!");
  45.         AFK[playerid] = 1;
  46.         }
  47.         return 1;
  48. }
  49.  
  50. CMD:back(playerid)
  51. {
  52.         if (AFK[playerid] == 0)
  53.         {
  54.             SendClientMessage(playerid,DRED,"You are already back!");
  55.         }
  56.         else
  57.         {
  58.                 new string[128];
  59.                 format(string,sizeof(string)," %s is now back!",GetPlayerNameEx(playerid));
  60.                 SendClientMessageToAll(WHITE,string);
  61.                 TogglePlayerControllable(playerid,1);
  62.                 SendClientMessage(playerid,WHITE,"Welcome back!");
  63.                 AFK[playerid] = 0;
  64.         }
  65.         return 1;
  66. }
  67. stock GetPlayerNameEx(playerid)
  68. {
  69.         new Name[MAX_PLAYER_NAME];
  70.         GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  71.         return Name;
  72. }
  73. #endif