AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Nanosuit 2x faster rachargable energy (https://forums.alliedmods.net/showthread.php?t=312988)

DJBosma 12-24-2018 05:05

Nanosuit 2x faster rachargable energy
 
Well,

I've tried to modify the nanosuit so that when a player buys a option his energy will recharge faster.

This is what i've got until now

PHP Code:

new Float:energy cl_nn_energy[player]
static 
Float:energy2
energy2 
+= energy
energy2 
get_pcvar_float(pcv_nn_regenerate) * 2
cl_nn_block_recharge
[player] = energy2 += floatmin(g_nn_energy[player], energy2

Any ideas?

Black Rose 12-26-2018 06:59

Re: Nanosuit 2x faster rachargable energy
 
PHP Code:

energy2 += energy
energy2 
get_pcvar_float(pcv_nn_regenerate) * 

->
PHP Code:

energy2 get_pcvar_float(pcv_nn_regenerate) * 2
energy2 
+= energy 

?

It's impossible to understand the math of it though.

klippy 12-26-2018 07:07

Re: Nanosuit 2x faster rachargable energy
 
You should show the original code and then your changes regarding this feature. The code you posted doesn't really make sense.

DJBosma 12-26-2018 13:34

Re: Nanosuit 2x faster rachargable energy
 
I solved it already.
Here's how I did it..

PHP Code:

new g_itemindex1
new g_itemindex2
new g_has_fast_energy[MAXPLAYERS 1] = {false, ...} 

adding the items in plugin_init()

PHP Code:

g_itemindex1 zp_register_extra_item("Energy Boost \y[\r+10\y]"30ZP_TEAM_HUMAN//30
    
g_itemindex2 zp_register_extra_item("Faster Energy \d(\rx3\d)"60ZP_TEAM_HUMAN)  //60 

Making the g_itemindex1 & g_itemindex2

PHP Code:

public zp_extra_item_selected(iditemid)
{
if(
itemid == g_itemindex1) {
g_nn_energy[id] += 10
client_cmd
(id,"spk %s",regain_sound)
set_dhudmessage(255000.550.5606.06.0);
show_dhudmessage(id"+10% Energy");

ChatColor(id"!g[Fatall-Error] !yYou successfully upgraded your suit!");

}
if(
itemid == g_itemindex2)
{
if(
g_has_fast_energy[id])
{
client_print(idprint_center"You already have Fast Energy!")
return 
ZP_PLUGIN_HANDLED
}
g_has_fast_energy[id] = true

client_cmd
(id,"spk %s",regain_sound)
set_dhudmessage(55551550.550.5606.06.0);
show_dhudmessage(id"+Faster Energy");

ChatColor(id"!g[Fatall-Error] !yYou successfully upgraded your suit!");

message_begin(MSG_ONEget_user_msgid("ScreenFade"), _id)
write_short(1<<12)
write_short(1<<12)
write_short(0x0000)
write_byte(25)
write_byte(25)
write_byte(255)
write_byte(100)
message_end()
}
return 
PLUGIN_CONTINUE


And finally the energy manipulation

PHP Code:

if (energy g_nn_energy[id] && cl_nn_mode[id] != NANO_CLOAK && cl_nn_block_recharge[id] == 0)
    {
        static 
Float:energy2
        
if(g_has_fast_energy[id] && itemid == g_itemindex1)
        
energy2 3.0  //regen
        
else if (g_has_fast_energy[id])
        
energy2 3.0  //regen
        
else
        
energy2 get_pcvar_float(pcv_nn_regenerate)
        
        if (
pev(id,pev_button) & IN_DUCK && cl_nn_speed[id] == SPD_STILL)
            
energy2 *= ENERGY_CROUCH
        
        energy2 
+= energy
        
        
// Useful to block the moment when a player energy is bigger than the maximum energy
        
energy floatmin(g_nn_energy[id], energy2)
        
        if (
energy get_pcvar_float(pcv_nn_critical) + CRITICAL_EXTRA_ADD)
            
cl_nn_critical[id] = false
    




All times are GMT -4. The time now is 07:34.

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