Guest User

AAS 1.0 by Harry :)

a guest
Jan 21st, 2013
1,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.49 KB | None | 0 0
  1. /*
  2. I'm not a bad person so feel free to do whatever
  3. you want with my first release on sa-mp forums. edit it
  4. or copy&paste it to your gamemode.
  5.  
  6.  
  7.  
  8. Harry :) Presents
  9.  
  10. Advanced
  11.         ______      ________
  12.         |    |      |           |  /
  13.         |----|      |____       |/
  14.         |    |      |           |\
  15.         |    |      |           | \    System
  16. */
  17.  
  18.  
  19. #define FILTERSCRIPT
  20.  
  21. #include <a_samp>
  22. #include <sscanf2>
  23. #include <foreach>
  24. #include <YSI\y_timers>
  25.  
  26. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  27.  
  28. #define MAX_AFK_TIME            30 //in Minutes!
  29. #define LABEL_DRAW_DISTANCE     50.0
  30.  
  31. new Text3D:AFKLabel[MAX_PLAYERS];
  32. new playerupdate[MAX_PLAYERS];
  33.  
  34. public OnFilterScriptInit()
  35. {
  36.     print("\nAdvanced Away-From-Keyboard 1.0 Filterscript by 'Harry :)' loaded.\n");
  37.     for(new playerid; playerid < MAX_PLAYERS; playerid++)
  38.     {
  39.         AFKLabel[playerid] = Create3DTextLabel(" ",0x000000,0.0,0.0,0.0,LABEL_DRAW_DISTANCE,0,1);
  40.     }
  41.     return 1;
  42. }
  43.  
  44. stock CheckPausing(playerid)
  45. {
  46.    if(GetTickCount() > ( GetPVarInt(playerid,"LastUpdate") + 3000 ) && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER)
  47.    {
  48.       return 1;
  49.    }
  50.    return 0;
  51. }
  52.  
  53. public OnPlayerConnect(playerid)
  54. {
  55.     Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 1.0);
  56.     return 1;
  57. }
  58.  
  59. task PerPlayerTimer[1000]()
  60. {
  61.     foreach(Player,i)
  62.     {
  63.         AFKUpdate(i);
  64.     }
  65. }
  66.  
  67. AFKUpdate(playerid)
  68. {
  69.     new string[128];
  70.     if(GetTickCount() > (GetPVarInt(playerid,"LastUpdate") + 1000) && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER)
  71.     {
  72.         playerupdate[playerid]++;
  73.         if(playerupdate[playerid] > 60)
  74.         {
  75.             new mins,secs;
  76.             mins = playerupdate[playerid] / 60;
  77.             secs = playerupdate[playerid] - (mins * 60);
  78.             if(mins == 1) format(string,sizeof(string),"Away From Keyboard \nfor\n%d minute and %d seconds",mins,secs);
  79.             else format(string,sizeof(string),"Away From Keyboard \nfor\n%d minutes and %d seconds",mins,secs);
  80.         }
  81.         else format(string,sizeof(string),"Away From Keyboard \nfor\n%d seconds",playerupdate[playerid]);
  82.         Update3DTextLabelText(AFKLabel[playerid], 0x00CDFFFF, string);
  83.     }
  84.     else if(playerupdate[playerid] >= MAX_AFK_TIME*60)
  85.     {
  86.         new Name[MAX_PLAYER_NAME];
  87.         GetPlayerName(playerid,Name,sizeof(Name));
  88.         format(string,sizeof(string),"[AAS] %s has been kicked from the server. [Paused for %d Minutes]",Name,MAX_AFK_TIME);
  89.         SendClientMessageToAll(0xFF00FFFF,string);
  90.         Kick(playerid);
  91.     }
  92.     else
  93.     {
  94.         Update3DTextLabelText(AFKLabel[playerid],0x00000000," ");
  95.     }
  96. }
  97.  
  98. public OnPlayerUpdate(playerid)
  99. {
  100.     SetPVarInt(playerid,"LastUpdate",GetTickCount());
  101.     playerupdate[playerid] = 0;
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerCommandText(playerid,cmdtext[])
  106. {
  107.     dcmd(afklist,7,cmdtext);
  108.     dcmd(afkcheck,8,cmdtext);
  109.     return 1;
  110. }
  111.  
  112. dcmd_afklist(playerid,params[])
  113. {
  114.     #pragma unused params
  115.     new string[128],variable[960],afk;
  116.     foreach(Player,i)
  117.     {
  118.         if(CheckPausing(i) == 1)
  119.         {
  120.             new Name[MAX_PLAYER_NAME];
  121.             GetPlayerName(i,Name,sizeof(Name));
  122.             format(string,sizeof(string),"\n• %s",Name);
  123.             strcat(variable,string);
  124.             afk++;
  125.         }
  126.     }
  127.     if(afk == 0) return SendClientMessage(playerid,0xFF00FFFF,"Nobody's AFK at the moment!");
  128.     if(afk == 1)
  129.     {
  130.         format(string,sizeof(string),"%d Player is AFK",afk);
  131.     }
  132.     if(afk > 1)
  133.     {
  134.         format(string,sizeof(string),"%d Players are AFK",afk);
  135.     }
  136.     ShowPlayerDialog(playerid,1503,DIALOG_STYLE_MSGBOX,string,variable,"Got it!","");
  137.     return 1;
  138. }
  139.  
  140. dcmd_afkcheck(playerid,params[])
  141. {
  142.     new id,Name[MAX_PLAYER_NAME],string[128];
  143.     if(sscanf(params,"i",id)) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /afkcheck ID");
  144.     GetPlayerName(id,Name,sizeof(Name));
  145.     if(CheckPausing(id) == 0)
  146.     {
  147.         format(string,sizeof(string),"%s {37D900}is not {FFBE00}A{37D900}way {FFBE00}F{37D900}rom his {FFBE00}K{37D900}eyboard",Name);
  148.         SendClientMessage(playerid,0xFFBE00FF,string);
  149.     }
  150.     else if(CheckPausing(id) == 1)
  151.     {
  152.         format(string,sizeof(string),"%s {D70000}is {FFBE00}A{D70000}way {FFBE00}F{D70000}rom his {FFBE00}K{D70000}eyboard,Name");
  153.         SendClientMessage(playerid,0xFFBE00FF,string);
  154.     }
  155.     return 1;
  156. }
  157. public OnFilterScriptExit()
  158. {
  159.     foreach(Player,i)
  160.     {
  161.         Delete3DTextLabel(AFKLabel[i]);
  162.     }
  163.     print("/nAdvanced Away-From-Keyboard v1.0 by 'Harry :)' unloaded.");
  164.     return 1;
  165. }
  166.  
  167.  
  168. //Hey, You just used my script,
  169. //but here's my website
  170. //so visit it maybe?
  171.  
  172. //www.bfsamp.net
Advertisement
Add Comment
Please, Sign In to add comment