Advertisement
Guest User

OnPlayerMarkMap

a guest
Sep 10th, 2011
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.47 KB | None | 0 0
  1. #if defined _mapmark_included
  2.     #endinput
  3. #endif
  4. #define _mapmark_included
  5.  
  6. #if defined MAPMARK_CHECK_SPEED
  7. #else
  8. #define MAPMARK_CHECK_SPEED (400)
  9. #endif
  10.  
  11. new Float:mapLastX[MAX_PLAYERS];
  12. new Float:mapLastY[MAX_PLAYERS];
  13. new Float:mapLastZ[MAX_PLAYERS];
  14.  
  15. new mapWaiting[MAX_PLAYERS];
  16.  
  17. stock Float:GDBP(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ) return floatsqroot(floatadd(floatadd(floatpower(floatsub(X, PointX), 2.0), floatpower(floatsub(Y, PointY), 2.0)), floatpower(floatsub(Z, PointZ), 2.0)));
  18.  
  19. forward WaitForPositionChange(playerid);
  20. public WaitForPositionChange(playerid)
  21. {
  22.     if(mapWaiting[playerid] == -1) return 1;
  23.     SetTimerEx("WaitForPositionChange",MAPMARK_CHECK_SPEED,0,"d",playerid);
  24.     new Float:X, Float:Y, Float:Z;
  25.     GetPlayerPos(playerid,X,Y,Z);
  26.     if(GDBP(mapLastX[playerid], mapLastY[playerid], mapLastZ[playerid],X,Y,Z) > 5)
  27.     {
  28.         OnPlayerMarkMap(playerid,mapWaiting[playerid],X,Y,Z);
  29.         mapWaiting[playerid] = -1;
  30.         TogglePlayerControllable(playerid,1);
  31.         SetPlayerPos(playerid,mapLastX[playerid],mapLastY[playerid],mapLastZ[playerid]);
  32.         AllowPlayerTeleport(playerid,0);
  33.         #if defined MAPMARK_ADMINTELEPORT
  34.         #else
  35.         AllowAdminTeleport(0);
  36.         #endif
  37.     }
  38.     return 1;
  39. }
  40.  
  41. SetPlayerMarkingMap(playerid,MarkID)
  42. {
  43.     AllowPlayerTeleport(playerid,1);
  44.     #if defined MAPMARK_ADMINTELEPORT
  45.     #else
  46.     AllowAdminTeleport(1);
  47.     #endif
  48.     TogglePlayerControllable(playerid,0);
  49.     SetTimerEx("WaitForPositionChange",MAPMARK_CHECK_SPEED,0,"d",playerid);
  50.     mapWaiting[playerid]=MarkID;
  51.     GetPlayerPos(playerid,mapLastX[playerid],mapLastY[playerid],mapLastZ[playerid]);
  52. }
  53.  
  54. forward OnPlayerMarkMap(playerid, MarkID, Float:X, Float:Y, Float:Z);
  55.  
  56. // --- Help'n'Credits:
  57.  
  58. /*
  59. If you want to control AllowAdminTeleport() in your FS / GM by yourself, then put
  60.  
  61. "#define MAPMARK_ADMINTELEPORT"
  62.  
  63. ABOVE (!)
  64.  
  65. "#include <mapmark>"
  66.  
  67. AND put
  68.  
  69. public OnPlayerMarkMap(playerid, MarkID, Float:X, Float:Y, Float:Z)
  70. {
  71.     return 1;
  72. }
  73.  
  74. into your GM/FS, otherwise it won't work.
  75.  
  76. There's no way to control AllowPlayerTeleport if some players aren't allowed to teleport around everywhere and others are...
  77.  
  78. I know, there are ways to improve this, but ... lazy. Do that by urself and release it, if you want to.
  79.  
  80.  
  81.  
  82. Created by NaS, please do NOT claim this as your own. And please, USE IT! :)
  83. You can copy this into your GM/FS and release it, without asking me. But don't say "HAHAHA I CREATED THIS!" or something. Thanx.
  84. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement