nbdyson

Unstick by Nicker

Mar 23rd, 2015
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.88 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define RANGE 0.5 //The range in which players will be detected as "stuck"
  4.  
  5. stock UnstickPlayer(playerid)
  6. {
  7.     new Float:x, Float:y, Float:z;
  8.     new Float:x2, Float:y2, Float:z2;
  9.    
  10.     for(new i = 0; i < MAX_PLAYERS; i++)
  11.     {
  12.         if(IsPlayerConnected(i) && GetPVarInt(i, "pSpawned") == 1 && i != playerid)
  13.         {
  14.             GetPlayerPos(i, x, y, z);
  15.         }
  16.        
  17.         if(IsPlayerInRangeOfPoint(playerid, RANGE, x, y, z))
  18.         {
  19.             GetPlayerPos(playerid, x2, y2, z2);
  20.             SetPlayerPos(playerid, x2+2.0, y2+2.0, z2);
  21.         }
  22.     }
  23.    
  24.     return 1;
  25. }
  26.  
  27. main()
  28. {
  29. }
  30.  
  31. public OnPlayerDeath(playerid, killerid, reason)
  32. {
  33.     SetPVarInt(playerid, "pSpawned", 0);
  34.    
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerSpawn(playerid)
  39. {
  40.     SetPVarInt(playerid, "pSpawned", 1);
  41.    
  42.     SetTimerEx("Unstick", 500, false, "i", playerid);
  43.    
  44.     return 1;
  45. }
  46.  
  47. forward Unstick(playerid);
  48. public Unstick(playerid)
  49. {
  50.     UnstickPlayer(playerid);
  51.    
  52.     return 1;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment