DeWilX

Simple AFK System [0.3]

Apr 27th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.67 KB | None | 0 0
  1. /* Simple AFK System by DeWilX */
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6.  
  7. #define COLOR_YELLOW 0xFFFF00AA
  8. #define COLOR_RED 0xFF0000FF
  9.  
  10. new gPlayers[MAX_PLAYERS][MAX_PLAYER_NAME+1];
  11. new hp = 9999999;
  12. new Float:phealth[MAX_PLAYERS];
  13. new IsPlayerAfk[MAX_PLAYERS];
  14. new afk[MAX_PLAYERS];
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print(" DeWilX's Simple AFK System -- Loaded");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerConnect(playerid)
  25. {
  26.     IsPlayerAfk[playerid] = 0;
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerDisconnect(playerid, reason)
  31. {
  32.     IsPlayerAfk[playerid] = 0;
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. if (strcmp("/afk", cmdtext, true, 10) == 0)
  39. {
  40.     new string[33];
  41.     IsPlayerAfk[playerid] = 1;
  42.     GetPlayerName(playerid,gPlayers[playerid],MAX_PLAYER_NAME);
  43.     GetPlayerHealth(playerid,phealth[playerid]);
  44.     SetPlayerHealth(playerid,hp);
  45.     TogglePlayerControllable(playerid, 0);
  46.     format(string,sizeof(string),"<<<[%s] is afk!>>>",gPlayers[playerid]);
  47.     SendClientMessageToAll(COLOR_RED,string);
  48.     if(afk[playerid] == 1){
  49.     SendClientMessage(playerid,COLOR_RED,"ERROR: You already are afk!");
  50.     }
  51. }
  52. if (strcmp("/back", cmdtext, true, 10) == 0)
  53. {
  54.     new string[33];
  55.     IsPlayerAfk[playerid] = 0;
  56.     TogglePlayerControllable(playerid, 1);
  57.     SetPlayerHealth(playerid,phealth[playerid]);
  58.     format(string,sizeof(string),"<<<[%s] is back!>>>",gPlayers[playerid]);
  59.     SendClientMessageToAll(COLOR_YELLOW,string);
  60.     if(afk[playerid] == 0){
  61.     SendClientMessage(playerid,COLOR_RED,"ERROR: You are not afk!");
  62.     }
  63.     return 1;
  64. }
  65. return 1;
  66. }
Add Comment
Please, Sign In to add comment