Guest User

yAFK

a guest
Dec 10th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #define FILTERSCRIPT    \
  2.         By Yiin
  3.  
  4. #include <a_samp>
  5. #define p [playerid]
  6.  
  7. new bool: afk[MAX_PLAYERS];
  8. new afk_skaiciavimas[MAX_PLAYERS];
  9. new t;
  10. new zaidejai;
  11. new Text3D:afk_tekstas[MAX_PLAYERS];
  12. new afklaikas[MAX_PLAYERS];
  13. new bool: spawned[MAX_PLAYERS];
  14.  
  15. PlayerPause(playerid)
  16. {
  17.     afk p = true;
  18.     afklaikas p = GetTickCount();
  19.     new txt[32];
  20.     format(txt, 32, "AFK by Yiin :: %i", ( GetTickCount() - afklaikas p ) / 1000);
  21.     afk_tekstas p = Create3DTextLabel(txt, 0xFF0000FF, 0,0,0,50,-1,1);
  22.     Attach3DTextLabelToPlayer(afk_tekstas p, playerid, 0,0,0.8);
  23.     // Kai nueina į afk.
  24. }
  25.  
  26. PlayerUnPause(playerid)
  27. {
  28.     afk p = false;
  29.     Delete3DTextLabel(afk_tekstas p);
  30.     // Kai gryžta iš afk.
  31. }
  32.  
  33. PlayerAFK(playerid)
  34. {
  35.     new txt[32];
  36.     format(txt, 32, "AFK :: %i", ( GetTickCount() - afklaikas p ) / 1000);
  37.     Update3DTextLabelText(afk_tekstas p, 0xFF0000FF, txt);
  38. }
  39.  
  40. public OnFilterScriptInit()         return print(" ---:: ` AFK ` "), zaidejai = GetMaxPlayers(), t = SetTimer("AFK", 500, 1), 1;
  41. public OnPlayerSpawn(playerid)      return spawned p = true, 1;
  42. public OnFilterScriptExit()         return KillTimer(t);
  43. public OnPlayerConnect(playerid)    return afk_skaiciavimas p = 0, spawned p = false, 1;
  44. public OnPlayerUpdate(playerid)     return afk_skaiciavimas p = 0, 1;
  45.  
  46. forward AFK();
  47. public AFK()
  48.     for(new i = 0; i < zaidejai; i++)
  49.         if(spawned[i])
  50.             if(afk_skaiciavimas[i] > 15 && !afk[i]) PlayerPause(i);
  51.             else if(!afk_skaiciavimas[i] && afk[i])   PlayerUnPause(i);
  52.             else if(afk_skaiciavimas[i] > 15 && afk[i])   PlayerAFK(i);
  53.             else  afk_skaiciavimas[i]++;
Advertisement
Add Comment
Please, Sign In to add comment