Advertisement
YiinY

afk_fs

May 27th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new afk[2][MAX_PLAYERS];
  4. new Float:sPos[MAX_PLAYERS][3];
  5.  
  6. new timer;
  7.  
  8. public OnFileScriptInit()
  9. {
  10. timer = SetTimer("afk_check", 5000, true);
  11. return 1;
  12. }
  13.  
  14. public OnFileScriptExit()
  15. {
  16. KillTimer(timer);
  17. return 1;
  18. }
  19.  
  20. forward afk_check();
  21. public afk_check()
  22. {
  23. foreach(new i : Player)
  24. {
  25. if(!afk[0][i] && afk[1][i])
  26. {
  27. afk[0][i] = 1;
  28. OnPlayerAFK(i, 1);
  29.  
  30. } else if(afk[0][i] && !afk[1][i]) {
  31.  
  32. afk[0][i] = 0;
  33. OnPlayerAfk(i, 0);
  34. }
  35. }
  36. return 1;
  37. }
  38.  
  39. public OnPlayerUpdate(playerid)
  40. {
  41. afk[1][playerid] = 0;
  42. return 1;
  43. }
  44.  
  45. OnPlayerAFK(playerid, isafk)
  46. {
  47. if(isafk)
  48. {
  49. // nuejo i afk
  50. GetPlayerPos(playerid, sPos[playerid][0], sPos[playerid][1], sPos[playerid][2]); // išsaugom coords
  51. SetPlayerPos(playerid, 3000, 3000, 0);
  52.  
  53. } else {
  54.  
  55. // gryzo is afk
  56. SetPlayerPos(playerid, sPos[playerid][0], sPos[playerid][1], sPos[playerid][2]); // gražinam į prieš tai buvusią poziciją.
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement