noahfallon

NoahF's Simple AFK System v1.2

Sep 21st, 2012
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.72 KB | None | 0 0
  1. #define FILTERSCRIPT         //MAKE SURE YOU HAVE THESE INCLUDES IN YOUR PAWNO INCLUDES FOLDER
  2. #include <a_samp>            //MAKE SURE YOU HAVE THESE INCLUDES IN YOUR PAWNO INCLUDES FOLDER
  3. #include <zcmd>              //MAKE SURE YOU HAVE THESE INCLUDES IN YOUR PAWNO INCLUDES FOLDER
  4. #define blue 0x0FFDD349      //MAKE SURE YOU HAVE THESE INCLUDES IN YOUR PAWNO INCLUDES FOLDER
  5. #define red 0xAA3333AA       //MAKE SURE YOU HAVE THESE INCLUDES IN YOUR PAWNO INCLUDES FOLDER
  6. #define green 0x00FF00C8
  7. #define EMBED_RED {AA3333}
  8. #define EMBED_BLUE {0FFDD3}
  9. #define EMBED_GREEN {00FF00}
  10.  
  11.     new pName[24]; //Setting up the variables.
  12.     new str[128]; //^^
  13.     new pName2[24]; //^^
  14.     new str2[128]; //^^
  15.     new CantTalk[128];
  16.     new IsAFK[MAX_PLAYERS]; //^^
  17.  
  18. public OnFilterScriptInit() //Everything in the brackets below this is called when the Script loads.
  19. {
  20.     print("\n-----------------------------------------------------------"); //Prints a message on samp-server.exe saying the script has loaded successfully.
  21.     print(" NoahF's Simple AFK System has loaded with no problems.");
  22.     print("-----------------------------------------------------------\n");
  23.     return 1;
  24. }
  25. public OnFilterScriptExit() //Everything in the brackets below this is called when the script loads.
  26. {
  27.     print("\n--------------------------------------------------------"); //Prints a message on samp-server.exe saying the script has unloaded successfully.
  28.     print(" NoahF's AFK System has unloaded without any errors.");
  29.     print("--------------------------------------------------------\n");
  30.     return 1;
  31.  }
  32.  
  33. public OnPlayerConnect(playerid)
  34. {
  35.     IsAFK[playerid] = 0; //Makes it so the player is not already AFK on connect.
  36. }
  37.  
  38.     CMD:afk(playerid, params[]) //The AFK Command
  39.     {
  40.         if(IsAFK[playerid] == 0) //Checks if the player is not already AFK.
  41.         {
  42.             TogglePlayerControllable(playerid,0); //Makes the player not controllable on the /afk command.
  43.             GetPlayerName(playerid, pName, 24);
  44.             format(str, 128, "%s has gone {00FF00}AFK! {0FFDD3}(Away from Keyboard)", pName); //The message it will send when a player types /afk.
  45.             SendClientMessageToAll(blue, str); //Sends the message to all players
  46.             IsAFK[playerid] = 1; //Tells the system the player is AFK.
  47.         }
  48.             else return SendClientMessage(playerid, blue, "You are already AFK!"); //Sends an error message if the player is already AFK.
  49.         return 1;
  50.     }
  51.  
  52.     CMD:back(playerid, params[]) //The Back Command
  53.     {
  54.         if(IsAFK[playerid] == 1) //Checks to see if the player is AFK.
  55.         {
  56.             TogglePlayerControllable(playerid,1); //Makes the player controllable on the /back command.
  57.             GetPlayerName(playerid, pName2, 24);
  58.             format(str2, 128, "%s is now {0FFDD3}back from being {00FF00}AFK!", pName2); //The message it will send when the player types /back.
  59.             SendClientMessageToAll(blue, str2); //Sends the message to all players.
  60.             IsAFK[playerid] = 0; //Tells the system the player is not AFK.
  61.         }
  62.             else return SendClientMessage(playerid, red, "You are not AFK!"); //The error message it will send if the player is not already AFK.
  63.         return 1;
  64.     }
  65.  
  66.     CMD:afklist(playerid, params[])
  67.     {
  68.         new pString[MAX_PLAYER_NAME], pName3[MAX_PLAYER_NAME];
  69.  
  70.         for(new pID = 0; pID < MAX_PLAYERS; pID ++)
  71.         {
  72.             if(IsPlayerConnected(pID))
  73.             {
  74.                 if(IsAFK[pID] == 1)
  75.                 {
  76.                     SendClientMessage(playerid, red, "{0FFDD3}Players Currently {00FF00}AFK:");
  77.                     GetPlayerName(playerid, pName3, sizeof(pName3));
  78.                     format(pString, sizeof(pString), "%s", pName3);
  79.                     SendClientMessage(playerid, red, pString);
  80.     }
  81.         }
  82.             }
  83.         return 1;
  84.                 }
  85.  
  86. public OnPlayerDisconnect(playerid)
  87. {
  88.     IsAFK[playerid] = 0;
  89. }
  90.  
  91. public OnPlayerText(playerid, text[])
  92. {
  93.     if(IsAFK[playerid] == 1)
  94.     format(CantTalk, 128, "You are currently in AFK (Away From Keyboard) Mode. You cannot talk until you type /Back.");
  95.     SendClientMessage(playerid, red, CantTalk);
  96.     return 0;
  97. }
  98.     /*
  99.     ---------------------------------DO NOT REMOVE------------------------------------------
  100.     NoahF's AFK system made on 8/25/2012.
  101.     Please don't remove these credits!
  102.     Feel free to post constructive criticism on this forum post so I can improve the script! Thanks, NoahF.
  103.     ---------------------------------END OF CREDITS-----------------------------------------
  104.     */
  105.     /*CHANGELOG V1.2
  106.         Added some embedded colors.
  107.         Fixed some indentation issues.
  108.         Added so when a player tries to talk, while AFK, they get a message saying they cannot talk, and their message won't be sent.
  109.         Made it so the AFK Variable is set to 0 when the player disconnects.
  110.         Pruned the script.
  111.     */
Advertisement
Add Comment
Please, Sign In to add comment