Raised This Month: $51 Target: $400
 12% 

Regeneration not stacking (How?)


Post New Thread Reply   
 
Thread Tools Display Modes
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-03-2010 , 06:09   Re: Regeneration not stacking (How?)
Reply With Quote #41

Hard to say right now, as I am in school and I don't really have time to really look at the code. If no one has looked at it when I get home (about 1 hour) I might take a closer look at it. It seems like it needs a bit changing in the hero init, not sure thou.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 11-03-2010 , 07:17   Re: Regeneration not stacking (How?)
Reply With Quote #42

Good to hear you are doing your schoolwork while in school and absolutely not anything else
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-03-2010 , 07:33   Re: Regeneration not stacking (How?)
Reply With Quote #43

I always pay good attention to what the teacher has to say, obviously.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 11-03-2010 , 09:08   Re: Regeneration not stacking (How?)
Reply With Quote #44

Of course, everyone does.
@ Art, theres no point in compiling as I didn't even finnish it.
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-03-2010 , 18:13   Re: Regeneration not stacking (How?)
Reply With Quote #45

Okay, I found the problem. I really didn't see it before I was about to re-write it.

You have passed on a symbol called "id" in your regen_loop, but you do not pass on anything called id in the task you set. I assume you want it to be a player id. It can't just find a player id out of no where. I re-wrote the whole thing, and it might not be the most optimized ways of doing it, but I believe this should get the job done.
As you have no id in the loop, you can't check nobody's armor, and that is probably why it wont work.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <superheromod>

new gHeroName[] = "Regen"

//bool for heroes
new bool:gHasRegen[SH_MAXSLOTS+1]
new 
bool:gHasWolv[SH_MAXSLOTS+1]
new 
bool:gHasDarth[SH_MAXSLOTS+1]
new 
bool:gHasRiddick[SH_MAXSLOTS+1]

//Hero ID's
new gHeroID
new WolvID
new darthID
new riddickID

//pcvars
new pcvarHPHeal
new pcvarAPHeal

public plugin_init()
{
    
register_plugin("SUPERHERO Regen""1.0""Exploited/Jelle")
    
    new 
pcvarLevel register_cvar("regen_level""10")
    
pcvarHPHeal register_cvar("regen_healhp""30")
    
pcvarAPHeal register_cvar("regen_healap""30")
    
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Regeneration""High speed regeneration!")
    
    
set_task(1.0"regen_loop"___"b")
}

public 
plugin_cfg()
{
    
WolvID sh_get_hero_id("Wolverine")
    
darthID sh_get_hero_id("Darth Maul")
    
riddickID sh_get_hero_id("Riddick")
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID == heroID )
    {
        switch(
mode)
        {
            case 
SH_HERO_ADD:
            {
                
gHasRegen[id] = true
            
}
            
            case 
SH_HERO_DROP:
            {
                
gHasRegen[id] = false
            
}
        }
    }
    
    else if ( 
WolvID == heroID )
    {
        switch(
mode)
        {
            case 
SH_HERO_ADD:
            {
                
gHasWolv[id] = true
            
}
            
            case 
SH_HERO_DROP:
            {
                
gHasWolv[id] = false
            
}
        }
    }
    
    else if ( 
darthID == heroID )
    {
        switch(
mode)
        {
            case 
SH_HERO_ADD:
            {
                
gHasDarth[id] = true
            
}
            
            case 
SH_HERO_DROP:
            {
                
gHasDarth[id] = false
            
}
        }
    }
    
    else if ( 
riddickID == heroID )
    {
        switch(
mode)
        {
            case 
SH_HERO_ADD:
            {
                
gHasRiddick[id] = true
            
}
            
            case 
SH_HERO_DROP:
            {
                
gHasRiddick[id] = false
            
}
        }
    }
}

public 
regen_loop()
{
    if ( !
sh_is_active() ) return
    
    new 
players[SH_MAXSLOTS], playerCountplayeri
    get_players
(playersplayerCount"ah")
    
    for ( 
0playerCounti++ )
    {
        
player players[i]
        
        
//return if user has either one or more of the healing heroes
        
if ( gHasWolv[player] || gHasDarth[player] || gHasRiddick[player] ) return
        
        if ( 
gHasRegen[player] )
        {
            
sh_add_hp(playerget_pcvar_num(pcvarHPHeal) )
            new 
userArmor get_user_armor(player) + get_pcvar_num(pcvarAPHeal)
            
cs_set_user_armor(playeruserArmorCS_ARMOR_KEVLAR )
        }
    }

Why didn't I went with cs_get_user_armor when I use cs_set_user_armor? Well simply because I kept getting tag mismatch, as it seems like cs_get_user_armor can only get one type of armor, either west + helm or only west. Anyone knows about that?

EDIT:
I know if I don't add this, G-Dog and fr33m@n will be on my back about it, so here it is:

You can also do it this way in the hero init:

PHP Code:
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID == heroID )
    {
        
gHasRegen[id] = mode true false
    
}
    
    else if ( 
WolvID == heroID )
    {
        
gHasWolv[id] = mode true false
    
}
    
    else if ( 
darthID == heroID )
    {
        
gHasDarth[id] = mode true false
    
}
    
    else if ( 
riddickID == heroID )
    {
        
gHasRiddick[id] = mode true false
    
}

Then you just won't have the possibility to go to a forward if the user picks/drops the hero. If you want to use the hero as I posted, use this way of setting the Booleans to true or false, as that is the most efficient.
__________________
No idea what to write here...

Last edited by Jelle; 11-03-2010 at 18:23.
Jelle is offline
Send a message via MSN to Jelle
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 11-03-2010 , 20:20   Re: Regeneration not stacking (How?)
Reply With Quote #46

Quote:
Originally Posted by Jelle View Post
You can also do it this way in the hero init:

PHP Code:
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID == heroID )
    {
        
gHasRegen[id] = mode true false
    
}
    
    else if ( 
WolvID == heroID )
    {
        
gHasWolv[id] = mode true false
    
}
    
    else if ( 
darthID == heroID )
    {
        
gHasDarth[id] = mode true false
    
}
    
    else if ( 
riddickID == heroID )
    {
        
gHasRiddick[id] = mode true false
    
}

This is where a switch would be better
Code:
public sh_hero_init(id, heroID, mode)
{
	switch(heroID)
	{
		case gHeroID: gHasRegen[id] = mode ? true : false
		case WolvID: gHasWolv[id] = mode ? true : false
		case darthID: gHasDarth[id] = mode ? true : false
		case riddickID: gHasRiddick[id] = mode ? true : false
	}
}

Last edited by vittu; 11-03-2010 at 21:39.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-03-2010 , 20:35   Re: Regeneration not stacking (How?)
Reply With Quote #47

Oh yeah. I see. I was just not sure how to do it.

Actually, using such switch, you don't really need the ID of well, "gHeroID" would you? I don't see you using it anywhere.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 11-03-2010 , 21:39   Re: Regeneration not stacking (How?)
Reply With Quote #48

Quote:
Originally Posted by Jelle View Post
"gHeroID" would you? I don't see you using it anywhere.
oops, fixed above...
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 11-04-2010 , 02:27   Re: Regeneration not stacking (How?)
Reply With Quote #49

Quote:
Originally Posted by vittu View Post
This is where a switch would be better
Code:
public sh_hero_init(id, heroID, mode)
{
	switch(heroID)
	{
		case gHeroID: gHasRegen[id] = mode ? true : false
		case WolvID: gHasWolv[id] = mode ? true : false
		case darthID: gHasDarth[id] = mode ? true : false
		case riddickID: gHasRiddick[id] = mode ? true : false
	}
}
ya that would be better if only switch didn't require it to be a constant expression, but alas can't use variables in a switch statement like that
__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 11-04-2010 , 14:40   Re: Regeneration not stacking (How?)
Reply With Quote #50

true, i experienced that too.
Fr33m@n 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 13:12.


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