AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] XXX Times kills (https://forums.alliedmods.net/showthread.php?t=139863)

One 10-06-2010 06:49

[SOLVED] XXX Times kills
 
hi,

i tried to write a plugin to showes messages by kills. now i have no idea to show how manytimes is a user killed by the same user.

for example :

Quote:

[AMX] You are kiled by XXX! He has XX HP & XX AP. ( XX Times kills )
Quote:

[AMX] You killed XXX! ( XX Times Kills )
here is my code.
i just want to have a idea how to catch how manytimes is a player killed by the same Killer & how manytimes killed the killer the same Victim.

here is my code.

PHP Code:

#include <amxmodx>

new g_iMaxPlayers

public plugin_init()
{
    
register_plugin("Kill MSGs","1","One")
    
register_event("DeathMsg","EventDeathMsg","a")
    
g_iMaxPlayers get_maxplayers()
}
public 
EventDeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);
    
    new 
szVictimName32 ];
    
get_user_nameiVictimszVictimNamecharsmaxszVictimName ) );
    
    if( 
iKiller == iVictim || !( <= iKiller <= g_iMaxPlayers ) )
    {
        
client_print0print_chat"%s killed self"szVictimName );
    }
    else
    {
        new 
szKillerName32 ]
        new 
szVictimname [32]
        new 
killershp get_user_health(iKiller)
        new 
killersAP get_user_armor(iKiller)
        
get_user_nameiKillerszKillerNamecharsmaxszKillerName ) )
        
get_user_nameiVictimszVictimnamecharsmaxszVictimname ) )
        
client_printc(iVictim"\nKilled by \g%s\n! He has \g%d \nHP & \g%d \nAP.",szKillerName,killershp,killersAP)
        
client_printciKiller"\nYou killed \g%s",szVictimname)
    }
}
stock client_printc(const id,const input[], any:...)
{
    new 
msg[191], players[32], count 1;
    
vformat(msg,190,input,3);
    
replace_all(msg,190,"\g","^4");// green
    
replace_all(msg,190,"\n","^1");// normal
    
replace_all(msg,190,"\t","^3");// team
    
if (idplayers[0] = id; else get_players(players,count,"ch");
    for (new 
i=0;i<count;i++)
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }


but i have no idea how to catch it :( i hope you understand me

lucas_7_94 10-06-2010 10:05

Re: XXX Times kills
 
i think you need use tries.

Exolent[jNr] 10-06-2010 13:10

Re: XXX Times kills
 
Quote:

Originally Posted by lucas_7_94 (Post 1316975)
i think you need use tries.

Unnecessary.

Just use a 2-dimensional array.

Code:
#define MAX_PLAYERS 32 new g_iKills[ MAX_PLAYERS + 1 ][ MAX_PLAYERS + 1 ]; new g_iMaxPlayers; public plugin_init( ) {     register_event( "DeathMsg", "EventDeathMsg", "a", "1>0" );         g_iMaxPlayers = get_maxplayers( ); } public client_disconnect( iPlayer ) {     arrayset( g_iKills[ iPlayer ], 0, ( g_iMaxPlayers + 1 ) );         for( new i = 1; i <= g_iMaxPlayers; i++ )     {         g_iKills[ i ][ iPlayer ] = 0;     } } public EventDeathMsg( ) {     new iKiller = read_data( 1 );         if( iKiller <= g_iMaxPlayers )     {         new iVictim = read_data( 2 );         new iKills = ++g_iKills[ iKiller ][ iVictim ];                 new szName[ 32 ];         get_user_name( iVictim, szName, charsmax( szName ) );         client_print( iKiller, print_chat. "* You have killed %s %i times!", szName, iKills );                 get_user_name( iKiller, szName, charsmax( szName ) );         client_print( iVictim, print_chat. "* You have been killed by %s %i times!", szName, iKills );     } }

One 10-06-2010 15:58

Re: XXX Times kills
 
n1 Exolent. like Ever :D

ty.


All times are GMT -4. The time now is 10:22.

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