Advertisement
Guest User

Untitled

a guest
May 29th, 2015
2,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_bit>
  3.  
  4. static stock
  5. Float:AC_Position[3],
  6. pLastPosTick[MAX_PLAYERS],
  7. BitArray:AC_SafeTP<MAX_PLAYERS>
  8. ;
  9.  
  10. forward OnPlayerTeleport(playerid, Float:distance);
  11.  
  12. public OnPlayerSpawn(playerid)
  13. {
  14. GetPlayerPos(playerid, AC_Position[0], AC_Position[1], AC_Position[2]);
  15. #if defined pds_OnPlayerSpawn
  16. forward pds_OnPlayerSpawn(playerid), return true;
  17. #endif
  18. }
  19.  
  20. #if defined _ALS_OnPlayerUpdate
  21. #undef OnPlayerSpawn
  22. #else
  23. #define _ALS_OnPlayerSpawn
  24. #endif
  25.  
  26. #define OnPlayerSpawn pds_OnPlayerSpawn
  27.  
  28. #if defined pds_OnPlayerSpawn
  29. forward pds_OnPlayerSpawn(playerid);
  30. #endif
  31.  
  32. public OnPlayerUpdate(playerid)
  33. {
  34. if( gettime( ) - pLastPosTick[ playerid ] > 1) //updates the player location every 2 seconds.
  35. {
  36. //on-foot
  37. if( !IsPlayerInRangeOfPoint(playerid, 50.0, AC_Position[ 0 ], AC_Position[ 1 ], AC_Position[ 2 ]) && !Bit_Get(AC_SafeTP, playerid) && !IsPlayerNPC(playerid)
  38. && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  39. {
  40. CallLocalFunction("OnPlayerTeleport", "if", playerid, GetPlayerDistanceFromPoint(playerid, AC_Position[ 0 ], AC_Position[ 1 ], AC_Position[ 2 ]));
  41. }
  42. //on-vehicle
  43. else if( !IsPlayerInRangeOfPoint(playerid, 300.0, AC_Position[ 0 ], AC_Position[ 1 ], AC_Position[ 2 ]) && !Bit_Get(AC_SafeTP, playerid) && !IsPlayerNPC(playerid)
  44. && GetVehicleSpeed( GetPlayerVehicleID(playerid) ) <= 50 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
  45. {
  46. CallLocalFunction("OnPlayerTeleport", "if", playerid, GetPlayerDistanceFromPoint(playerid, AC_Position[ 0 ], AC_Position[ 1 ], AC_Position[ 2 ]));
  47. }
  48. GetPlayerPos(playerid, AC_Position[ 0 ], AC_Position[ 1 ], AC_Position[ 2 ]);
  49. Bit_Set(AC_SafeTP, playerid, false);
  50. pLastPosTick[ playerid ] = gettime( ) + 2;
  51. }
  52. #if defined pds_OnPlayerUpdate
  53. pds_OnPlayerUpdate(playerid), return true;
  54. #endif
  55. }
  56.  
  57. #if defined _ALS_OnPlayerUpdate
  58. #undef OnPlayerUpdate
  59. #else
  60. #define _ALS_OnPlayerUpdate
  61. #endif
  62.  
  63. #define OnPlayerUpdate pds_OnPlayerUpdate
  64.  
  65. #if defined pds_OnPlayerUpdate
  66. forward pds_OnPlayerUpdate(playerid);
  67. #endif
  68.  
  69. stock pds_SetPlayerPos(playerid, Float:PosX, Float:PosY, Float:PosZ)
  70. {
  71. GetPlayerPos(playerid, AC_Position[0], AC_Position[1], AC_Position[2]);
  72. Bit_Set(AC_SafeTP, playerid, true);
  73. return SetPlayerPos(playerid, PosX, PosY, PosZ);
  74. }
  75.  
  76. #if defined _ALS_SetPlayerPos
  77. #undef SetPlayerPos
  78. #else
  79. #define _ALS_SetPlayerPos
  80. #endif
  81.  
  82. #define SetPlayerPos pds_SetPlayerPos
  83.  
  84. stock pds_SetPlayerPosFindZ(playerid, Float:PosX, Float:PosY, Float:PosZ)
  85. {
  86. GetPlayerPos(playerid, AC_Position[0], AC_Position[1], AC_Position[2]);
  87. Bit_Set(AC_SafeTP, playerid, true);
  88. return SetPlayerPosFindZ(playerid, PosX, PosY, PosZ);
  89. }
  90.  
  91. #if defined _ALS_SetPlayerPosFindZ
  92. #undef SetPlayerPosFindZ
  93. #else
  94. #define _ALS_SetPlayerPosFindZ
  95. #endif
  96.  
  97. #define SetPlayerPosFindZ pds_SetPlayerPosFindZ
  98.  
  99.  
  100. stock pds_PutPlayerInVehicle(playerid, vehicleid, seatid)
  101. {
  102. GetPlayerPos(playerid, AC_Position[0], AC_Position[1], AC_Position[2]);
  103. Bit_Set(AC_SafeTP, playerid, true);
  104. return PutPlayerInVehicle(playerid, vehicleid, seatid);
  105. }
  106.  
  107. #if defined _ALS_PutPlayerInVehicle
  108. #undef PutPlayerInVehicle
  109. #else
  110. #define _ALS_PutPlayerInVehicle
  111. #endif
  112.  
  113. #define PutPlayerInVehicle pds_PutPlayerInVehicle
  114.  
  115.  
  116. static stock GetVehicleSpeed( vehicleid ) //records in KMH.
  117. {
  118. new
  119. Float:VehiclePos[3],
  120. VehicleVelocity
  121. ;
  122. GetVehicleVelocity( vehicleid, VehiclePos[0], VehiclePos[1], VehiclePos[2] );
  123. VehicleVelocity = floatround( floatsqroot( VehiclePos[0]*VehiclePos[0] + VehiclePos[1]*VehiclePos[1] + VehiclePos[2]*VehiclePos[2] ) * 180 );
  124. return VehicleVelocity;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement