Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.43 KB | None | 0 0
  1. /***************************************************************************************************
  2.                                 AMX Parachute
  3.          
  4.   Version: 0.2.2
  5.   Author: KRoTaL
  6.  
  7.   0.1    Release
  8.   0.1.1  Players can't buy a parachute if they already own one
  9.   0.1.2  Release for AMX MOD X
  10.   0.1.3  Minor changes
  11.   0.1.4  Players lose their parachute if they die
  12.   0.1.5  Added amx_parachute cvar
  13.   0.1.6  Changed set_origin to movetype_follow (you won't see your own parachute)
  14.   0.1.7  Added amx_parachute <name> | admins with admin level a get a free parachute
  15.   0.1.8  Fixed the give parachute command
  16.      added a admin_parachute cvar to give admins with level A a free parachute
  17.   0.1.9  Added a sell command & added a cvar to get money back
  18.   0.2.0  Added para_free cvar to give everyone a free parachute
  19.   0.2.1  Fixed some minor bugs
  20.   0.2.2  Fixed the parachute remove bug
  21.   0.2.3  Fixed the alive bug
  22.  
  23.  
  24.   Commands:
  25.  
  26.     say buy_parachute   - buys a parachute
  27.    
  28.     amx_parachute <name>|@all   - gives a player a free parachute
  29.  
  30.     Press +use to slow down your fall.
  31.  
  32.   Cvars:
  33.  
  34.     sv_parachute "1"     -  0: disables the plugin
  35.                     1: enables the plugin
  36.  
  37.     parachute_cost "1000"    -  cost of the parachute
  38.    
  39.     admin_parachute "0"  -  0: admins with level A won't get a free parachute
  40.                     1: admins with level A get a free parachute
  41.                    
  42.     parachute_payback "75"   -  the amount you get back of the parachute in %(75/100*1000) = 750
  43.    
  44.     para_free "0"        -  0: no free parachute
  45.                     1: free parachute for everyone
  46.    
  47.  
  48.   Setup (AMXX 1.71):
  49.  
  50.     Install the amxx file.
  51.     Enable engine and cstrike(amxx's modules.ini)
  52.     Put the parachute.mdl file in the cstrike/models folder
  53.  
  54.  
  55. ***************************************************************************************************/
  56.  
  57. #include <amxmodx>
  58. #include <amxmisc>
  59. #include <engine>
  60. #include <cstrike>
  61.  
  62. #define PLUGINNAME  "AMXX Parachute"
  63. #define VERSION     "0.2.3"
  64. #define AUTHOR      "KRoT@L"
  65.  
  66. new bool:has_parachute[33];
  67. new para_ent[33];
  68. new bool:had_parachute[33];
  69. new bool:player_died[33];
  70.  
  71. public plugin_init()
  72. {
  73.     register_plugin( PLUGINNAME, VERSION, AUTHOR )
  74.    
  75.     register_dictionary( "parachute.txt" )
  76.    
  77.     register_concmd( "say buy_parachute", "buy_parachute" )
  78.     register_concmd( "say sell_parachute", "sell_parachute" )
  79.     register_concmd( "amx_parachute", "give_parachute", ADMIN_LEVEL_A, "amx_parachute <name, @all>" )
  80.  
  81.     register_cvar( "sv_parachute", "1" )
  82.     register_cvar( "parachute_cost", "0" )
  83.     register_cvar( "parachute_payback", "75" )
  84.     register_cvar( "admin_parachute", "0" )
  85.     register_cvar( "para_free", "0" )
  86.    
  87.     register_logevent( "event_roundstart", 2, "0=World triggered", "1=Round_Start" )
  88.     register_logevent( "event_roundend", 2, "0=World triggered", "1=Round_End" )
  89.     register_event( "ResetHUD", "event_resethud", "be" )
  90.     register_event( "DeathMsg", "death_event", "a" )
  91. }
  92.  
  93. public plugin_modules() {
  94.     require_module( "engine" )
  95.     require_module( "cstrike" )
  96. }
  97.  
  98. public plugin_precache()
  99. {
  100.     precache_model("models/parachute.mdl")
  101. }
  102.  
  103. public client_connect(id)
  104. {
  105.     if(para_ent[id] > 0)
  106.     {
  107.         remove_entity(para_ent[id])
  108.     }
  109.     has_parachute[id] = false
  110.     para_ent[id] = 0
  111. }
  112.  
  113. public event_roundstart() {
  114.     new MaxPlayers = get_maxplayers();
  115.     for( new id; id < MaxPlayers; id++ ) {
  116.         if( had_parachute[id] == true && player_died[id] == false ) {
  117.             has_parachute[id] = true
  118.         }
  119.     }
  120.     set_task( 3.0, "free_parachute" );
  121.        
  122. }
  123.  
  124. public event_roundend() {
  125.     new MaxPlayers = get_maxplayers();
  126.     for( new id; id < MaxPlayers; id++ ) {
  127.         if( is_user_alive( id ) ) {
  128.             if( has_parachute[id] == true ) {
  129.                 had_parachute[id] = true;
  130.             }else{
  131.                 had_parachute[id] = false;
  132.             }
  133.             player_died[id] = false;
  134.  
  135.         }else {
  136.             if(para_ent[id] > 0) {
  137.                 remove_entity(para_ent[id])
  138.             }
  139.             has_parachute[id] = false
  140.             para_ent[id] = 0
  141.             player_died[id] = true;
  142.         }
  143.     }
  144.        
  145. }
  146.  
  147. public event_resethud( id ) {
  148.     if(para_ent[id] > 0)
  149.     {
  150.         remove_entity(para_ent[id])
  151.     }
  152.     has_parachute[id] = false
  153.     para_ent[id] = 0
  154.    
  155.     buy_parachute(id)
  156. }
  157.  
  158. public death_event()
  159. {
  160.     new id = read_data(2)
  161.  
  162.     if(para_ent[id] > 0)
  163.     {
  164.         remove_entity(para_ent[id])
  165.     }
  166.     has_parachute[id] = false
  167.     para_ent[id] = 0
  168.     player_died[id] = true
  169. }
  170.  
  171. public buy_parachute(id) {
  172.    
  173.    
  174.     has_parachute[id] = true
  175.  
  176.     return PLUGIN_CONTINUE
  177. }
  178.  
  179. public sell_parachute(id) {
  180.     if (get_cvar_num("sv_parachute") == 0) {
  181.         client_print(id, print_chat, "%L", id, "para_disabled")
  182.         return PLUGIN_CONTINUE
  183.     }
  184.     if (has_parachute[id]) {
  185.         if(para_ent[id] > 0)
  186.         {
  187.             if(is_valid_ent(para_ent[id])) {
  188.                 remove_entity(para_ent[id])
  189.             }
  190.         }
  191.         has_parachute[id] = false
  192.         para_ent[id] = 0
  193.  
  194.         new money = cs_get_user_money(id)
  195.         new cost = get_cvar_num("parachute_cost")
  196.         new payback = floatround(float(cost) * (get_cvar_float("parachute_payback") / 100))
  197.         cs_set_user_money(id, money + payback)
  198.         client_print(id, print_chat, "%L", id, "para_sell", payback)
  199.     }
  200.     return PLUGIN_CONTINUE
  201. }
  202. public free_parachute() {
  203.     new maxPlayers = get_maxplayers();
  204.     if(get_cvar_num( "sv_parachute" ) == 0) return PLUGIN_CONTINUE
  205.  
  206.         for( new i = 1; i <= maxPlayers; i++ )
  207.         {
  208.         if( !is_user_connected( i ) ) return PLUGIN_CONTINUE
  209.        
  210.         if ( get_cvar_num( "para_free") == 1 ) {
  211.             client_print( i, print_chat, "%L", LANG_PLAYER, "para_admin_free" )
  212.             has_parachute[i] = true
  213.            
  214.             return PLUGIN_CONTINUE
  215.         }
  216.         if ( get_cvar_num("admin_parachute") == 1 && get_user_flags( i ) && ADMIN_LEVEL_A ) {
  217.             client_print( i, print_chat, "%L", LANG_PLAYER, "para_admin_free" )
  218.             has_parachute[i] = true
  219.            
  220.             return PLUGIN_CONTINUE
  221.         }
  222.     }
  223.     return PLUGIN_CONTINUE
  224. }
  225.  
  226. public give_parachute(id, level, cid) {
  227.    
  228.     if (!cmd_access(id, level, cid, 2 ) ) {
  229.         return PLUGIN_CONTINUE
  230.     }
  231.    
  232.     if (get_cvar_num("sv_parachute") == 0 ) {
  233.         client_print(id, print_chat, "%L", id, "para_disabled")
  234.        
  235.         return PLUGIN_CONTINUE
  236.     }else{
  237.         new arg[32]
  238.         read_argv( 1, arg, 31 )
  239.         if (arg[0] == '@' && arg[1] == 'a') {
  240.             new maxPlayers = get_maxplayers();
  241.             for( new i = 1; i <= maxPlayers; i++ )
  242.             {
  243.                 client_print( i, print_chat, "%L", LANG_PLAYER, "para_free_all" )
  244.                 has_parachute[i] = true
  245.             }
  246.            
  247.             return PLUGIN_CONTINUE
  248.         }
  249.         new player = cmd_target( id, arg, 4 )
  250.        
  251.         if (has_parachute[id]) {
  252.             client_print(id, print_chat, "%L", id, "para_has" )
  253.            
  254.             return PLUGIN_CONTINUE
  255.         }
  256.         if( !player ) {
  257.             client_print( id, print_chat, "%L", id, "para_no_player" )
  258.    
  259.             return PLUGIN_CONTINUE
  260.         }else{
  261.             client_print(player, print_chat, "%L", player, "para_give" )
  262.             has_parachute[player] = true
  263.            
  264.             return PLUGIN_CONTINUE
  265.         }
  266.        
  267.     }
  268.     return PLUGIN_CONTINUE
  269. }
  270.  
  271. public client_PreThink(id)
  272. {
  273.     if( get_cvar_num( "sv_parachute" ) == 0 )
  274.     {
  275.         return PLUGIN_CONTINUE
  276.     }
  277.  
  278.     if( !is_user_alive(id) )
  279.     {
  280.         return PLUGIN_CONTINUE
  281.     }
  282.  
  283.     if( has_parachute[id] )
  284.     {
  285.         if (get_user_button(id) & IN_USE )
  286.         {
  287.             if ( !( get_entity_flags(id) & FL_ONGROUND ) )
  288.             {
  289.                 new Float:velocity[3]
  290.                 entity_get_vector(id, EV_VEC_velocity, velocity)
  291.                 if(velocity[2] < 0)
  292.                 {
  293.                     if (para_ent[id] == 0)
  294.                     {
  295.                         para_ent[id] = create_entity("info_target")
  296.                         if (para_ent[id] > 0)
  297.                         {
  298.                             entity_set_model(para_ent[id], "models/parachute.mdl")
  299.                             entity_set_int(para_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW)
  300.                             entity_set_edict(para_ent[id], EV_ENT_aiment, id)
  301.                         }
  302.                     }
  303.                     if (para_ent[id] > 0)
  304.                     {
  305.                         velocity[2] = (velocity[2] + 40.0 < -100) ? velocity[2] + 40.0 : -100.0
  306.                         entity_set_vector(id, EV_VEC_velocity, velocity)
  307.                         if (entity_get_float(para_ent[id], EV_FL_frame) < 0.0 || entity_get_float(para_ent[id], EV_FL_frame) > 254.0)
  308.                         {
  309.                             if (entity_get_int(para_ent[id], EV_INT_sequence) != 1)
  310.                             {
  311.                                 entity_set_int(para_ent[id], EV_INT_sequence, 1)
  312.                             }
  313.                             entity_set_float(para_ent[id], EV_FL_frame, 0.0)
  314.                         }
  315.                         else
  316.                         {
  317.                             entity_set_float(para_ent[id], EV_FL_frame, entity_get_float(para_ent[id], EV_FL_frame) + 1.0)
  318.                         }
  319.                     }
  320.                 }
  321.                 else
  322.                 {
  323.                     if (para_ent[id] > 0)
  324.                     {
  325.                         remove_entity(para_ent[id])
  326.                         para_ent[id] = 0
  327.                     }
  328.                 }
  329.             }
  330.             else
  331.             {
  332.                 if (para_ent[id] > 0)
  333.                 {
  334.                     remove_entity(para_ent[id])
  335.                     para_ent[id] = 0
  336.                 }
  337.             }
  338.         }
  339.         else if (get_user_oldbutton(id) & IN_USE)
  340.         {
  341.             if (para_ent[id] > 0)
  342.             {
  343.                 remove_entity(para_ent[id])
  344.                 para_ent[id] = 0
  345.             }
  346.         }
  347.     }
  348.    
  349.     return PLUGIN_CONTINUE
  350. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement