AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   killing anounce (https://forums.alliedmods.net/showthread.php?t=195740)

Caldeum 09-11-2012 00:24

killing anounce
 
Anyone can help to fix thix code? if player kill 5 enemys in one round on hud will print message... after round end must count from begin.

PHP Code:

#include < amxmodx >

new kill_num32 ];
new 
g_HudMsg1;

public 
plugin_init( )
{
    
register_logevent"logevent_round_end"2"1=Round_End" );
    
register_event"DeathMsg""event_death""a""1>0" );
    
    
g_HudMsg1 CreateHudSyncObj( );
}

public 
client_connectid )
    
kill_numid ] = 0;

public 
client_disconnectid )
    
kill_numid ] = 0;

public 
logevent_round_endid )
    
kill_numid ] = 0;

public 
event_death( )
{
    static 
iKiller;
    
iKiller read_data);
    
kill_numiKiller ]++;
    
    new 
name32 ];
    
get_user_nameiKillername31 );
    
    if ( 
kill_numiKiller ] == )
    {
        
set_hudmessage5050500.070.1020.14.00.10.1, -);
        
ShowSyncHudMsg0g_HudMsg1"Wow! %s killed 5 enemys"name );
    }
    else if ( 
kill_numiKiller ] == 10 )
    {
        
set_hudmessage5050500.070.1020.14.00.10.1, -);
        
ShowSyncHudMsg0g_HudMsg1"Wow! %s killed 10 enemys"name );
        
kill_numiKiller ] = 0;
    }



Caldeum 09-11-2012 17:46

Re: killing anounce
 
anyone? :(

Alka 09-11-2012 17:49

Re: killing anounce
 
PHP Code:

public logevent_round_end()
{
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNum);

    for(new 
iNum i++)
        
kill_num[iPlayers[i]] = 0//bad practice? w/e


Also get user name only when it's needed, when he got 5 or 10 kills (inside of if condition)

guipatinador 09-12-2012 06:38

Re: killing anounce
 
Also, check if he didn't commit suicide.

Caldeum 09-12-2012 07:51

Re: killing anounce
 
Quote:

Originally Posted by guipatinador (Post 1797396)
Also, check if he didn't commit suicide.

Just wanted to write about it :D

This gonna fix?
PHP Code:

new iVictim read_data);

    if ( 
iKiller == iVictim )
        return; 


guipatinador 09-12-2012 07:56

Re: killing anounce
 
Yes.
Also, make sure that he didn't make TK.

Caldeum 09-12-2012 08:20

Re: killing anounce
 
PHP Code:

if ( cs_get_user_teamiKiller ) == cs_get_user_teamiVictim ) )
   return; 


Alka 09-12-2012 08:26

Re: killing anounce
 
or get_user_team() without the need of cstrike module :-)

Caldeum 09-12-2012 08:31

Re: killing anounce
 
ok thanks guys :)

Liverwiz 09-12-2012 08:42

Re: killing anounce
 
Code:

    else if ( kill_num[ iKiller ] == 10 )
    {
        set_hudmessage( 50, 50, 50, 0.07, 0.10, 2, 0.1, 4.0, 0.1, 0.1, -1 );
        ShowSyncHudMsg( 0, g_HudMsg1, "Wow! %s killed 10 enemys", name );
        kill_num[ iKiller ] = 0;
    }

Settting kill_num to 0 here will reset the score after 10 kills. Alive or not.
I'd also, depending what you want to do, put the the kill_num reset in event_death. This will make it so you don't need to deal with a round_start event. Allowing deathmatch servers to use this code because their rounds go on for god knows how long while the players continue to spawn.


All times are GMT -4. The time now is 08:20.

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