Advertisement
Guest User

S-AFK by Simo0000

a guest
Jul 13th, 2015
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.82 KB | None | 0 0
  1. /*--S-AFK system created by simo0000--*/
  2.  
  3. #include            <a_samp>
  4. #include            <ZCMD>
  5. #include            <sscanf2>
  6. #include            <foreach>
  7. #include            <YSI\y_timers>
  8.  
  9. #pragma tabsize 0
  10.  
  11. new AFKTime[MAX_PLAYERS];
  12. new Text3D:AFKLabel[MAX_PLAYERS];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     print("\n--------------------------------------");
  17.     print("S-AFK system by simo0000 is loaded.");
  18.     print("--------------------------------------\n");
  19.     return 1;
  20. }
  21.  
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     SetPVarInt(playerid, "AFK", 0);
  26.     AFKTime[playerid] = 0;
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerDisconnect(playerid, reason)
  31. {
  32.     SetPVarInt(playerid, "AFK", 0);
  33.     AFKTime[playerid] = 0;
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerText(playerid,text[])
  38. {
  39.   if(GetPVarInt(playerid, "AFK") == 1) return  SendClientMessage(playerid, 0xAA3333AA, "You cannot talk while you are in AFK MODE."), 0;
  40.   return 1;
  41. }
  42.  
  43. stock GetName(playerid)
  44. {
  45.     new name[24];
  46.     GetPlayerName(playerid, name, sizeof(name));
  47.     return name;
  48. }
  49.  
  50. task AfkTimer[1000]()
  51. {
  52.    foreach(new i: Player)
  53.       {
  54.          if(GetPVarInt(i, "AFK") == 1)
  55.          {
  56.          AFKTime[i]++;
  57.          }
  58.       }
  59.  
  60.     return 1;
  61. }
  62.  
  63.  
  64. CMD:afklist(playerid)
  65. {
  66.     new
  67.         AFKCount = 0, String[1024];
  68.         SendClientMessage(playerid, 0x33CCFFAA, "|      AFK List        |");
  69.         foreach(new i: Player)
  70.         {
  71.             if(GetPVarInt(i, "AFK") == 1)
  72.             {
  73.                 format(String, sizeof(String), "%s >> AFK (%d secondes)", GetName(i), AFKTime[i]);
  74.                 SendClientMessage(playerid, -1, String);
  75.                 AFKCount++;
  76.             }
  77.         }
  78.         if(AFKCount == 0) return SendClientMessage(playerid, -1, "There is no players AFK.");
  79.     return 1;
  80. }
  81.  
  82. CMD:afk(playerid)
  83. {
  84.    new string[128];
  85.    if(GetPVarInt(playerid, "AFK") == 1) return SendClientMessage(playerid, 0xAA3333AA, "You are already AFK");
  86.    SendClientMessage(playerid, 0x33CCFFAA, "You are now AFK, You can't move or talk.!");
  87.    TogglePlayerControllable(playerid,0);
  88.    SetPVarInt(playerid, "AFK", 1);
  89.    AFKLabel[playerid] = Create3DTextLabel("[Away from keyboard]",0xFF9900AA,30.0,40.0,50.0,40.0,0);
  90.    Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 0.7);
  91.  
  92.    format(string, sizeof(string), "%s is now Away from the keyboard!", GetName(playerid));
  93.    SendClientMessageToAll(0xFFFF00AA, string);
  94.    return 1;
  95. }
  96.  
  97. CMD:back(playerid)
  98. {
  99.    new string[128];
  100.    if(GetPVarInt(playerid, "AFK") == 0) return SendClientMessage(playerid, 0xAA3333AA, "You are not AFK");
  101.    SendClientMessage(playerid, 0x33CCFFAA, "You are now back from AFK, Welcome back!");
  102.    TogglePlayerControllable(playerid,1);
  103.    SetPVarInt(playerid, "AFK", 0);
  104.    AFKTime[playerid] = 0;
  105.    format(string, sizeof(string), "%s is now Back!", GetName(playerid));
  106.    SendClientMessageToAll(0xFFFF00AA, string);
  107.    Delete3DTextLabel(Text3D:AFKLabel[playerid]);
  108.    return 1;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement