Raised This Month: $ Target: $400
 0% 

Model on Player Oirigin's back added to existing jetpack idle function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Murd
New Member
Join Date: May 2011
Old 05-16-2011 , 20:25   Model on Player Oirigin's back added to existing jetpack idle function
Reply With Quote #1

This is the TS_Jetpack plugin by Bad_Bud or B!g_Bud whoever. I changed a few effects but could not get a working entity_set_model in the Idle state. JetpackBools[id][0] is the idle. //Idle jetpack. to find your way through the text to get to the idle effect area. I need help with putting the model on the back like c4 in CS when the jetpack is turned on and thats all.
the precache model to use is models/arp/w_backpack.mdl

Code:
// Jetpack mod: Cvars can toggle explosions and effects.  Jetpack key is the reload key.
// Fuel is optional.

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new bool:JetpackBools[33][2]//Jetpack On/Jetpack in use?
new Float:JetpackSound[33][2]//When was the last sound played?
new JetpackFuel[33],explosion,smoke
new TS_Jetpack,TS_Jetpack_Explode,TS_Jetpack_Fuel,TS_Jetpack_Death,TS_Jetpack_UpSpeed
new TS_Jetpack_ForwardSpeed,TS_Jetpack_Accelerate,TS_Jetpack_UAccelerate,TS_Jetpack_FuelMatch
new TS_Jetpack_MaxFuel,TS_Jetpack_StartingFuel,TS_Jetpack_DepletionRate,TS_Jetpack_RegenRate,TS_Jetpack_IdleDeplete

public plugin_init()
{
    register_plugin("TS_Jetpack","3.0","Bad_BudExtra")
    
    register_clcmd("jetpack","Jetpack")
    register_clcmd("+mentalnotethisdoesntworkpack","gogojetpack")//this needs to have the getkey removed so it can use the jetpack in one key
    register_clcmd("-mentalnotethisdoesntworkpack","stopjetpack")
    register_concmd("ts_jetpack_setfuel","SetFuel",ADMIN_RCON)
    register_concmd("ts_jetpack_givefuel","GiveFuel",ADMIN_RCON)
    register_concmd("ts_jetpack_save","SaveConfig",ADMIN_RCON)
    register_concmd("ts_jetpack_reset","JetpackReset",ADMIN_RCON)//Resets jetpack fuels.
    
    TS_Jetpack=register_cvar("ts_jetpack","1")//1 = On
    TS_Jetpack_Explode=register_cvar("ts_jetpack_explode","1")//1 = On, 2 = Burst regeneration jetpacks.
    TS_Jetpack_Fuel=register_cvar("ts_jetpack_fuel","0")//1 = True
    TS_Jetpack_FuelMatch=register_cvar("ts_jetpack_fuelmatch","10")//If greater than 0, you gain said fuel amount for each kill you get.
    TS_Jetpack_Death=register_cvar("ts_jetpack_death","0")//If 1, jetpacks in use turn off when their owner dies.
    TS_Jetpack_UpSpeed=register_cvar("ts_jetpack_upspeed","200.0")//Upward thrust the jetpack gives.
    TS_Jetpack_ForwardSpeed=register_cvar("ts_jetpack_forwardspeed","575.0")//Max forward speed.
    TS_Jetpack_Accelerate=register_cvar("ts_jetpack_accelerate","50.0")//Rate of acceleration (forward, back, left, right).
    TS_Jetpack_UAccelerate=register_cvar("ts_jetpack_uaccelerate","100.0")//Rate of upward acceleration.
    TS_Jetpack_MaxFuel=register_cvar("ts_jetpack_maxfuel","1000")//Max fuel.
    TS_Jetpack_StartingFuel=register_cvar("ts_jetpack_startingfuel","50")//Starting fuel.
    TS_Jetpack_DepletionRate=register_cvar("ts_jetpack_depletionrate","1.0")//Rate at which fuel depletes.  1.0 is the standard rate.
    TS_Jetpack_RegenRate=register_cvar("ts_jetpack_regenrate","1.0")//Rate at which fuel regenerates.  1.0 is the standard rate.  This is only used if ts_jetpack_fuel is set to 2.
    TS_Jetpack_IdleDeplete=register_cvar("ts_jetpack_idledeplete","1")//If 0, idle jetpacks don't slowly lose fuel.
    
    register_event("DeathMsg","Death","a")
    
    register_forward(FM_PlayerPreThink,"PreThink")
    
    set_task(0.1,"JetpackFly",0,"",0,"b")
}

public plugin_precache()
{
    precache_sound("Jetpack/Jetpack.wav")
    precache_sound("Jetpack/JetpackIdle.wav")
    
    explosion=precache_model("sprites/explode1.spr")
    smoke=precache_model("sprites/lightsmoke.spr")
}

public client_putinserver(id)
{
    if(get_pcvar_num(TS_Jetpack_Fuel)==1)
    {
        JetpackFuel[id]=((get_pcvar_num(TS_Jetpack_StartingFuel)*1000)-1)
    }
    else if(get_pcvar_num(TS_Jetpack_Fuel)==2)
    {
        JetpackFuel[id]=99999
    }
}

public client_disconnect(id)
{    
    JetpackBools[id][0]=false
    JetpackBools[id][1]=false
    
    JetpackSound[id][0]=0.0
    JetpackSound[id][1]=0.0
}

public JetpackReset(id)
{
    static i,TotalPlayers
    static Players[32]
    get_players(Players,TotalPlayers)
    
    if(get_pcvar_num(TS_Jetpack_Fuel)==1)
        for (i=0;i<TotalPlayers;i++)
        {
            id=Players[i]
            
            JetpackFuel[id]=((get_pcvar_num(TS_Jetpack_StartingFuel)*1000)-1)
        }    
    else if(get_pcvar_num(TS_Jetpack_Fuel)==2)
        for (i=0;i<TotalPlayers;i++)
        {
            id=Players[i]
            
            JetpackFuel[id]=99999
        }
    
    return PLUGIN_HANDLED
}

public PreThink(id)
{
    if(get_pcvar_num(TS_Jetpack)==1)
    {
        static Button
        Button=pev(id,pev_button)
        
        if(JetpackBools[id][0])
        {
            if((Button&IN_RELOAD)&&(!(pev(id,pev_flags)&FL_ONGROUND)))
            {
                if(get_pcvar_num(TS_Jetpack_Fuel)==2&&JetpackFuel[id]<5000)
                    JetpackBools[id][1]=false
                else
                    JetpackBools[id][1]=true
            }
            
            set_pev(id,pev_button,Button&~IN_RELOAD)
            
            if(JetpackBools[id][1])
            {
                if(Float:engfunc(EngFunc_Time)-JetpackSound[id][0]>1.0&&is_user_alive(id))
                {
                    emit_sound(id,CHAN_ITEM,"Jetpack/jetpack.wav",1.0,ATTN_NORM,0,PITCH_NORM)
                    JetpackSound[id][0]=Float:engfunc(EngFunc_Time)
                }
                JetpackSound[id][1]=0.0
            }
            else
            {
                if(Float:engfunc(EngFunc_Time)-JetpackSound[id][1]>1.0&&is_user_alive(id))
                {
                    emit_sound(id,CHAN_ITEM,"Jetpack/jetpackidle.wav",1.0,ATTN_NORM,0,PITCH_NORM)
                    JetpackSound[id][1]=Float:engfunc(EngFunc_Time)
                }
                JetpackSound[id][0]=0.0
            }
        }
    }
    
    return FMRES_IGNORED
}

public gogojetpack(id) //This doesn't look like it will work lmao - (V)URD
{
    JetpackBools[id][0]=true
    JetpackBools[id][1]=true
    effect_fly(id)
}

public stopjetpack(id)
{
    JetpackBools[id][0]=false
    JetpackBools[id][1]=false
}

public client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{    
    if(get_pcvar_num(TS_Jetpack_Explode)==1)
    {
        if(JetpackBools[victim][1])
        {        
            if(wpnindex!=0&&wpnindex!=25&&wpnindex!=35&&wpnindex!=36)//If not: Falldamage, Combat Knife, Seal Knife, Kung Fu
            {
                    if(wpnindex==24&&damage>15)//Grenade
                        JetpackExplode(victim)
                    else if(damage>90)
                        JetpackExplode(victim)
                    else if(damage<75&&random(2)!=0)
                        JetpackExplode(victim)
                    else if(damage<50&&random(1)==1)
                        JetpackExplode(victim)
                    else if(damage<25&&random(2)==2)
                        JetpackExplode(victim)
                    else if(random(4)==4)
                        JetpackExplode(victim)
            }
        }
    }
}

public JetpackExplode(victim)
{
    static Float:TempOrigin[3]
    pev(victim,pev_origin,TempOrigin)
    
    if(get_pcvar_num(TS_Jetpack_Fuel)==1)
    {
        if(JetpackFuel[victim]>25000)
            JetpackFuel[victim]=floatround(JetpackFuel[victim]*0.8)
        else
            JetpackFuel[victim]=0
    }
    
    effect_explosion(victim)
    
    RadiusDamage(TempOrigin,170.0,650.0)
}

public Death()
{
    static id,killerid
    killerid=read_data(1)
    id=read_data(2)
    
    if(get_pcvar_num(TS_Jetpack_FuelMatch)>0&&get_pcvar_num(TS_Jetpack_Fuel)==1&&killerid!=id&&killerid!=0)//Fuelmatch is on, and fuelmode is 1.
    {
        client_print(killerid,print_chat,"*You have gained %d fuel.",get_pcvar_num(TS_Jetpack_FuelMatch))
        JetpackFuel[killerid]+=((get_pcvar_num(TS_Jetpack_FuelMatch)*1000)-1)
        
        if(JetpackFuel[killerid]>get_pcvar_num(TS_Jetpack_MaxFuel))
            JetpackFuel[killerid]=((get_pcvar_num(TS_Jetpack_MaxFuel)*1000)-1)
    }
    else if(get_pcvar_num(TS_Jetpack_Fuel)==2)
    {
        JetpackFuel[id]=99999
    }
    
    if(get_pcvar_num(TS_Jetpack_Death)==1)
        JetpackBools[id][0]=false
    JetpackBools[id][1]=false
}

public Jetpack(id)
{
    if(get_pcvar_num(TS_Jetpack)==1)
    {
        if(!JetpackBools[id][0])
        {
            if(get_pcvar_num(TS_Jetpack_Fuel)==1)
            {
                if(JetpackFuel[id]>0)
                {
                    JetpackBools[id][0]=true
                
                    client_print(id,print_chat,"*You have turned your jetpack on.")
                }
                else
                    client_print(id,print_chat,"*Your jetpack has no fuel!")
            }
            else
            {
                JetpackBools[id][0]=true
                
                client_print(id,print_chat,"*You have turned your jetpack on.")
            }
        }
        else
        {
                JetpackBools[id][0]=false
            
                client_print(id,print_chat,"*You have turned your jetpack off.")
        }
    }
    
    return PLUGIN_HANDLED
}

public SetFuel(ID)
{
    if(get_pcvar_num(TS_Jetpack_Fuel)==1)
    {
        if(read_argc()==3)
        {
            static Fuel
            static arg2[33]
            read_argv(2,arg2,32)
            Fuel=str_to_num(arg2)
            
            if(Fuel<0)
            {
                client_print(ID,print_console,"ERROR: <You may only set fuel in non-negative amounts>")
            }
            else
            {        
                static arg[33]
                read_argv(1,arg,32)
                ChangeFuel(ID,arg,Fuel,true)
            }
        }
        else
        {
            client_print(ID,print_console,"USAGE: <Part of Playername or ^"ALL^"> <Amount of fuel to set (0 to %d)>",get_pcvar_num(TS_Jetpack_MaxFuel))
        }
    }
    else
    {
        client_print(ID,print_console,"USAGE: ts_jetpack_fuel must be set to 1 in order to give or set fuel.")
    }
    
    return PLUGIN_HANDLED
}

public GiveFuel(ID)
{
    if(get_pcvar_num(TS_Jetpack_Fuel)==1)
    {
        if(read_argc()==3)
        {
            static Fuel
            static arg2[33]
            read_argv(2,arg2,32)
            Fuel=str_to_num(arg2)
            
            if(Fuel<1)
            {
                client_print(ID,print_console,"ERROR: <You may only give positive amounts of fuel>")
            }
            else
            {        
                static arg[33]
                read_argv(1,arg,32)
                ChangeFuel(ID,arg,Fuel,false)
            }
        }
        else
        {
            client_print(ID,print_console,"USAGE: <Part of Playername or ^"ALL^"> <Amount of fuel to give (Fuel will cap at %d)>",get_pcvar_num(TS_Jetpack_MaxFuel))
        }
    }
    else
    {
        client_print(ID,print_console,"USAGE: ts_jetpack_fuel must be set to 1 in order to give or set fuel.")
    }
    
    return PLUGIN_HANDLED
}

public ChangeFuel(ID,arg[33],Fuel,Set)
{
    static id,MaxFuel
    MaxFuel=get_pcvar_num(TS_Jetpack_MaxFuel)
    
    if(!equali(arg,"ALL"))
    {
        id=cmd_target(id,arg)
        
        if(Set)
        {
            if(Fuel>MaxFuel)
                Fuel=MaxFuel
            
            JetpackFuel[id]=((Fuel*1000)-1)
            client_print(id,print_chat,"*Your fuel has been set to %d.",Fuel)
            
            static Name[44]
            get_user_name(id,Name,43)            
            client_print(ID,print_console,"You have set %s's fuel to %d.",Name,Fuel)
        }
        else//Give
        {
            JetpackFuel[id]+=((Fuel*1000)-1)
            
            if(JetpackFuel[id]>(MaxFuel*1000))
            {
                JetpackFuel[id]=((MaxFuel*1000)-1)
            }
            
            client_print(id,print_chat,"*You have been given %d fuel.",Fuel)
            
            static Name[44]
            get_user_name(id,Name,43)            
            client_print(ID,print_console,"You have given %d fuel to %s.",Fuel,Name)
        }
    }
    else
    {        
        static i,TotalPlayers
        static Players[32]
        get_players(Players,TotalPlayers)
        for (i=0;i<TotalPlayers;i++)
        {
            id=Players[i]
            
            if(Set)
            {
                if(Fuel>MaxFuel)
                    Fuel=MaxFuel
                
                JetpackFuel[id]=((Fuel*1000)-1)    
                client_print(id,print_chat,"*Your fuel has been set to %d.",Fuel)
            }
            else//Give
            {
                JetpackFuel[id]+=((Fuel*1000)-1)
                
                if(JetpackFuel[id]>(MaxFuel*1000))
                {
                    JetpackFuel[id]=((MaxFuel*1000)-1)
                }
                
                client_print(id,print_chat,"*You have been given %d fuel.",Fuel)
            }
        }
        
        if(Set)
            client_print(ID,print_console,"You have set everyone's fuel to %d",Fuel)
        else
            client_print(ID,print_console,"You have given %d fuel to everyone.",Fuel)
    }
}

public SaveConfig(ID)
{
    if(read_argc()==2)
    {
        static arg[65]
        read_argv(1,arg,64)
        
        if(containi(arg,".cfg")==-1)
            format(arg,64,"%s.cfg",arg)
        
        client_print(ID,print_console,"Attempting save: %s...",arg)
        
        if(!equali(arg,"config.cfg")&&!equali(arg,"game.cfg")&&!equali(arg,"listenserver.cfg")&&!equali(arg,"autoexec.cfg")&&!equali(arg,"server.cfg"))
        {
            static Write[65]
            
            format(Write,64,"ts_jetpack %d",get_pcvar_num(TS_Jetpack))        
            write_file(arg,Write,0)
            
            format(Write,64,"ts_jetpack_explode %d",get_pcvar_num(TS_Jetpack_Explode))
            write_file(arg,Write,1)
            
            format(Write,64,"ts_jetpack_fuel %d",get_pcvar_num(TS_Jetpack_Fuel))
            write_file(arg,Write,2)
            
            format(Write,64,"ts_jetpack_fuelmatch %d",get_pcvar_num(TS_Jetpack_FuelMatch))
            write_file(arg,Write,3)
            
            format(Write,64,"ts_jetpack_death %d",get_pcvar_num(TS_Jetpack_Death))
            write_file(arg,Write,4)
            
            format(Write,64,"ts_jetpack_upspeed %f",get_pcvar_float(TS_Jetpack_UpSpeed))
            write_file(arg,Write,5)
            
            format(Write,64,"ts_jetpack_forwardspeed %f",get_pcvar_float(TS_Jetpack_ForwardSpeed))
            write_file(arg,Write,6)
            
            format(Write,64,"ts_jetpack_accelerate %f",get_pcvar_float(TS_Jetpack_Accelerate))
            write_file(arg,Write,7)
            
            format(Write,64,"ts_jetpack_uaccelerate %f",get_pcvar_float(TS_Jetpack_UAccelerate))
            write_file(arg,Write,8)
            
            format(Write,64,"ts_jetpack_maxfuel %d",get_pcvar_num(TS_Jetpack_MaxFuel))
            write_file(arg,Write,9)
            
            format(Write,64,"ts_jetpack_startingfuel %d",get_pcvar_num(TS_Jetpack_StartingFuel))
            write_file(arg,Write,10)
            
            format(Write,64,"ts_jetpack_depletionrate %f",get_pcvar_float(TS_Jetpack_DepletionRate))
            write_file(arg,Write,11)
            
            format(Write,64,"ts_jetpack_regenrate %f",get_pcvar_float(TS_Jetpack_RegenRate))
            write_file(arg,Write,12)
            
            format(Write,64,"ts_jetpack_idledeplete %d",get_pcvar_num(TS_Jetpack_IdleDeplete))
            write_file(arg,Write,13)
            
            format(Write,64,"ts_jetpack_reset")
            write_file(arg,Write,14)
            
            client_print(ID,print_console,"Save complete.",arg)
        }
        else
        {
            client_print(ID,print_console,"Error: That filename is unavailable, please choose another.")
        }
    }
    else
    {
        client_print(ID,print_console,"USAGE: <Name of file>")
    }
    return PLUGIN_HANDLED
}

public JetpackFly()
{
    static Float:Velocity[3]
    new Float:NewVelocity[3]
    static Float:Angle[3]
    static Float:AngleVector[3]
    static Button
    
    static id,AlivePlayers
    static Players[32]
    get_players(Players,AlivePlayers,"a")
    for (new i=0;i<AlivePlayers;i++)
    {
        id=Players[i]
        
        if(get_pcvar_num(TS_Jetpack)==0)
        {
            if(JetpackBools[id][0])
            {
                JetpackBools[id][0]=false
                client_print(id,print_chat,"*Jetpacks have been disabled.")
            }
        }
        
        if(JetpackBools[id][1])//If jetpack is on and jetpack key is being pressed.
        {    
            effect_fly(id)
            set_pev(id,pev_gaitsequence,0)
            set_pev(id,pev_sequence,1)
            
            if(!(pev(id,pev_flags)&FL_ONGROUND))//If the jetpacker is off the ground already
            {    
                pev(id,pev_velocity,Velocity)
                
                pev(id,pev_angles,Angle)
                Angle[2]=0.0//Remove the Z value.
                
                Button=pev(id,pev_button)
                
                if(Button&IN_FORWARD)
                {                                        
                    angle_vector(Angle,ANGLEVECTOR_FORWARD,AngleVector)
                    
                    NewVelocity[0]+=(AngleVector[0]*get_pcvar_float(TS_Jetpack_Accelerate))
                    NewVelocity[1]+=(AngleVector[1]*get_pcvar_float(TS_Jetpack_Accelerate))
                }
                
                if(Button&IN_MOVERIGHT)
                {    
                    angle_vector(Angle,ANGLEVECTOR_RIGHT,AngleVector)
                    
                    NewVelocity[0]+=(AngleVector[0]*get_pcvar_float(TS_Jetpack_Accelerate))
                    NewVelocity[1]+=(AngleVector[1]*get_pcvar_float(TS_Jetpack_Accelerate))
                }
                
                if(Button&IN_MOVELEFT)
                {
                    angle_vector(Angle,ANGLEVECTOR_RIGHT,AngleVector)
                    
                    NewVelocity[0]-=(AngleVector[0]*get_pcvar_float(TS_Jetpack_Accelerate))
                    NewVelocity[1]-=(AngleVector[1]*get_pcvar_float(TS_Jetpack_Accelerate))
                }
                
                if(Button&IN_BACK)
                {
                    angle_vector(Angle,ANGLEVECTOR_FORWARD,AngleVector)
                    
                    NewVelocity[0]-=(AngleVector[0]*get_pcvar_float(TS_Jetpack_Accelerate))
                    NewVelocity[1]-=(AngleVector[1]*get_pcvar_float(TS_Jetpack_Accelerate))
                }
                
                CheckAndScale(Velocity,NewVelocity)
                
                if(Velocity[2]<0.0)//Jetpacks get more power on the way down -- it helps landing.
                {
                    Velocity[2]+=(get_pcvar_float(TS_Jetpack_UAccelerate)*1.15)
                }
                else if(Velocity[2]<get_pcvar_float(TS_Jetpack_UpSpeed))
                {
                    Velocity[2]+=get_pcvar_float(TS_Jetpack_UAccelerate)
                }
                
                set_pev(id,pev_velocity,Velocity)
            }
            
            if(get_pcvar_num(TS_Jetpack_Fuel)==1)
            {
                CheckFuel(id)
                
                JetpackHUD(id)
                
                JetpackFuel[id]-=floatround(150*get_pcvar_float(TS_Jetpack_DepletionRate))
            }
            else if(get_pcvar_num(TS_Jetpack_Fuel)==2)
            {
                JetpackFuel[id]-=floatround(5000*get_pcvar_float(TS_Jetpack_DepletionRate))
                
                CheckFuelP(id)
                
                JetpackHUDP(id)
            }
            else
            {
                set_hudmessage(0,175,0,-1.5,0.95,2,0.0,0.1,0.0,0.0,3)
                show_hudmessage(id,"")
            }
            
            JetpackBools[id][1]=false
        }
        else if(JetpackBools[id][0])//Idle jetpack.
        {    
            if(get_pcvar_num(TS_Jetpack_Fuel)==1)
            {
                CheckFuel(id)
                
                JetpackHUD(id)
                
                if(get_pcvar_num(TS_Jetpack_IdleDeplete))
                    JetpackFuel[id]-=floatround(20*get_pcvar_float(TS_Jetpack_DepletionRate))
            }
            else if(get_pcvar_num(TS_Jetpack_Fuel)==2)
            {
                CheckFuelP(id)
                
                JetpackHUDP(id)
                
                JetpackFuel[id]+=floatround(1000*get_pcvar_float(TS_Jetpack_RegenRate))
                
                if(JetpackFuel[id]>99999)
                    JetpackFuel[id]=99999
            }
            else
            {
                set_hudmessage(0,175,0,-1.5,0.95,2,0.0,0.1,0.0,0.0,3)
                show_hudmessage(id,"")
            }
            
            effect_idle(id)//Idle Jetpack Effect
        }
        else
        {
            set_hudmessage(0,175,0,-1.5,0.95,2,0.0,0.1,0.0,0.0,3)
            show_hudmessage(id,"")
        }
    }

    return PLUGIN_HANDLED
}

public CheckAndScale(Float:Velocity[3],Float:NewVelocity[3])
{
    new Float:Ratio
    
    new Float:TempVelocity[3]
    TempVelocity[0]=Velocity[0]+NewVelocity[0]
    TempVelocity[1]=Velocity[1]+NewVelocity[1]
    
    if(vector_length(TempVelocity)<get_pcvar_float(TS_Jetpack_ForwardSpeed))
    {
        Velocity[0]=TempVelocity[0]
        Velocity[1]=TempVelocity[1]
    }
    else
    {
        Ratio=(get_pcvar_float(TS_Jetpack_ForwardSpeed)/vector_length(TempVelocity))
        Velocity[0]*=Ratio
        Velocity[1]*=Ratio
    }
}

public JetpackHUD(id)
{
    if(JetpackFuel[id]>10000)
        set_hudmessage(255,255,255,-1.0,0.96,0,0.0,10.0,0.0,0.0,3)
    else
        set_hudmessage(255,0,0,-1.0,0.96,0,0.0,10.0,0.0,0.0,3)
        
    show_hudmessage(id,"Fuel: %d",(JetpackFuel[id]/1000)+1)
}

public JetpackHUDP(id)
{
    if(JetpackFuel[id]>10000)
        set_hudmessage(255,255,255,-1.0,0.96,0,0.0,10.0,0.0,0.0,3)
    else
        set_hudmessage(255,0,0,-1.0,0.96,0,0.0,10.0,0.0,0.0,3)
    
    if(JetpackFuel[id]>0)
        show_hudmessage(id,"Fuel: %d%",(JetpackFuel[id]/1000)+1)
    else
        show_hudmessage(id,"Fuel: 0%")
}

public CheckFuel(id)
{
    if(JetpackFuel[id]<1)
    {
        JetpackBools[id][0]=false
        JetpackBools[id][1]=false
        JetpackFuel[id]=0//Set to 0 in case it was slightly negative due to a high depletion rate.
        client_print(id,print_chat,"*Your jetpack is out of fuel!")
    }
}

public CheckFuelP(id)
{
    if(JetpackFuel[id]<5000)
    {
        JetpackBools[id][1]=false
        
        if(JetpackFuel[id]<1)
            JetpackFuel[id]=0//Set to 0 in case it was slightly negative due to a high depletion rate.
    }
}

public effect_fly(id)
{
    effect_smoke(id)
    effect_smoke(id)
    effect_smoke(id)
    effect_spark(id)

    return PLUGIN_HANDLED
}

public effect_smoke(id)
{
    static origin[3]
    get_user_origin(id,origin)

    message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(TE_SPRITE)
    write_coord(origin[0]+random_num(-15,15))
    write_coord(origin[1]+random_num(-15,15))
    write_coord(origin[2]-60+random_num(-10,10))
    write_short(smoke)
    write_byte(10)
    write_byte(115)
    message_end()
}

public effect_spark(id)
{
    static origin[3]
    get_user_origin(id,origin,0)
    
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(3)
    write_coord(origin[0])
    write_coord(origin[1])
    write_coord(origin[2])
    write_short(explosion)
    write_byte(4) // byte (scale in 0.1's) 188 
    write_byte(25)
    write_byte(4)
    message_end()
}

public effect_idle(id)
{    
    static origin[3]
    get_user_origin(id,origin)
    
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(TE_SPRITE)
    write_coord(origin[0]+random_num(-25,25))
    write_coord(origin[1]+random_num(-25,25))
    write_coord(origin[2]-35+random_num(0,15))
    write_short(smoke)
    write_byte(10)
    write_byte(115)
    message_end()
    
    return PLUGIN_HANDLED
}

public effect_explosion(id)
{
    static origin[3]
    get_user_origin(id,origin,0)
    
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
    write_byte(TE_EXPLOSION2) 
    write_coord(origin[0]) //coord, coord, coord (start)
    write_coord(origin[1])
    write_coord(origin[2])
    write_byte(200) // byte (scale in 0.1's) 188 
    write_byte(10) // byte (framerate) 
    message_end()

    message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(3)
    write_coord(origin[0]) //coord, coord, coord (start)
    write_coord(origin[1])
    write_coord(origin[2])
    write_short(explosion)
    write_byte(60)
    write_byte(10)
    write_byte(0)
    message_end()
    
    return PLUGIN_HANDLED
}

public RadiusDamage(Float:Origin[3],Float:MaxDamage,Float:Radius)
{
    static id,AlivePlayers,Float:Damage//,Float:Health
    static Players[32],Float:VictimOrigin[3]
    get_players(Players,AlivePlayers,"a")
    for (new i=0;i<AlivePlayers;i++)
    {
        id=Players[i]
        pev(id,pev_origin,VictimOrigin)
        
        if(get_distance_f(Origin,VictimOrigin)<=Radius)
        {
            Damage=(MaxDamage*(1-(get_distance_f(Origin,VictimOrigin)/Radius)))
            //pev(id,pev_health,Health)
            //Health-=Damage
            
            fm_fakedamage(id,"Jetpack",Damage,0)
        }
    }
}

stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
    new class[] = "trigger_hurt"
    new entity = fm_create_entity(class)
    if (!entity)
        return 0

    new value[16]
    float_to_str(takedmgdamage * 2, value, sizeof value - 1)
    fm_set_kvd(entity, "dmg", value, class)

    num_to_str(damagetype, value, sizeof value - 1)
    fm_set_kvd(entity, "damagetype", value, class)

    fm_set_kvd(entity, "origin", "8192 8192 8192", class)
    fm_DispatchSpawn(entity)

    set_pev(entity, pev_classname, classname)
    fm_fake_touch(entity, victim)
    fm_remove_entity(entity)

    return 1
}

stock fm_create_entity(const classname[])
    return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))

stock fm_DispatchSpawn(entity)
    return dllfunc(DLLFunc_Spawn, entity)

stock fm_fake_touch(toucher, touched)
    return dllfunc(DLLFunc_Touch, toucher, touched)

stock fm_remove_entity(index)
    return engfunc(EngFunc_RemoveEntity, index)

stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
    if (classname[0])
        set_kvd(0, KV_ClassName, classname)
    else {
        new class[32]
        pev(entity, pev_classname, class, sizeof class - 1)
        set_kvd(0, KV_ClassName, class)
    }

    set_kvd(0, KV_KeyName, key)
    set_kvd(0, KV_Value, value)
    set_kvd(0, KV_fHandled, 0)

    return dllfunc(DLLFunc_KeyValue, entity, 0)
}
Any help is greatly appreciated.

Edit: Sorry for the title typo, it's Origin's.

Last edited by Murd; 05-16-2011 at 20:50. Reason: Thread Title Typo
Murd is offline
Reply



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:00.


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