Raised This Month: $ Target: $400
 0% 

Solved Bots to use a parachute


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ivani6651
Member
Join Date: Feb 2017
Old 12-20-2020 , 16:24   Bots to use a parachute
Reply With Quote #1

Can you make my bots be able to use a free parachute as and when they jump from a height!

PHP Code:
#include <amxmodx>
#include <engine>
#include <fun>
#include <hamsandwich>
 
#define PLUGIN "Parachute"
#define VERSION "1.0"
#define AUTHOR "Slavvkko"
 
new para_ent[33]
new 
pDetachpFallSpeedFloat:gravity[33]
 
public 
plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR);
   
pFallSpeed register_cvar("parachute_fallspeed""100")
   
pDetach register_cvar("parachute_detach""1")
   
register_event("DeathMsg""death_event""a")
   
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
}
 
public 
client_disconnect(id)
{
   
parachute_reset(id)
}
 
public 
death_event()
{
   new 
id read_data(2)
   
parachute_reset(id)
}
 
parachute_reset(id)
{
   if(
para_ent[id] > 0) {
      if (
is_valid_ent(para_ent[id])) {
         
remove_entity(para_ent[id])
      }
   }
 
   
para_ent[id] = 0
}
 
public 
fw_PlayerSpawn_Post(id)
{
   if (!
is_user_alive(id))
      return;
    
   
gravity[id] = get_user_gravity(id)
}
 
public 
zp_user_infected_post(idinfectornemesis)
{
   
gravity[id] = get_user_gravity(id)
}
 
public 
zp_user_humanized_post(idsurvivor)
{
   
gravity[id] = get_user_gravity(id)
}
 
public 
client_PreThink(id)
{
   
//parachute.mdl animation information
   //0 - deploy - 84 frames
   //1 - idle - 39 frames
   //2 - detach - 29 frames
 
   
if (!is_user_alive(id)) return
 
   new 
Float:fallspeed get_pcvar_float(pFallSpeed) * -1.0
   
new Float:frame
 
   
new button get_user_button(id)
   new 
oldbutton get_user_oldbutton(id)
   new 
flags get_entity_flags(id)
    
   if (
para_ent[id] > && (flags FL_ONGROUND)) {
 
      if (
get_pcvar_num(pDetach)) {
 
         if (
get_user_gravity(id) == 0.1set_user_gravity(idgravity[id])
 
         if (
entity_get_int(para_ent[id],EV_INT_sequence) != 2) {
            
entity_set_int(para_ent[id], EV_INT_sequence2)
            
entity_set_int(para_ent[id], EV_INT_gaitsequence1)
            
entity_set_float(para_ent[id], EV_FL_frame0.0)
            
entity_set_float(para_ent[id], EV_FL_fuser10.0)
            
entity_set_float(para_ent[id], EV_FL_animtime0.0)
            
entity_set_float(para_ent[id], EV_FL_framerate0.0)
            return
         }
 
         
frame entity_get_float(para_ent[id],EV_FL_fuser1) + 2.0
         entity_set_float
(para_ent[id],EV_FL_fuser1,frame)
         
entity_set_float(para_ent[id],EV_FL_frame,frame)
 
         if (
frame 254.0) {
            
remove_entity(para_ent[id])
            
para_ent[id] = 0
         
}
      }
      else {
         
remove_entity(para_ent[id])
         
set_user_gravity(idgravity[id])
         
para_ent[id] = 0
      
}
 
      return
   }
 
   if (
button IN_USE) {
       
      new 
Float:velocity[3]
      
entity_get_vector(idEV_VEC_velocityvelocity)
 
      if (
velocity[2] < 0.0) {
 
         if(
para_ent[id] <= 0) {
            
para_ent[id] = create_entity("info_target")
            if(
para_ent[id] > 0) {
               
entity_set_string(para_ent[id],EV_SZ_classname,"parachute")
               
entity_set_edict(para_ent[id], EV_ENT_aimentid)
               
entity_set_edict(para_ent[id], EV_ENT_ownerid)
               
entity_set_int(para_ent[id], EV_INT_movetypeMOVETYPE_FOLLOW)
               
entity_set_int(para_ent[id], EV_INT_sequence0)
               
entity_set_int(para_ent[id], EV_INT_gaitsequence1)
               
entity_set_float(para_ent[id], EV_FL_frame0.0)
               
entity_set_float(para_ent[id], EV_FL_fuser10.0)
            }
         }
 
         if (
para_ent[id] > 0) {
 
            
entity_set_int(idEV_INT_sequence3)
            
entity_set_int(idEV_INT_gaitsequence1)
            
entity_set_float(idEV_FL_frame1.0)
            
entity_set_float(idEV_FL_framerate1.0)
            
set_user_gravity(id0.1)
 
            
velocity[2] = (velocity[2] + 40.0 fallspeed) ? velocity[2] + 40.0 fallspeed
            entity_set_vector
(idEV_VEC_velocityvelocity)
 
            if (
entity_get_int(para_ent[id],EV_INT_sequence) == 0) {
 
               
frame entity_get_float(para_ent[id],EV_FL_fuser1) + 1.0
               entity_set_float
(para_ent[id],EV_FL_fuser1,frame)
               
entity_set_float(para_ent[id],EV_FL_frame,frame)
 
               if (
frame 100.0) {
                  
entity_set_float(para_ent[id], EV_FL_animtime0.0)
                  
entity_set_float(para_ent[id], EV_FL_framerate0.4)
                  
entity_set_int(para_ent[id], EV_INT_sequence1)
                  
entity_set_int(para_ent[id], EV_INT_gaitsequence1)
                  
entity_set_float(para_ent[id], EV_FL_frame0.0)
                  
entity_set_float(para_ent[id], EV_FL_fuser10.0)
               }
            }
         }
      }
      else if (
para_ent[id] > 0) {
         
remove_entity(para_ent[id])
         
set_user_gravity(idgravity[id])
         
para_ent[id] = 0
      
}
   }
   else if ((
oldbutton IN_USE) && para_ent[id] > ) {
      
remove_entity(para_ent[id])
      
set_user_gravity(idgravity[id])
      
para_ent[id] = 0
   
}


Last edited by ivani6651; 12-23-2020 at 11:28.
ivani6651 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode