noahfallon

Simple AFK System v1.1

Aug 31st, 2012
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.85 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.  
  7.     new pName[24]; //Setting up the variables.
  8.     new str[128]; //^^
  9.     new pName2[24]; //^^
  10.     new str2[128]; //^^
  11.     new IsAFK[MAX_PLAYERS]; //^^
  12.  
  13.     public OnFilterScriptInit() //Everything in the brackets below this is called when the Script loads.
  14.     {
  15.             print("\n-----------------------------------------------------------"); //Prints a message on samp-server.exe saying the script has loaded successfully.
  16.             print(" NoahF's Simple AFK System has loaded with no problems.");
  17.             print("-----------------------------------------------------------\n");
  18.             return 1;
  19.     }
  20.     public OnFilterScriptExit() //Everything in the brackets below this is called when the script loads.
  21.     {
  22.             print("\n----------------------------------"); //Prints a message on samp-server.exe saying the script has unloaded successfully.
  23.             print(" NoahF's AFK System has unloaded.");
  24.             print("------------------------------------\n");
  25.             return 1;
  26.     }
  27.    
  28.     public OnPlayerConnect(playerid)
  29.     {
  30.         IsAFK[playerid] = 0; //Makes it so the player is not already AFK on connect.
  31.     }
  32.  
  33.     command(afk, playerid, params[]) //The AFK Command
  34.     {
  35.         if(IsAFK[playerid] == 0) //Checks if the player is not already AFK.
  36.         {
  37.             TogglePlayerControllable(playerid,0); //Makes the player not controllable on the /afk command.
  38.             GetPlayerName(playerid, pName, 24);
  39.             format(str, 128, "%s has gone AFK! (Away from keyboard)", pName); //The message it will send when a player types /afk.
  40.             SendClientMessageToAll(blue, str); //Sends the message to all players
  41.             IsAFK[playerid] = 1; //Tells the system the player is AFK.
  42.         }
  43.         else return SendClientMessage(playerid, blue, "You are already AFK!"); //Sends an error message if the player is already AFK.
  44.         return 1;
  45.     }
  46.  
  47.     command(back, playerid, params[]) //The Back Command
  48.     {
  49.         if(IsAFK[playerid] == 1) //Checks to see if the player is AFK.
  50.         {
  51.             TogglePlayerControllable(playerid,1); //Makes the player controllable on the /back command.
  52.             GetPlayerName(playerid, pName2, 24);
  53.             format(str2, 128, "%s is now back from being AFK!", pName2); //The message it will send when the player types /back.
  54.             SendClientMessageToAll(blue, str2); //Sends the message to all players.
  55.             IsAFK[playerid] = 0; //Tells the system the player is not AFK.
  56.         }
  57.         else return SendClientMessage(playerid, blue, "You aren't AFK!"); //The error message it will send if the player is not already AFK.
  58.         return 1;
  59.     }
  60.  
  61. command(afklist, playerid, params)
  62. {
  63.     new pString[MAX_PLAYER_NAME], pName3[MAX_PLAYER_NAME];
  64.  
  65.     for(new pID = 0; pID < MAX_PLAYERS; pID ++)
  66.     {
  67.     if(IsPlayerConnected(pID))
  68.         {
  69.             if(IsAFK[pID] == 1)
  70.             {
  71.                 SendClientMessage(playerid, 0xFFFFFFFF, "Players currently AFK:");
  72.                 GetPlayerName(playerid, pName3, sizeof(pName3));
  73.                 format(pString, sizeof(pString), "%s", pName3);
  74.                 SendClientMessage(playerid, 0xFFFFFFFF, pString);
  75. }
  76.     }
  77.         }
  78.     return 1;
  79.             }
  80. /*
  81. ---------------------------------DO NOT REMOVE------------------------------------------
  82. NoahF's AFK system made on 8/25/2012.
  83. Please don't remove these credits!
  84. Feel free to post constructive criticism on this forum post so I can improve the script! Thanks, NoahF.
  85. ---------------------------------END OF CREDITS-----------------------------------------
  86. */
Advertisement
Add Comment
Please, Sign In to add comment