Raised This Month: $32 Target: $400
 8% 

Need help for powers code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.J
Senior Member
Join Date: Sep 2017
Location: cs_assault
Old 01-02-2018 , 07:52   Need help for powers code
Reply With Quote #1

Hi, sorry for my bad english
im using zombie mod with class, can anyone help me with this code :
PHP Code:
public AddHealth(id)
{
    
set_user_health(idget_user_health(id) + (20*HealthLevel[id]));
    
    if(
get_user_health(id) > 100.0)
        
MaxHealth[id] = get_user_health(id);
        
    else
        
MaxHealth[id] = 100;
        
    
Refreshing[id] = false;
}
public 
NeverEndingRegen()
{
    new 
players[32], num;
    
get_players(playersnum"ach");
    
    for(new 
id;id num;id++)
    {
        new 
players[id];
        if(
RegenLevel[i] > && !Refreshing[id])
        {
            if((
get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(iMaxHealth[i]);
            else 
set_user_health(iget_user_health(i) + RegenLevel[i]);
        }
    }

when i buy this power (HP regenaration) , when i become zombie my HP set to 100 and to know that my zombie HP are 5000 ,and every class have her own health
Note : there is no include file for this mod.
Mr.J is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 01-02-2018 , 08:13   Re: Need help for powers code
Reply With Quote #2

Quote:
Originally Posted by Mr.J View Post
Hi, sorry for my bad english
im using zombie mod with class, can anyone help me with this code :
PHP Code:
public AddHealth(id)
{
    
set_user_health(idget_user_health(id) + (20*HealthLevel[id]));
    
    if(
get_user_health(id) > 100.0)
        
MaxHealth[id] = get_user_health(id);
        
    else
        
MaxHealth[id] = 100;
        
    
Refreshing[id] = false;
}
public 
NeverEndingRegen()
{
    new 
players[32], num;
    
get_players(playersnum"ach");
    
    for(new 
id;id num;id++)
    {
        new 
players[id];
        if(
RegenLevel[i] > && !Refreshing[id])
        {
            if((
get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(iMaxHealth[i]);
            else 
set_user_health(iget_user_health(i) + RegenLevel[i]);
        }
    }

when i buy this power (HP regenaration) , when i become zombie my HP set to 100 and to know that my zombie HP are 5000 ,and every class have her own health
Note : there is no include file for this mod.
ther is no misstake in the code...
because as i see it show when get user health more then 100 as 500 it set him max health to 500
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
Adomaz1
Senior Member
Join Date: Feb 2014
Old 01-02-2018 , 08:23   Re: Need help for powers code
Reply With Quote #3

Code:
public AddHealth(id) {
	new team = cs_get_user_team(id);
	if(team == CS_TEAM_T)
		return
	
	set_user_health(id, get_user_health(id) + (20*HealthLevel[id])); 
	
	if(get_user_health(id) > 100.0) MaxHealth[id] = get_user_health(id); 
	else MaxHealth[id] = 100;
	
	Refreshing[id] = false;
} 

public NeverEndingRegen() {	
	new players[32], num; 
	get_players(players, num, "ach"); 
	
	for(new id;id < num;id++) { 
		new i = players[id]; 
		if(RegenLevel[i] > 0 && !Refreshing[id]) { 
			if((get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(i, MaxHealth[i]); 
			else set_user_health(i, get_user_health(i) + RegenLevel[i]); 
		} 
	} 
}

Last edited by Adomaz1; 01-02-2018 at 08:45.
Adomaz1 is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 01-02-2018 , 08:30   Re: Need help for powers code
Reply With Quote #4

Quote:
Originally Posted by Adomaz1 View Post
Code:
public AddHealth(id) {
	new team = cs_get_user_team(id);
	if(team == CS_TEAM_T)
		return
	
	set_user_health(id, get_user_health(id) + (20*HealthLevel[id])); 
	
	if(get_user_health(id) > 100.0) MaxHealth[id] = get_user_health(id); 
	else MaxHealth[id] = 100;
	
	Refreshing[id] = false;
} 

public NeverEndingRegen() {
	new team = cs_get_user_team(id);
	if(team == CS_TEAM_T)
		return
	
	new players[32], num; 
	get_players(players, num, "ach"); 
	
	for(new id;id < num;id++) { 
		new i = players[id]; 
		if(RegenLevel[i] > 0 && !Refreshing[id]) { 
			if((get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(i, MaxHealth[i]); 
			else set_user_health(i, get_user_health(i) + RegenLevel[i]); 
		} 
	} 
}
just a question o_O what you done now is maked the code work for CT only but i gess he want for T also get a HP+...
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
Old 01-02-2018, 08:38
Adomaz1
This message has been deleted by Adomaz1.
Adomaz1
Senior Member
Join Date: Feb 2014
Old 01-02-2018 , 08:46   Re: Need help for powers code
Reply With Quote #5

Quote:
Originally Posted by D3XT3R View Post
just a question o_O what you done now is maked the code work for CT only but i gess he want for T also get a HP+...
did he mention that this is for zombies ONLY, or are you just guessing?

Last edited by Adomaz1; 01-02-2018 at 08:49.
Adomaz1 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 01-02-2018 , 09:03   Re: Need help for powers code
Reply With Quote #6

Try this... and come back with results
Code:
public AddHealth(id){     if (is_user_alive(id)) return 0;     set_user_health(id, get_user_health(id) + (20*HealthLevel[id]));     Refreshing[id] = false; } public NeverEndingRegen(id){     if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && !Refreshing[id]) return 0;         set_user_health(id, get_user_health(id) + RegenLevel[id]); }
Quote:
Removed MaxHealth[id] - why? Useless. HealthLevel[id] can't be lower than 0
Removed get_players - why? No need to get players, we use statements.
Don't create a var if it will be used once only.
RegenLevel[id] should be higher than 0. No need to use statements for it.
if((get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(i, MaxHealth[i])
- if MaxHealth[id] + RegenLevel[id] > MaxHealth[id], returns always true.
__________________

Last edited by Relaxing; 01-02-2018 at 09:08.
Relaxing is offline
Mr.J
Senior Member
Join Date: Sep 2017
Location: cs_assault
Old 01-02-2018 , 10:39   Re: Need help for powers code
Reply With Quote #7

Quote:
Originally Posted by Adomaz1 View Post
Code:
public AddHealth(id) {
	new team = cs_get_user_team(id);
	if(team == CS_TEAM_T)
		return
	
	set_user_health(id, get_user_health(id) + (20*HealthLevel[id])); 
	
	if(get_user_health(id) > 100.0) MaxHealth[id] = get_user_health(id); 
	else MaxHealth[id] = 100;
	
	Refreshing[id] = false;
} 

public NeverEndingRegen() {	
	new players[32], num; 
	get_players(players, num, "ach"); 
	
	for(new id;id < num;id++) { 
		new i = players[id]; 
		if(RegenLevel[i] > 0 && !Refreshing[id]) { 
			if((get_user_health(i) + RegenLevel[i]) > MaxHealth[i]) set_user_health(i, MaxHealth[i]); 
			else set_user_health(i, get_user_health(i) + RegenLevel[i]); 
		} 
	} 
}
same problem , zombies regen HP to maxim 100 HP and their HP are 100 (exactly like CT)

Quote:
Originally Posted by Relaxing View Post
Try this... and come back with results
Code:
public AddHealth(id){     if (is_user_alive(id)) return 0;     set_user_health(id, get_user_health(id) + (20*HealthLevel[id]));     Refreshing[id] = false; } public NeverEndingRegen(id){     if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && !Refreshing[id]) return 0;         set_user_health(id, get_user_health(id) + RegenLevel[id]); }
i cant compile, here the compile messages :

powers.sma <114> :warning 209: function "AddHealth" should return a value
PHP Code:
    Refreshing[id] = false;

powers.sma <158> : error 017: undefined symbol "id"
PHP Code:
    if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && !Refreshing[id]) return 0
powers.sma <160> : error 017: undefined symbol "id"
PHP Code:
    set_user_health(idget_user_health(id) + RegenLevel[id]); 
Another one :
powers.sma <160> : error 017: undefined symbol "id"
PHP Code:
    set_user_health(idget_user_health(id) + RegenLevel[id]); 
powers.sma <161> :warning 209: function "NeverEndingRegen" should return a value
PHP Code:
    Refreshing[id] = false;

Mr.J is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 01-02-2018 , 11:45   Re: Need help for powers code
Reply With Quote #8

So this code is part of an extra item or zombie class code?
zmd94 is offline
Mr.J
Senior Member
Join Date: Sep 2017
Location: cs_assault
Old 01-02-2018 , 11:55   Re: Need help for powers code
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
So this code is part of an extra item or zombie class code?
No its for gunxpmod
Mr.J is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 01-02-2018 , 11:56   Re: Need help for powers code
Reply With Quote #10

Quote:
Originally Posted by zmd94 View Post
So this code is part of an extra item or zombie class code?
gunxpmod powers and an oldest version in world )))) since 2011-2012
__________________

Last edited by D3XT3R; 01-03-2018 at 03:58. Reason: maked the version date right
D3XT3R is offline
Send a message via Skype™ to D3XT3R
Reply


Thread Tools
Display Modes

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 19:18.


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