Raised This Month: $ Target: $400
 0% 

Checks fail all the time?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-03-2010 , 13:33   Checks fail all the time?
Reply With Quote #1

I don't know where to post this since it is a mix of SH mod and ZP mod, and I hope you guys in here can help me.

What I want to do, is to make a check to see if a player is a zombie or not, if he is, then set the SH powers. If I do this, it works, but ofc. for both zombie and survivor:

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

#include <superheromod>
#include <zombieplague>

new gHeroID
new const gHeroName [] = "Test"
new bool:gHasTest[SH_MAXSLOTS+1]
//pcvars
new pcvarHealthpcvarArmor

public plugin_init()
{
    
register_plugin("SUPERHERO Test""1.0""Jelle")
    
    
//cvars
    
new pcvarLevel register_cvar("test_level""5")
    
pcvarHealth register_cvar("test_health""2000")
    
pcvarArmor register_cvar("test_armor""2000")
    
    
//create hero and hero info
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Test""Testing")
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return
    
    switch(
mode)
    {
        case 
SH_HERO_ADD:
        {
            
gHasTest[id] = true
            set_power
(id)
        }
        case 
SH_HERO_DROP:
        {
            
gHasTest[id] = false
        
}
    }
}

public 
sh_client_spawn(id)
{
    
set_power(id)
}

set_power(id)
{
    if (
gHasTest[id] && is_user_alive(id))
    {
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor)
    }

Then I tried this:

PHP Code:
set_power(id)
{
    if (
gHasTest[id] && is_user_alive(id) && zp_get_user_survivor(id))
    {
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor)
    }

This gave no help also. Then I tried with a task, since the zombie is found about 10 - 15 seconds in the game, but that did not work either. Then I tried this:

PHP Code:
set_power(id)
{
    if (
zp_get_user_zombie(id) && zp_get_user_nemesis(id)) return
    
    if (
gHasTest[id] && is_user_alive(id))
    {
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor)
    }

This did not help either. So now I turn to you guys, do you have any suggestions?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-03-2010 , 18:59   Re: Checks fail all the time?
Reply With Quote #2

Quote:
Originally Posted by Jelle View Post
What I want to do, is to make a check to see if a player is a zombie or not, if he is, then set the SH powers. If I do this, it works, but ofc. for both zombie and survivor:
PHP Code:
set_power(id

    if(
is_user_alive(id) && gHasTest[id] && zp_get_user_zombie(id)) 
    { 
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor
    } 

__________________
fysiks is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-04-2010 , 07:45   Re: Checks fail all the time?
Reply With Quote #3

Thank you, but that will set the SH powers if the guy is a zombie, but I want it to be only on humans.

The survivor check doesn't work, since it is only the last man standing which becomes a survivor, all others are humans, and there are no checks for that, which is why I did this:

PHP Code:
set_power(id

    if (
zp_get_user_zombie(id) && zp_get_user_nemesis(id)) return 
     
    if (
gHasTest[id] && is_user_alive(id)) 
    { 
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor
    } 

So survivors and humans get powers, but it still wont work. If I remove

PHP Code:
if (zp_get_user_zombie(id) && zp_get_user_nemesis(id)) return 
it works, and sets the hero powers, but then zombies get the power too, which I do not want.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 17:51   Re: Checks fail all the time?
Reply With Quote #4

Quote:
Originally Posted by Jelle View Post
What I want to do, is to make a check to see if a player is a zombie or not, if he is [a zombie], then set the SH powers. If I do this, it works, but ofc. for both zombie and survivor
Quote:
Originally Posted by Jelle View Post
Thank you, but that will set the SH powers if the guy is a zombie, but I want it to be only on humans.
There must have been a typo in your originaly request.

PHP Code:
set_power(id

    if (!
zp_get_user_zombie(id) && is_user_alive(id)) 
    { 
        
sh_set_hero_hpap(gHeroIDpcvarHealthpcvarArmor
    } 

I'm a bit confused as to why you pass "id" and do checks for it but then you set the attributes for everybody with that Hero? (Keep in mind I'm not fully aware of how this Hero stuff works)
__________________
fysiks is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-04-2010 , 18:28   Re: Checks fail all the time?
Reply With Quote #5

There was a typo yes, sorry for that.

To clarify what I meant:

I want to set the hero powers using this native, if they are humans or survivors.

Basically, in SH mod, we put sh_set_hero_hpap in plugin_init(), which has no id, and I can therefor not add any checks before I set it. Now I just want to add a check before the hero powers are applied. The native pretty much explains itself. It sets the extra health and armor accordingly to the pcvars specified.

I am passing id, because I want to check the player who just spawned (in sh_client_spawn(id) and in sh_hero_init())

The thing is, I did it this way:

PHP Code:
if (zp_get_user_zombie(id) && zp_get_user_nemesis(id)) return 
which I see is the same as

PHP Code:
if (!zp_get_user_zombie(id) && is_user_alive(id)) 
I can try it with the ! in front, but to be honest, I do not think it will work.

Some more reading:
I tried adding this check before a model is set using a superhero:

PHP Code:
if (zp_get_user_zombie(id) && zp_get_user_nemesis(id)) return 
and it works, there is no model on the zombie. If I delete this check, I have wolverine-like knife, if I add it, I have normal zombie knife when zombie.

All I need now is the hero setting of hp/ap/gravity/damage multiplier.
To do this, it uses closely the same as the SH native where I set health and armor, and they should also be done in plugin_init().

I am totally stuck on why this wont work.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 19:25   Re: Checks fail all the time?
Reply With Quote #6

It still makes no sense to set the attributes everytime that a human spawns for something that doesn't differ between two players that are the same "hero".

Also, your use of pcvars is totally wrong.
__________________
fysiks is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-04-2010 , 19:31   Re: Checks fail all the time?
Reply With Quote #7

If I do it in plugin_init() it will also set the attributes when you spawn, I just need a check to see if he is a zombie, if not, then set these powers.
And as said before, if I delete the zp checks totally, it works as it should, and set HP/AP on all players if they have this hero.

What is wrong with my pcvars?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 19:35   Re: Checks fail all the time?
Reply With Quote #8

pcvarHealth and pcvarArmor are cvar pointers and not the value of the cvar.
__________________
fysiks is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-04-2010 , 19:41   Re: Checks fail all the time?
Reply With Quote #9

That I did not catch. I have always been using this method, also for radius of a blast or something like that. The sh native ask for the pcvars and reads the values:

Code:
/**
 * Sets hero's max Health and Armor. (Optional)
 * Health and Armor do not stack, values from heroes are compared and greatest is applied.
 *
 * @note		If you only want to set one of the values, set the other to 0 or underscore "_" to use the default set value of 0.
 *
 * @param heroID	The index of the hero.
 * @param pcvarHealth	The pcvar value for maximum Health CVAR for the hero, CVAR values below 100 are ignored.
 * @param pcvarArmor	The pcvar value for maximum Armor CVAR for the hero.
 * @noreturn
 */
native sh_set_hero_hpap(heroID, pcvarHealth = 0, pcvarArmor = 0);
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 19:54   Re: Checks fail all the time?
Reply With Quote #10

Quote:
Originally Posted by Jelle View Post
That I did not catch. I have always been using this method, also for radius of a blast or something like that. The sh native ask for the pcvars and reads the values:

Code:
/**
 * Sets hero's max Health and Armor. (Optional)
 * Health and Armor do not stack, values from heroes are compared and greatest is applied.
 *
 * @note		If you only want to set one of the values, set the other to 0 or underscore "_" to use the default set value of 0.
 *
 * @param heroID	The index of the hero.
 * @param pcvarHealth	The pcvar value for maximum Health CVAR for the hero, CVAR values below 100 are ignored.
 * @param pcvarArmor	The pcvar value for maximum Armor CVAR for the hero.
 * @noreturn
 */
native sh_set_hero_hpap(heroID, pcvarHealth = 0, pcvarArmor = 0);
Oh, umm, that description is confusing. It says pcvar value and not "cvar pointer" which makes kinda vague. The person that wrote that needs to reword it.
__________________

Last edited by fysiks; 05-04-2010 at 19:57.
fysiks is offline
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 03:36.


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