HaPeace

fAFK (Unique - With Reason - AFK List - Disable Chat)

Feb 18th, 2013
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.66 KB | None | 0 0
  1. // Fizz AFK (Unique - With Reason - Disable Chat)
  2. //-----------------------------------------------------------------
  3. // Thank's to Zeex
  4. // Thank's to KoczkaHUN for the AFK List
  5. // Thank's to Falcon, Rajat, Rafael, and Misiur
  6. // Thank's to Krisna as a Tester
  7. //---------------------------Feature-------------------------------
  8. // - AFK List
  9. // - Disable Chat when AFK
  10. // - AFK Reason
  11. // - 3DTextLabel above the player with Reason
  12. //-----------------------------------------------------------------
  13.  
  14. #include <a_samp>
  15. #include <zcmd>
  16. #include <foreach>
  17. #include <sscanf2>
  18.  
  19. #define COLOR_WHITE 0xFFFFFFFF
  20. #define COLOR_GREEN 0x33AA33AA
  21. #define COLOR_GRAD2 0xBFC0C2FF
  22. #define C_WHITE   "{FFFFFF}"
  23. #define C_GREEN   "{1FD925}"
  24.  
  25. new str[64],
  26.     IsPlayerAFK[MAX_PLAYERS],
  27.     Text3D:Label[MAX_PLAYERS],
  28.     AFK_Reason[MAX_PLAYERS];
  29.    
  30. main()
  31. {
  32.         print("\n----------------------------------");
  33.         print(" Fizz AFK by ProPoint a.k.a HaPeace ");
  34.         print("----------------------------------\n");
  35. }
  36.  
  37. public OnPlayerText(playerid, text[])
  38. {
  39.     if(IsPlayerAFK[playerid] == 1)
  40.     {
  41.         SendClientMessage(playerid, COLOR_GRAD2, "You are now AFK, you can't speak, use /back !");
  42.         return 0;
  43.     }
  44.     return 1;
  45. }
  46.  
  47. public OnPlayerConnect(playerid)
  48. {
  49.     IsPlayerAFK[playerid] = 0;
  50.     return 1;
  51. }
  52.  
  53. public OnPlayerDisconnect(playerid)
  54. {
  55.     if(IsPlayerAFK[playerid] == 1)
  56.     {
  57.         Delete3DTextLabel(Label[playerid]);
  58.         IsPlayerAFK[playerid] = 0;
  59.     }
  60.     return 1;
  61. }
  62.  
  63. PlayerName(playerid)
  64. {
  65.     new pName[24];
  66.     GetPlayerName(playerid, pName,24);
  67.     return pName;
  68. }
  69.  
  70. CMD:afk(playerid, params[])
  71. {
  72.     if(IsPlayerAFK[playerid] == 0)
  73.     {
  74.         new reason[64];
  75.         new strtext[64];
  76.         if(sscanf(params,"s[64]", reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afk [reason]");
  77.         IsPlayerAFK[playerid] = 1;
  78.         format(str, sizeof(str), "[ %s ] is now AFK, Reason : %s", PlayerName(playerid), reason);
  79.         SendClientMessageToAll(COLOR_WHITE, str);
  80.         format(AFK_Reason[playerid],64,"%s", reason);
  81.         format(strtext, sizeof(strtext), ""C_GREEN"Player is AFK\n"C_WHITE"Reason: %s", reason);
  82.         Label[playerid] = Create3DTextLabel(strtext,COLOR_WHITE,30.0,40.0,50.0,40.0,0);
  83.         Attach3DTextLabelToPlayer(Label[playerid], playerid, 0.0, 0.0, 0.3);
  84.         GameTextForPlayer (playerid, "~w~You are now AFK, type ~b~/back when you come back", 3000, 5);
  85.         TogglePlayerControllable(playerid, 0);
  86.     }
  87.     else if(IsPlayerAFK[playerid] == 1)
  88.     {
  89.         SendClientMessage(playerid, COLOR_WHITE, "You are alredy AFK.");
  90.     }
  91.     return 1;
  92. }
  93. CMD:back(playerid, params[])
  94. {
  95.     if(IsPlayerAFK[playerid] == 1)
  96.     {
  97.         IsPlayerAFK[playerid] = 0;
  98.         format(str, sizeof(str), "[ %s ] is no longer AFK", PlayerName(playerid));
  99.         SendClientMessageToAll(COLOR_WHITE, str);
  100.         Delete3DTextLabel(Text3D:Label[playerid]);
  101.         GameTextForPlayer (playerid, "~w~Welcome Back", 3000, 5);
  102.         TogglePlayerControllable(playerid, 1);
  103.     }
  104.     else if(IsPlayerAFK[playerid] == 0)
  105.     {
  106.         SendClientMessage(playerid, COLOR_WHITE, "You are not AFK.");
  107.     }
  108.     return 1;
  109. }
  110.  
  111. CMD:afklist(playerid,params[])
  112. {
  113.     new count = 0, string[2500], pName[MAX_PLAYER_NAME];
  114.  
  115.     for(new i = 0; i < MAX_PLAYERS; i++)
  116.     {
  117.         if (GetPlayerName(i, pName,sizeof(pName)))
  118.         {
  119.             if(IsPlayerAFK[i] == 1)
  120.             {
  121.                 format(string, sizeof(string), "%sPlayer: {99EE22}%s, {992233}ID: {99DDDD}%d\n",
  122.                 string, pName, i);
  123.                 count++;
  124.             }
  125.         }
  126.     }
  127.     if (count == 0)
  128.     {
  129.         SendClientMessage(playerid, COLOR_GRAD2, "No one AFK!");
  130.  
  131.     }
  132.     else ShowPlayerDialog(playerid,837,DIALOG_STYLE_LIST,"AFK PLAYERS:",string,"OK","Cancel");
  133.     return 1;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment