Advertisement
Janchuks

[v1] Afk System

Jan 24th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.56 KB | None | 0 0
  1. // ______ _                 _                   ______
  2. //| ___ \ |               | |                 |___  /
  3. //| |_/ / |__   __ _ _ __ | |_ ___  _ __ ___     / /
  4. //|  __/| '_ \ / _` | '_ \| __/ _ \| '_ ` _ \   / /
  5. //| |   | | | | (_| | | | | || (_) | | | | | |./ /___
  6. //\_|   |_| |_|\__,_|_| |_|\__\___/|_| |_| |_|\_____/
  7.  
  8. #include a_samp
  9. #define COLOR_RED   0xFF0000FF
  10. #define COLOR_GREEN 0x008000FF
  11. #define COLOR_BLUE  0x0000FFFF
  12. #define COLOR_ORANGE    0xFF8000FF
  13. new AFK[MAX_PLAYERS];
  14. new Float:OldHealth;
  15.  
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     print("\nAfk System: Loading");
  20.     print("Afk System: Loaded");
  21.     print("Afk System Made by: PhantomZ\n");
  22.     return 1;
  23. }
  24.  
  25.  
  26.  
  27. public OnPlayerText(playerid, text[])
  28. {
  29.     if(AFK[playerid] ==1)
  30.     {
  31.         SendClientMessage(playerid,COLOR_RED,"You're AFK. You Can't talk");
  32.         return 0;
  33. }
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerCommandText(playerid, cmdtext[])
  38. {
  39.     if (strcmp("/AFK", cmdtext, true, 10) == 0)
  40.     {
  41.         if(AFK[playerid] == 1)
  42.         {
  43.         return SendClientMessage(playerid,COLOR_RED,"You're already AFK");
  44.         }
  45.         new string[128];
  46.         new PNAME[MAX_PLAYER_NAME];
  47.         new vehicleid;
  48.         vehicleid = GetPlayerVehicleID(playerid);
  49.         AFK[playerid] = 1;
  50.         SetPlayerHealth(playerid,999999999);
  51.         SetVehicleHealth(vehicleid,9999999999);
  52.         GetPlayerHealth(playerid,OldHealth);
  53.         GetVehicleHealth(vehicleid,OldHealth);
  54.         SendClientMessage(playerid,COLOR_RED,"You're now AFK");
  55.         GetPlayerName(playerid, PNAME, MAX_PLAYERS);
  56.         format(string, sizeof(string), "%s Is now AFK", PNAME);
  57.         SendClientMessageToAll(COLOR_BLUE,string);
  58.         TogglePlayerControllable(playerid,0);
  59.         return 1;
  60.     }
  61.  
  62.     if (strcmp("/Back", cmdtext, true, 10) == 0)
  63.     {
  64.         if(AFK[playerid] == 0)
  65.         {
  66.         return SendClientMessage(playerid,COLOR_RED,"You're not AFK, can'y use this command");
  67.         }
  68.         new string[128];
  69.         new PNAME[MAX_PLAYER_NAME];
  70.         AFK[playerid] = 0;
  71.         new vehicleid;
  72.         vehicleid = GetPlayerVehicleID(playerid);
  73.         SetPlayerHealth(playerid,OldHealth);
  74.         SetVehicleHealth(vehicleid,OldHealth);
  75.         SendClientMessage(playerid,COLOR_GREEN,"You're not AFK");
  76.         GetPlayerName(playerid, PNAME, MAX_PLAYERS);
  77.         format(string, sizeof(string), "%s is back from AFK", PNAME);
  78.         SendClientMessageToAll(COLOR_ORANGE,string);
  79.         TogglePlayerControllable(playerid,1);
  80.         return 1;
  81.     }
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement