Advertisement
Mongi

Dropping with rope - SAMP

May 19th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.49 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <linegen>
  4.  
  5. #define OBJECTS_FOR_ROPE 150
  6. #define ROPE_LENGTH 5.0
  7. #define MIN_ROPE_HEIGHT 70.0
  8.  
  9. enum RopeData {
  10.     RopeID[OBJECTS_FOR_ROPE],
  11.     Float:RopeX,
  12.     Float:RopeY,
  13.     Float:RopeZ
  14. };
  15. new Ropes[MAX_PLAYERS][RopeData];
  16.  
  17. new Float:RealPlayerHP[MAX_PLAYERS];
  18. new IsRappeling[MAX_PLAYERS] = false;
  19. new Float:OldPos[MAX_PLAYERS];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("\n--------------------------------------");
  24.     print(" Blank Filterscript by your name here");
  25.     print("--------------------------------------\n");
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     return 1;
  32. }
  33.  
  34. stock CreateRope(playerid)
  35. {
  36.     new Float:z;
  37.     GetPlayerPos(playerid, Ropes[playerid][RopeX], Ropes[playerid][RopeY], z);
  38.     new Float:Angle;
  39.     GetPlayerFacingAngle(playerid, Angle);
  40.    
  41.     for(new i = 0; i < OBJECTS_FOR_ROPE; i++)
  42.     {
  43.         Ropes[playerid][RopeID][i] = CreateDynamicObject(19089, Ropes[playerid][RopeX], Ropes[playerid][RopeY], z-(i*ROPE_LENGTH), 0, 0, Angle);
  44.     }
  45. }
  46.  
  47. stock DestroyRope(playerid)
  48. {
  49.     for(new i = 0; i < OBJECTS_FOR_ROPE; i++)
  50.     {
  51.         DestroyDynamicObject(Ropes[playerid][RopeID][i]);
  52.     }
  53. }
  54.  
  55. public OnPlayerDisconnect(playerid, reason)
  56. {
  57.     IsRappeling[playerid] = false;
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerUpdate(playerid)
  62. {
  63.     if(IsRappeling[playerid])
  64.     {
  65.         ApplyAnimation(playerid, "ped", "abseil", 4.1, 1, 1, 1, 0, 0, 1);
  66.         SetPlayerHealth(playerid, 0x7FFFFFFF);
  67.         new Float:x, Float:y, Float:z;
  68.         GetPlayerPos(playerid, x, y, z);
  69.         if(z == OldPos[playerid])
  70.         {
  71.             ClearAnimations(playerid, 1);
  72.             IsRappeling[playerid] = false;
  73.             SetPlayerHealth(playerid, RealPlayerHP[playerid]);
  74.             DestroyRope(playerid);
  75.         }
  76.         else OldPos[playerid] = z;
  77.     }
  78.     return 1;
  79. }
  80.  
  81. CMD:slapme(playerid, params[]) // Just for testing
  82. {
  83.     new Float:x, Float:y, Float:z;
  84.     GetPlayerPos(playerid, x, y, z);
  85.     SetPlayerPos(playerid, x, y, z+100);
  86.     return 1;
  87. }
  88.  
  89. CMD:drop(playerid, params[])
  90. {
  91.     if(IsRappeling[playerid]) return SendClientMessage(playerid, -1, "Error: You are already rappeling!");
  92.     new Float:x, Float:y, Float:z;
  93.     GetPlayerPos(playerid, x, y, z);
  94.     if ( z < MIN_ROPE_HEIGHT ) return SendClientMessage(playerid, -1, "Error: Tell the driver to go higher!");
  95.     OldPos[playerid] = z;
  96.     GetPlayerHealth(playerid, RealPlayerHP[playerid]);
  97.     IsRappeling[playerid] = true;
  98.     ApplyAnimation(playerid, "ped", "abseil", 4.1, 1, 1, 1, 0, 0, 1);
  99.     SetPlayerHealth(playerid, 0x7FFFFFFF);
  100.     CreateRope(playerid);
  101.     return 1;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement