Advertisement
SevenSlash

7Slash's AFK + PM System

Jan 2nd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.30 KB | None | 0 0
  1. /*
  2.  
  3. ** ---------- Away From Keyboard (AFK) + Private Message (PM) System ----------- **
  4. ** -----------              Author : SevenSlash                    ------------- **
  5. ** ----------------------------------------------------------------------------- **
  6. **
  7.  
  8. ** ==> PM System ==>
  9. 1) /pm
  10. 2) /disablepms
  11. 3) /enablepms
  12. 4) /ignore
  13. 5) /unignore
  14.  
  15. ** ==> AFK System ==>
  16. 1) /afk
  17. 2) /back
  18. 3) /afklist
  19. */
  20.  
  21.  
  22.  
  23.  
  24. #include <a_samp>
  25. #include <sscanf2>
  26. #include <zcmd>
  27.  
  28. new isAFK[MAX_PLAYERS];
  29. new isDisabled[MAX_PLAYERS];
  30. new ignored[MAX_PLAYERS];
  31.  
  32. stock GetName (playerid)
  33. {
  34.     new pName[MAX_PLAYER_NAME];
  35.     GetPlayerName( playerid, pName, sizeof(pName) );
  36.     return pName;
  37. }
  38.  
  39. public OnFilterScriptInit()
  40. {
  41.     print("\n::-> 7Slash AFK + PM System loaded.\n");
  42.     return 1;
  43. }
  44.  
  45.  
  46. public OnPlayerConnect(playerid)
  47. {
  48.     isAFK[playerid] = 0;
  49.     isDisabled[playerid] = 0;
  50.     ignored[playerid] = 0;
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerDisconnect(playerid, reason)
  55. {
  56.     isAFK[playerid] = 0;
  57.     isDisabled[playerid] = 0;
  58.     ignored[playerid] = 0;
  59.     return 1;
  60. }
  61.  
  62. CMD:afk (playerid, params[])
  63. {
  64.     new str[128], str2[128];
  65.     if ( isAFK[playerid] == 1 ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}You are already in AFK mode! Type {E6EBB9}/back {CFE5E8}to deactivate AFK mode!" );
  66.     TogglePlayerControllable(playerid, 0);
  67.     format( str, sizeof(str), "{B8F279}-AFK- {F7F265}%s(%d) is now Away From Keyboard (AFK)!", GetName( playerid ), playerid );
  68.     format( str2, sizeof(str2), "~g~%s[%d] ~w~is AFK", GetName(playerid), playerid );
  69.     GameTextForAll( str2, 2500, 1 );
  70.     SendClientMessageToAll( -1, str );
  71.     isAFK[playerid] = 1;
  72.     return 1;
  73. }
  74.  
  75. CMD:back (playerid, params[])
  76. {
  77.     new str[128], str2[128];
  78.     if ( isAFK[playerid] == 0 ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}You are not in AFK mode! Type {E6EBB9}/afk {CFE5E8}to activate AFK mode!" );
  79.     TogglePlayerControllable(playerid, 1);
  80.     format( str, sizeof(str), "{B8F279}-AFK- {F7F265}%s(%d) is now back in game!", GetName( playerid ), playerid );
  81.     format( str2, sizeof(str2), "~g~%s[%d] ~w~is BACK", GetName(playerid), playerid );
  82.     GameTextForAll( str2, 2500, 1 );
  83.     SendClientMessageToAll( -1, str );
  84.     isAFK[playerid] = 0;
  85.     return 1;
  86. }
  87.  
  88. CMD:pm ( playerid, params[] )
  89. {
  90.     new str1[128], msg[128], str2[128], str3[128], giveid;
  91.     if ( sscanf(params, "us[128]", giveid, msg)) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /pm <ID> <Text>" );
  92.     else if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
  93.     else
  94.     format( str1, sizeof(str1), "{F7F265}PM sent to %s(%d): {ACE2E6}%s", GetName( playerid ), playerid, msg );
  95.     format( str2, sizeof(str2), "{F7F265}PM received from %s(%d): {ACE2E6}%s", GetName( giveid ), giveid, msg );
  96.     if (isDisabled[giveid] == 1)
  97.     {
  98.         format( str3, sizeof(str3), "{FC1C1C}ERROR: {CFE5E8}%s(%d) has PMs disabled!", GetName(giveid), giveid );
  99.         SendClientMessage( playerid, -1, str3 );
  100.         return 1;
  101.     }
  102.     if (ignored[giveid] == 1)
  103.     {
  104.         format( str3, sizeof(str3), "{FC1C1C}ERROR: {CFE5E8}%s(%d) has chosen not to receive your PMs!", GetName(giveid), giveid );
  105.         SendClientMessage( playerid, -1, str3 );
  106.         return 1;
  107.     }
  108.     GameTextForPlayer( giveid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM received!", 3000, 3 );
  109.     GameTextForPlayer( playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM sent!", 3000, 3 );
  110.     SendClientMessage( playerid, -1, str1 );
  111.     SendClientMessage( giveid, -1, str2 );
  112.     return 1;
  113. }
  114.  
  115. CMD:disablepms ( playerid )
  116. {
  117.     isDisabled[playerid] = 1;
  118.     SendClientMessage( playerid, -1, "{F7F265}You will no longer receive PMs from other players!" );
  119.     return 1;
  120. }
  121.  
  122. CMD:enablepms ( playerid )
  123. {
  124.     isDisabled[playerid] = 0;
  125.     SendClientMessage( playerid, -1, "{11ED65}You will now receive PMs from other players!" );
  126.     return 1;
  127. }
  128.  
  129. CMD:ignore ( playerid, params[] )
  130. {
  131.     new giveid, str[126];
  132.     if ( sscanf(params, "u", giveid )) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /ignore <ID>" );
  133.     if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
  134.     else
  135.     ignored[giveid] = 1;
  136.     format( str, sizeof(str), "{FC1C1C}You have ignored %s(%d) and you will no longer receive PMs from this player!", GetName( giveid ), giveid );
  137.     SendClientMessage( playerid, -1, str );
  138.     return 1;
  139. }
  140.        
  141. CMD:unignore ( playerid, params[] )
  142. {
  143.     new giveid, str[126];
  144.     if ( sscanf(params, "u", giveid )) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /unignore <ID>" );
  145.     if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
  146.     else
  147.     ignored[giveid] = 0;
  148.     format( str, sizeof(str), "{11ED65}You have un-ignored %s(%d)!", GetName( giveid ), giveid );
  149.     SendClientMessage( playerid, -1, str );
  150.     return 1;
  151. }
  152.  
  153. CMD:afklist ( playerid, params[] )
  154. {
  155.     new str[128];
  156.     for (new i = 0; i < MAX_PLAYERS; i++)
  157.     {
  158.         if (IsPlayerConnected(i))
  159.         {
  160.             if (isAFK[i] == 1)
  161.             {
  162.                 format( str, sizeof(str), "{F75A05}** Away From Keyboard (AFK) Players:\n{F07F1D}%s(%d)\r\n", GetName(i), i );
  163.                 ShowPlayerDialog( playerid, 0, DIALOG_STYLE_MSGBOX, "{FF0000}AFK List", str, "OK", "" );
  164.             }
  165.             else
  166.             {
  167.                 SendClientMessage( playerid, -1, "{CFE5E8}No players are Away From Keyboard (AFK)." );
  168.             }
  169.         }
  170.     }
  171.     return 1;
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement