Raised This Month: $ Target: $400
 0% 

Mana System


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 09-01-2012 , 02:59   Mana System
Reply With Quote #1

Hey guys, I'm trying to build a plugin that gives Ts a certain amount of Mana which they can use by sending the command impulse 100. I am having a problem with set_task and remove_task

This is a function that I have to be activated every new round:

Code:
    public fwHamPlayerSpawnPost( iPlayer )
    {
        if (is_user_alive(iPlayer))
        {    
            if( cs_get_user_team( iPlayer ) == CS_TEAM_T )
            {         
                iMana[ iPlayer ] = get_pcvar_num( iManaMax );
                
                set_task( get_pcvar_float( TimeIncreaseMana ),"Mana", iPlayer, "", 0, "a", RoundTime )
                
                set_task( 1.0, "sMana", iPlayer, "", 0, "a", RoundTime );
            }
        }
        
        else
        {            
            return PLUGIN_HANDLED;
        }
    }
Then with these two commands I am trying to call another function to remove these tasks if the player dies or if the round is restarted

Code:
        register_event("DeathMsg", "removetask", "a")
        
        register_event("HLTV", "removetask", "a", "1=0", "2=0")
Code:
    public removetask( id )
    {            
        remove_task( id );
    }
This is not working though, so everytime round restarts or player dies the task starts being played over the other, making it twice as fast. How can I fix this? Thank you to anyone that helps
vitorrossi is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 09-01-2012 , 05:54   Re: Mana System
Reply With Quote #2

DeathMsg and HLTV don't have any params. Put the remove_task in Ham_Spawn and Ham_Killed.
Backstabnoob is offline
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 09-01-2012 , 15:51   Re: Mana System
Reply With Quote #3

That worked perfectly, thank you. So the reason it wasn't working before was that register_event wasn't sending the player's id to the function?

Last edited by vitorrossi; 09-01-2012 at 15:52.
vitorrossi is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 09-01-2012 , 17:02   Re: Mana System
Reply With Quote #4

Yes. In DeathMsg, both the victim and killer ID's are accessible through the read_data function; in HLTV, you need to loop through all players.
Backstabnoob is offline
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 09-01-2012 , 17:20   Re: Mana System
Reply With Quote #5

Thanks a lot for the help, I really appreciate it!
vitorrossi 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 08:21.


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