Raised This Month: $ Target: $400
 0% 

Solved Nanosuit 2x faster rachargable energy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DJBosma
Member
Join Date: Dec 2009
Old 12-24-2018 , 05:05   Nanosuit 2x faster rachargable energy
Reply With Quote #1

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?

Last edited by DJBosma; 12-25-2018 at 18:54. Reason: Solved
DJBosma is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 12-26-2018 , 06:59   Re: Nanosuit 2x faster rachargable energy
Reply With Quote #2

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.
__________________

Last edited by Black Rose; 12-26-2018 at 07:00.
Black Rose is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-26-2018 , 07:07   Re: Nanosuit 2x faster rachargable energy
Reply With Quote #3

You should show the original code and then your changes regarding this feature. The code you posted doesn't really make sense.
__________________
klippy is offline
DJBosma
Member
Join Date: Dec 2009
Old 12-26-2018 , 13:34   Re: Nanosuit 2x faster rachargable energy
Reply With Quote #4

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
    

DJBosma 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 07:34.


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