Advertisement
Blasium

Advanced SWAT Rope

Feb 7th, 2012
10,626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.49 KB | None | 0 0
  1. #include <a_samp> //0.3 r7 required
  2. #include <mapandreas> //you have to set it up on your own (see http://forum.sa-mp.com/index.php?topic=145196.0 )
  3.  
  4. #define players 500 //maximum of players in your server
  5. #define chopperid 497 //ID of the vehicle model ( http://wiki.sa-mp.com/wiki/Vehicles:Helicopters )
  6. #define ropelength 50 //length of slideable rope (ingame meters)
  7. #define skinid 285 //the skin, who may slide down the rope ( http://wiki.sa-mp.com/wiki/Skins:All )
  8.  
  9. #define offsetz 12
  10. #define dur 250
  11.  
  12. new r0pes[players][ropelength],Float:pl_pos[players][5]; //cause pvar + array = sux
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  17.     print("\n--------------------------------------");
  18.     print("         <Advanced Rope (v1)>           ");
  19.     print("  (c) Trooper([Y]) , 2010 (Nicksoft)    ");
  20.     print("--------------------------------------\n");
  21.    
  22.     return 1;
  23. }
  24.  
  25. public OnFilterScriptExit()
  26. {
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerDisconnect(playerid, reason)
  36. {
  37.     if(GetPVarInt(playerid,"roped") == 1)
  38.     {
  39.         for(new destr=0;destr<=ropelength;destr++)
  40.         {
  41.             DestroyObject(r0pes[playerid][destr]);
  42.         }
  43.     }
  44.     return 1;
  45. }
  46.  
  47. public OnPlayerDeath(playerid, killerid, reason)
  48. {
  49.     if(GetPVarInt(playerid,"roped") == 1)
  50.     {
  51.         for(new destr2=0;destr2<=ropelength;destr2++)
  52.         {
  53.             DestroyObject(r0pes[playerid][destr2]);
  54.         }
  55.         SetPVarInt(playerid,"roped",0);
  56.         DisablePlayerCheckpoint(playerid);
  57.     }
  58.     return 1;
  59. }
  60.  
  61. public OnVehicleDeath(vehicleid, killerid)
  62. {
  63.     if(GetVehicleModel(vehicleid) == chopperid)
  64.     {
  65.         for(new shg=0;shg<=players;shg++)
  66.         {
  67.             if(GetPVarInt(shg,"chop_id") == vehicleid && GetPVarInt(shg,"roped") == 1)
  68.             {
  69.                 DisablePlayerCheckpoint(shg);
  70.                 SetPVarInt(shg,"roped",0);
  71.                 DisablePlayerCheckpoint(shg);
  72.                 ClearAnimations(shg);
  73.                 TogglePlayerControllable(shg,1);
  74.                 for(new destr3=0;destr3<=ropelength;destr3++)
  75.                 {
  76.                     DestroyObject(r0pes[shg][destr3]);
  77.                 }
  78.             }
  79.         }
  80.     }
  81.     return 1;
  82. }
  83.  
  84. forward syncanim(playerid);
  85. public syncanim(playerid)
  86. {
  87.     if(GetPVarInt(playerid,"roped") == 0) return 0;
  88.     SetTimerEx("syncanim",dur,0,"i",playerid);
  89.     ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
  90.     return 1;
  91. }
  92.  
  93. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  94. {
  95.     if(GetVehicleModel(vehicleid) == chopperid && ispassenger)
  96.     {
  97.         SetPVarInt(playerid,"chop_id",GetPlayerVehicleID(playerid));
  98.         SetPVarInt(playerid,"roped",0);
  99.     }
  100.     else SetPVarInt(playerid,"chop_id",0);
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerEnterCheckpoint(playerid)
  105. {
  106.     if(GetPVarInt(playerid,"roped") == 1 && GetPlayerSkin(playerid) == skinid)
  107.     {
  108.         SetPVarInt(playerid,"roped",0);
  109.         SetPVarInt(playerid,"chop_id",0);
  110.         ClearAnimations(playerid);
  111.         TogglePlayerControllable(playerid,0);
  112.         TogglePlayerControllable(playerid,1);
  113.         DisablePlayerCheckpoint(playerid);
  114.         for(new destr4=0;destr4<=ropelength;destr4++)
  115.         {
  116.             DestroyObject(r0pes[playerid][destr4]);
  117.         }
  118.     }
  119.        
  120.     return 1;
  121. }
  122.  
  123. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  124. {
  125.     if(GetPlayerSkin(playerid) == skinid && GetPVarInt(playerid,"roped") == 0 && GetPlayerVehicleSeat(playerid) != 0 && IsPlayerInAnyVehicle(playerid) && (newkeys & KEY_SUBMISSION || newkeys == KEY_SUBMISSION))
  126.     {
  127.         GetPlayerPos(playerid,pl_pos[playerid][0],pl_pos[playerid][1],pl_pos[playerid][2]);
  128.         MapAndreas_FindZ_For2DCoord(pl_pos[playerid][0],pl_pos[playerid][1],pl_pos[playerid][3]);
  129.         pl_pos[playerid][4] = floatsub(pl_pos[playerid][2],pl_pos[playerid][3]);
  130.         if(pl_pos[playerid][4] >= ropelength) return SendClientMessage(playerid,0xAA3333AA,"You are too scared to slide from this height");
  131.         if(pl_pos[playerid][4] <= 2) return RemovePlayerFromVehicle(playerid);
  132.         SetPVarInt(playerid,"roped",1);
  133.         SetPlayerCheckpoint(playerid,pl_pos[playerid][0],pl_pos[playerid][1],floatsub(pl_pos[playerid][3],offsetz),20);
  134.         SetPlayerPos(playerid,pl_pos[playerid][0],pl_pos[playerid][1],floatsub(pl_pos[playerid][2],2));
  135.         SetPlayerVelocity(playerid,0,0,0);
  136.         for(new rep=0;rep!=10;rep++) ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
  137.         for(new cre=0;cre<=pl_pos[playerid][4];cre++)
  138.         {
  139.             r0pes[playerid][cre] = CreateObject(3004,pl_pos[playerid][0],pl_pos[playerid][1],floatadd(pl_pos[playerid][3],cre),87.640026855469,342.13500976563, 350.07507324219);
  140.         }
  141.         SetTimerEx("syncanim",dur,0,"i",playerid);
  142.     }
  143.     return 1;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement