Raised This Month: $ Target: $400
 0% 

DeathMsg is running more than once?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-12-2010 , 07:08   DeathMsg is running more than once?
Reply With Quote #1

Hi,

I would like to count specific death, but for some reason, the counter sometimes increased by more than one point. Any ideas?

Here is the code
PHP Code:
public plugin_init(){
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_event("DeathMsg""event_death_message""a")
    
register_event("TextMsg""event_round_restart""a""2=#Game_Commencing""2=#Game_will_restart_in")
    
register_logevent("event_round_start"2"0=World triggered""1=Round_Start")
}

public 
client_damage(iAttackeriVictimiDamageiWeaponiHitplaceTA){
    if (
iAttacker && iVictim){
        
g_iHits[iAttacker][iVictim]++
    }
}

public 
event_death_message(){
    new 
iKiller read_data(1)
    new 
iVictim read_data(2)
    if (!
iKiller || !iVictim){
        return 
PLUGIN_CONTINUE
    
}

    new 
szWeapon[20], iHeadshot read_data(3)
    
read_data(4szWeapon19)

    if (
get_user_team(iKiller) != get_user_team(iVictim)){

        if (
equal(szWeapon"p228") || equal(szWeapon"usp") || equal(szWeapon"glock18") || equal(szWeapon"fiveseven") || equal(szWeapon"elites") || equal(szWeapon"deagle")){
            
g_iPistolKills[iKiller]++
        }

        if (
equal(szWeapon"knife")){
            
g_iKnifeKills[iKiller]++
        }
    }

    
g_iPistolKills[iVictim] = 0
    g_iKnifeKills
[iVictim] = 0

    
return PLUGIN_CONTINUE

Leon M. is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-12-2010 , 09:47   Re: DeathMsg is running more than once?
Reply With Quote #2

You should check if iKiller != iVictim.
__________________
hleV is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-12-2010 , 10:02   Re: DeathMsg is running more than once?
Reply With Quote #3

Quote:
Originally Posted by hleV View Post
You should check if iKiller != iVictim.
Why? I check the teams, I think this is enough.
Leon M. is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-12-2010 , 12:34   Re: DeathMsg is running more than once?
Reply With Quote #4

I don't see anything wrong.
You could make an else for knife check though, because both condition shouldn't be possible at the same time.
Also, you should really consider the use of a Trie to store pistols names.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-12-2010 , 13:30   Re: DeathMsg is running more than once?
Reply With Quote #5

Hmm, thanks

However, I must learn something about Trie before I can use them.
Leon M. is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-12-2010 , 14:45   Re: DeathMsg is running more than once?
Reply With Quote #6

Quote:
Originally Posted by Leon M. View Post
Why? I check the teams, I think this is enough.
It's not enough. You check if killer and victim's teams are equal. If killer is victim, teams will be the same too.
__________________
hleV is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-12-2010 , 15:40   Re: DeathMsg is running more than once?
Reply With Quote #7

Yeah, and the counters won't increased.
Leon M. is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-16-2010 , 09:23   Re: DeathMsg is running more than once?
Reply With Quote #8

Hi, I did not need to start a new thread. I only have a short question about the use of trie. Can someone show me examples about using of the celltrie.inc?

I must create and set a trie, and I must delete some informations!

Many Thanks in advance
Leon
Leon M. 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 03:38.


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