Advertisement
Guest User

Automatic AFK system(Anti-Pause)

a guest
Feb 24th, 2013
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.25 KB | None | 0 0
  1. /*Automatic AFK system(anti pause system) by JewelL*/
  2. #include <a_samp>
  3. #include <foreach>
  4. #include <streamer>
  5. #include <zcmd>
  6. new IsPaused[MAX_PLAYERS], pTick[MAX_PLAYERS], IsPunished[MAX_PLAYERS],Text3D:pauseLaber[MAX_PLAYERS],pKilled[MAX_PLAYERS],pTimer;
  7. forward CheckPlayer();
  8. public OnFilterScriptInit()
  9. {
  10.     print("Anti pause system loaded");
  11.     pTimer = SetTimer("CheckPlayer", 1000, 1);
  12.     return 1;
  13. }
  14.  
  15. public OnFilterScriptExit()
  16. {
  17.     print("Anti pause system unloaded");
  18.     KillTimer(pTimer);
  19.     foreach(Player, i)
  20.     if(IsPlayerConnected(i) && IsPaused[i] == 1)
  21.     DestroyDynamic3DTextLabel(pauseLaber[i]);
  22.     return 1;
  23. }
  24. public OnPlayerConnect(playerid)
  25. {
  26.     SetPVarInt(playerid, "spawned", 0);
  27.     return 1;
  28. }
  29. public OnPlayerRequestClass(playerid, classid)
  30. {
  31.     SetPVarInt(playerid, "spawned", 0);
  32.     return 1;
  33. }
  34. public OnPlayerDeath(playerid, killerid, reason)
  35. {
  36.     SetPVarInt(playerid, "spawned", 0);
  37. }
  38. public OnPlayerSpawn(playerid)
  39. {
  40.     SetPVarInt(playerid, "spawned", 1);
  41.     return 1;
  42. }
  43. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
  44. {
  45.     if(IsPaused[damagedid] == 1 && damagedid != INVALID_PLAYER_ID && GetPlayerTeam(playerid) != GetPlayerTeam(damagedid) && amount > 5 && pKilled[damagedid]== 0){
  46.     pKilled[damagedid]=1;
  47.     SendDeathMessage( playerid,damagedid, weaponid);
  48.     SetPlayerScore(playerid,GetPlayerScore(playerid)+1); //Remove this you aren't using a score system
  49.     SetPlayerVirtualWorld(damagedid,107);
  50.     SpawnPlayer(damagedid);
  51.     }
  52.     return 1;
  53. }
  54. public OnPlayerUpdate(playerid)
  55. {
  56.     pTick[playerid] = GetTickCount();
  57.     return 1;
  58. }
  59. public CheckPlayer()
  60. {
  61.     foreach(Player, i){
  62.         if(!IsPlayerConnected(i)) continue;
  63.         if(GetTickCount() - pTick[i] > 1500 ){
  64.             if(IsPaused[i] == 0 && GetPVarInt(i, "spawned") == 1){
  65.             pauseLaber[i] = CreateDynamic3DTextLabel("AFK, i'm pausing", 0xFB0404C8, 0, 0, 0, 25, i,INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
  66.             IsPaused[i] = 1;
  67.             pKilled[i]=0;
  68.             }
  69.         }
  70.         else{
  71.             if(IsPaused[i] == 1) DestroyDynamic3DTextLabel(pauseLaber[i]);
  72.             if(IsPunished[i] == 1) SetPlayerVirtualWorld(i,GetPVarInt(i, "world"));
  73.             IsPaused[i] = 0;
  74.             IsPunished[i] = 0;
  75.         }
  76.         if(GetTickCount() - pTick[i] > 8000 && GetPVarInt(i, "spawned") == 1){
  77.             if(IsPunished[i] == 0){
  78.             IsPunished[i] = 1;
  79.             SetPVarInt(i, "world", GetPlayerVirtualWorld(i));
  80.             SetPlayerVirtualWorld(i,107);
  81.             }
  82.         }
  83.     }
  84.     return 1;
  85. }
  86. CMD:pausers(playerid)
  87. {
  88. return cmd_afklist(playerid);
  89. }
  90. CMD:afklist(playerid)
  91. {
  92.     new count=0;
  93.     new string[256],temp[50],Name[MAX_PLAYER_NAME];
  94.     strcat(string, "{33FF00}");
  95.     foreach(Player, i){
  96.        if (IsPlayerConnected(i)){
  97.           if(IsPaused[i] == 1){
  98.               GetPlayerName(i,Name,sizeof(Name));
  99.               format(temp, 60, "%s(Id:%i)\n",Name,i);
  100.               strcat(string, temp);
  101.               count++;
  102.           }
  103.        }
  104.     }
  105.     format(temp, 60, "{00FFE6}AFK players, count: %d",count);
  106.     if (count > 0)ShowPlayerDialog(playerid,3221,DIALOG_STYLE_MSGBOX,temp,string ,"OK","");
  107.     else ShowPlayerDialog(playerid,3222,DIALOG_STYLE_MSGBOX,"{00FFE6}AFK Players","{FF0000}none is afk" ,"OK","");
  108.     return 1;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement