AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Kill Counter (https://forums.alliedmods.net/showthread.php?t=336380)

Arje 02-15-2022 10:54

Kill Counter
 
Hello, I would like to make a counter with my kills, but also that it counts every time a teammate dies

Currently it only counts every time I kill someone, and every time someone on the other team dies, and I would like it to only count my kills and when someone on my team dies

PHP Code:

new g_KillCount 0

//----------------------------------------------------------------------------------------------
public client_death(victimattacker)
{
    if ( 
victim == attacker ) return
    
    new 
CsTeams:attackerTeam cs_get_user_team(attacker)
    new 
CsTeams:victimTeam cs_get_user_team(victim)
    
    if ( 
is_user_alive(attacker) || victimTeam != attackerTeam ) {
        
g_KillCount g_KillCount 1
            client_print
(attackerprint_chatYou have %i kills.", g_KillCount)
    } 



OciXCrom 02-15-2022 13:36

Re: Kill Counter
 
Then remove the part of the code that checks the team?

Supremache 02-15-2022 13:37

Re: Kill Counter
 
Take example:
PHP Code:

new g_iPlayerKillsMAX_PLAYERS ]

register_event"DeathMsg""OnPlayerKilled""a" )

public 
OnPlayerKilled( )
{
    new 
iAttacker read_data), iVictim read_data)
        
    if( 
is_user_connectediAttacker ) && iAttacker != iVictim )
    {
        
g_iPlayerKillsiAttacker ]++;
        
client_print_coloriAttackerprint_team_default"Your Kills: %i"g_iPlayerKillsiAttacker ] )
    }



Arje 02-15-2022 17:15

Re: Kill Counter
 
I think I did not explain well.

I want that if I am tt(or ct) and kill one of the other team: g_KillCount + 1
I already achieved this, it's easy to do

but i want besides that, that when someone of my team dies, (for example if I am tt, if another tt dies) too: g_KillCount + 1

I don't know if I explain it better now, but I can try again, excuse me for my english.

Supremache 02-15-2022 19:21

Re: Kill Counter
 
Quote:

Originally Posted by Arje (Post 2771566)
I think I did not explain well.

I want that if I am tt(or ct) and kill one of the other team: g_KillCount + 1
I already achieved this, it's easy to do

but i want besides that, that when someone of my team dies, (for example if I am tt, if another tt dies) too: g_KillCount + 1

I don't know if I explain it better now, but I can try again, excuse me for my english.

Want to increase "g_KillCount" when you or someone on your team dies? If yes, then create a loop with get_players

Natsheh 02-16-2022 07:16

Re: Kill Counter
 
Quote:

Originally Posted by Supremache (Post 2771550)
Take example:
PHP Code:

new g_iPlayerKillsMAX_PLAYERS ]

register_event"DeathMsg""OnPlayerKilled""a" )

public 
OnPlayerKilled( )
{
    new 
iAttacker read_data), iVictim read_data)
        
    if( 
is_user_connectediAttacker ) && iAttacker != iVictim )
    {
        
g_iPlayerKillsiAttacker ]++;
        
client_print_coloriAttackerprint_team_default"Your Kills: %i"g_iPlayerKillsiAttacker ] )
    }



Don't hook DeathMsg to count the killer kills, hook the player killed post event and do the count, DeathMsg could be blocked by other various plugins.


All times are GMT -4. The time now is 11:35.

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