Advertisement
Kartik_Sharma

SAMP basic AFK system

Jul 13th, 2012
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.47 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6.  
  7. //UPDATE_TIME is the time interval to check if player is paused or not.
  8. #define UPDATE_TIME 2000
  9.  
  10. //PauseTimerr is timer for each player.
  11. new PauseTimer[MAX_PLAYERS];
  12.  
  13. //To check if player was paused earlier .
  14. new bool:Paused[MAX_PLAYERS];
  15.  
  16. //This is your 3D Text Label
  17. new Text3D:PauseText[MAX_PLAYERS];
  18.  
  19. main()
  20. {
  21.     return 1;
  22. }
  23. public OnGameModeInit()
  24. {
  25.     // Don't use these lines if it's a filterscript
  26.     SetGameModeText("Blank Script");
  27.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  28.     return 1;
  29. }
  30.  
  31.  
  32. public OnPlayerRequestClass(playerid, classid)
  33. {
  34.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  35.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  36.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerDeath(playerid, killerid, reason)
  41. {
  42.     KillTimer(PauseTimer[playerid]);
  43.     return 1;
  44. }
  45. public OnPlayerSpawn(playerid)
  46. {
  47.     PauseTimer[playerid] = SetTimerEx("Pause_Check",UPDATE_TIME,true,"i",playerid);
  48.     //When a player spawn we start a timer which repeats itself after UPDATE_TIME (2000 ms)
  49.     return 1;
  50. }
  51.  
  52. forward Pause_Check(playerid);
  53.  
  54. public Pause_Check(playerid)
  55. {
  56.     new Float:x,Float:y,Float:z,Float:a;//Get Player Location and facing Angle.
  57.     GetPlayerPos(playerid,x,y,z);
  58.     GetPlayerFacingAngle(playerid,a);
  59.     //If player's location is same as it was before UPDATE_TIME (2000 ms)
  60.     if(x == GetPVarFloat(playerid,"x") && y == GetPVarFloat(playerid,"y") && z == GetPVarFloat(playerid,"z") && a == GetPVarFloat(playerid,"a"))
  61.     {
  62.         if (Paused[playerid] == false)//If he was not paused before 2 sec
  63.         {
  64.             //Create a 3D Text label .
  65.             PauseText[playerid] = Create3DTextLabel("Paused", -1, x, y,z+1.5,100, GetPlayerVirtualWorld(playerid), 0);
  66.         }
  67.         //We now know he have paused.
  68.         //This will take sure that we do not create multiple 3D text labels.
  69.         Paused[playerid] = true;
  70.     }
  71.     //If he have moved/updated
  72.     else
  73.     {
  74.         if (Paused[playerid] == true)//If he was paused before 2 sec.
  75.         {
  76.             Delete3DTextLabel(PauseText[playerid]);//We will delete the Label we created when he paused.
  77.         }
  78.         //And make him un pause.
  79.         Paused[playerid] = false;
  80.     }
  81.  
  82.     //Setting Player varibles.
  83.     SetPVarFloat(playerid,"x",x);
  84.     SetPVarFloat(playerid,"y",y);
  85.     SetPVarFloat(playerid,"z",z);
  86.     SetPVarFloat(playerid,"a",a);
  87.     return 1;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement