Advertisement
Guest User

AFK

a guest
Oct 27th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.19 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #define COLOR_AFK 0xF0CC00FF
  6. #define COLOR_AFK2 0xE0FFFFAA
  7.  
  8. new AFK[MAX_PLAYERS];
  9. new AFKTimer[MAX_PLAYERS];
  10. new Text:AFKText[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.     print("\n--------------------------------------");
  15.     print(" AFK Script by BlackSA.");
  16.     print("--------------------------------------\n");
  17.     return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.     return 1;
  23. }
  24.  
  25. public OnPlayerConnect(playerid)
  26. {
  27.     AFK[playerid] = 0;
  28.     AFKTimer[playerid] = 0;
  29.     return 1;
  30. }
  31.  
  32. public OnPlayerText(playerid, text[])
  33. {
  34.     new string[128];
  35.     new name[MAX_PLAYER_NAME];
  36.     GetPlayerName(playerid, name, sizeof(name));
  37.     if(AFK[playerid])
  38.     {
  39.         format(string, sizeof(string), "[AFK Chat] %s says: %s", name, text);
  40.         AfkC(COLOR_AFK, string);
  41.         return 0;
  42.     }
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerCommandText(playerid, cmdtext[])
  47. {
  48.     new string[128];
  49.     new playername[MAX_PLAYER_NAME];
  50.     if (strcmp("/afk", cmdtext, true, 10) == 0)
  51.     {
  52.         TextDrawHideForPlayer(playerid, AFKText[playerid]);
  53.         AFKText[playerid] = TextDrawCreate(150.0, 150.0, "~r~-AFK, To get out of AFK: ~w~/AFK-");
  54.         TextDrawUseBox(AFKText[playerid], 0);
  55.         TextDrawFont(AFKText[playerid], 2);
  56.         GetPlayerName(playerid, playername, sizeof(playername));
  57.         if(AFK[playerid] == 0)
  58.         {
  59.             format(string, sizeof(string), "SERVER: %s is now on AFK mode!", playername);
  60.             SendClientMessageToAll(COLOR_AFK, string);
  61.             TogglePlayerControllable(playerid, 0);
  62.             SetTimerEx("AFKTime", 30000, false, "i", 1337);
  63.             SetPlayerCameraPos(playerid, -833.5241,-1358.8575,86.9054);
  64.             SetPlayerCameraLookAt(playerid, -833.5241,-1358.8575,0);
  65.             TextDrawShowForPlayer(playerid, AFKText[playerid]);
  66.             AFK[playerid] = 1;
  67.             AFKTimer[playerid] = 1;
  68.         }
  69.         else
  70.         {
  71.             if(AFKTimer[playerid]) return SendClientMessage(playerid, COLOR_AFK2, "SERVER: You must wait 30 seconds before exit AFK mode.");
  72.             format(string, sizeof(string), "SERVER: %s is now off AFK mode!", playername);
  73.             SendClientMessageToAll(COLOR_AFK, string);
  74.             TogglePlayerControllable(playerid, 1);
  75.             SetCameraBehindPlayer(playerid);
  76.             AFK[playerid] = 0;
  77.             AFKTimer[playerid] = 0;
  78.         }
  79.         return 1;
  80.     }
  81.     if(strcmp("/afklist", cmdtext, true, 10) == 0)
  82.     {
  83.         for(new i = 0; i<MAX_PLAYERS; i++)
  84.         {
  85.             if(IsPlayerConnected(i))
  86.             {
  87.                 if(AFK[i])
  88.                 {
  89.                     SendClientMessage(playerid, COLOR_AFK2, "SERVER: AFK List: ");
  90.                     GetPlayerName(i, playername, sizeof(playername));
  91.                     format(string, sizeof(string), "  %s are on AFK mode.", playername);
  92.                     SendClientMessage(playerid, COLOR_AFK, string);
  93.                 }
  94.                 else
  95.                 {
  96.                     SendClientMessage(playerid, COLOR_AFK2, "SERVER: There is no peoples are in AFK mode right now.");
  97.                 }
  98.             }
  99.         }
  100.         return 1;
  101.     }
  102.     return 0;
  103. }
  104.  
  105. forward AFKTime();
  106. public AFKTime()
  107. {
  108.     for(new i = 0; i<MAX_PLAYERS; i++)
  109.     {
  110.         if(AFKTimer[i])
  111.         {
  112.             AFKTimer[i] = 0;
  113.         }
  114.     }
  115.     return 1;
  116. }
  117.  
  118. forward AfkC(color, const string[]);
  119. public AfkC(color, const string[])
  120. {
  121.     for(new i = 0; i<MAX_PLAYERS; i++)
  122.     {
  123.         if(AFK[i])
  124.         {
  125.             SendClientMessage(i, color, string);
  126.             TextDrawHideForPlayer(i, AFKText[i]);
  127.         }
  128.     }
  129.     return 1;
  130. }
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement