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

Ham_Killed skipping frags?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 01-05-2017 , 12:19   Ham_Killed skipping frags?
Reply With Quote #1

I have a simple ace & semi-ace display in a mix plugin.
Relevant code
PHP Code:
RegisterHam(Ham_Killed"player""player_killed"1);

public 
player_killed(victimattackershouldgib)
{
        if(
is_user_connected(victim) && is_user_connected(attacker) && attacker!=victim)
        {
            if((
cs_get_user_team(attacker)==CS_TEAM_CT && cs_get_user_team(victim)==CS_TEAM_T) || (cs_get_user_team(attacker)==CS_TEAM_T && cs_get_user_team(victim)==CS_TEAM_CT))
            {
                
g_frags[attacker]++;
            }
            
        }
}

public 
round_ended()//called from eT_win() and eCT_win()
{
    new 
iPlayers[32], iNumplayername[32];
    
get_players(iPlayers,iNum);
    for(new 
i=0;i<iNum;i++)
    {
        
player iPlayers[i];
        if(
cs_get_user_team(player)==CS_TEAM_T || cs_get_user_team(player)==CS_TEAM_CT)
        {
            if(
g_frags[player]==4)
            {
                
get_user_name(playername31);
                
chat_color(0,".v%s .gJucatorul .e%s .ga realizat un .eSEMI-ACE.g!",PREFIX,name);
            }
            else if(
g_frags[player]==5)
            {
                
get_user_name(playername31);
                
chat_color(0,".v%s .gJucatorul .e%s .ga realizat un .eACE.g!",PREFIX,name);
            }
            
g_frags[player] = 0;
        }
    }

g_frags[] is also set to 0 on Ham_Spawn post as well as on round_start
PHP Code:
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1);
register_logevent("round_start"2"0=World triggered""1=Round_Start"); 

TL;DR:
frag counter increments on Ham_Killed
frag counter is reset at round_end (at sendaudio terwin&ctwin)
frag counter is reset at ham spawn post
frag counter is reset at round_start, when freezetime ends

on round end (at sendaudio terwin&ctwin), a player with 5 kills has "semi-ace" displayed in picture below



Am I missing something? Haven't found a way to reproduce the bug. Do nade kills count in ham_killed ?
EDIT:: This happened on 1st round after team switch, aka the 16th round of the game. I know there used to be some weird bug with players showing up in the wrong team until a respawn, not sure which functions were affected though or whether this might be the case, could be it when checking if a frag is valid.
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 01-05-2017 at 12:27.
aron9forever is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 01-05-2017 , 12:59   Re: Ham_Killed skipping frags?
Reply With Quote #2

Poop, I just noticed something, might be that the win sounds are triggered before the kill post, therefore if the player's 4th frag kills the last enemy, round end will be called before the 4th frag gets added so nothing will be displayed; would also explain why ace shows as semi-ace.

Should I switch to pre kill? With the existing code, would that work fine?
Should I use some other hook to count the frags?
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 01-05-2017 at 13:01.
aron9forever is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-05-2017 , 16:49   Re: Ham_Killed skipping frags?
Reply With Quote #3

No Ham_Killed doesn't get called on grenades. Use DeathMsg ?
__________________

Last edited by edon1337; 01-05-2017 at 16:49.
edon1337 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-05-2017 , 18:01   Re: Ham_Killed skipping frags?
Reply With Quote #4

I don't know if the Ham_Killed doesn't get called on grenades, you can search for learn more about it, if your current code doesn't work, just change him, use DeathMsg as edon said.

And

PHP Code:
if((cs_get_user_team(attacker)==CS_TEAM_CT && cs_get_user_team(victim)==CS_TEAM_T) || (cs_get_user_team(attacker)==CS_TEAM_T && cs_get_user_team(victim)==CS_TEAM_CT)) 
LOL, you just need this:

PHP Code:
if(cs_get_user_team(attacker) != cs_get_user_team(victim)) 
Here

PHP Code:
if(cs_get_user_team(player)==CS_TEAM_T || cs_get_user_team(player)==CS_TEAM_CT
Just add the flag 'e' on get_players()

Like this

PHP Code:
get_players(iPlayers,iNum,"e"
Here's the API - https://www.amxmodx.org/api/amxmodx/get_players
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-05-2017 at 18:02.
EFFx is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-05-2017 , 19:21   Re: Ham_Killed skipping frags?
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
No Ham_Killed doesn't get called on grenades. Use DeathMsg ?
That seems unlikely. Being killed by a grenade means that the entity needs to die which is done with Ham_Killed.
__________________
fysiks is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-05-2017 , 19:30   Re: Ham_Killed skipping frags?
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
No Ham_Killed doesn't get called on grenades. Use DeathMsg ?


PHP Code:
#include <amxmodx>
#include <hamsandwich>

public plugin_init() 
{
    
RegisterHamHam_Killed "player" "HamKilled" );
}

public 
HamKillediPlayer iKiller iShouldGib )
{
    
client_printprint_chat "you were killed" );

__________________
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-05-2017 , 20:11   Re: Ham_Killed skipping frags?
Reply With Quote #7

PHP Code:
client_printprint_chat "you were killed" ); 
->

PHP Code:
client_printiKiller print_chat "you were killed" ); 
:*
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-05-2017 , 21:50   Re: Ham_Killed skipping frags?
Reply With Quote #8

Quote:
Originally Posted by EFFx View Post
PHP Code:
client_printprint_chat "you were killed" ); 
->

PHP Code:
client_printiKiller print_chat "you were killed" ); 
:*


I used 0 on purpose. What does it matter? I was proving a point. I should have printed "grenade kill" instead of "you were killed" but I wrote this quickly. Either way, the goal was to show that the event fires on grenade kills, which it does.
__________________

Last edited by Bugsy; 01-05-2017 at 21:57.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-05-2017 , 22:02   Re: Ham_Killed skipping frags?
Reply With Quote #9

Dude, I'm kidding with you, sorry if you don't got it. Obviously I knew it was a purpose.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-05-2017 at 22:03.
EFFx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-06-2017 , 07:43   Re: Ham_Killed skipping frags?
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
That seems unlikely. Being killed by a grenade means that the entity needs to die which is done with Ham_Killed.
Weird, I've read that Ham_Killed doesn't get called on grenades.
__________________
edon1337 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 23:47.


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