AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [HELP] Best Player of the Round (https://forums.alliedmods.net/showthread.php?t=231329)

extream87 12-12-2013 09:16

[HELP] Best Player of the Round
 
What is wrong with this code?
When the round ends only appears: Best Player: nothing more

Code:
#include <amxmodx> #include <cstrike> #define PLUGIN "Best Player" #define VERSION "1.0" #define AUTHOR "pauSe" #define IsPlayer(%1)    (1 <= %1 <= gMaxPlayers) new gKills[33] new gMaxPlayers public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_logevent("RoundStart", 2, "1=Round_Start")     register_logevent("RoundEnd", 2, "1=Round_End")         register_event("DeathMsg", "FwdDeathMsgEvent", "a")         gMaxPlayers = get_maxplayers() } public client_connect(id)     gKills[id] = 0     public DeathMsg() {     new attacker = read_data(1)     new victim = read_data(2)         if(attacker != victim && cs_get_user_team(attacker) != cs_get_user_team(victim) && IsPlayer(attacker))         gKills[attacker]++ } public RoundStart()     arrayset(gKills, 0, 33) public RoundEnd() {     new name[34]     new bestplayer, bestscore         for(new i; i < sizeof(gKills); i++)     {         if(gKills[i] > bestscore)         {             bestplayer = i             bestscore = gKills[i]         }     }         get_user_name(bestplayer, name, 33)         set_hudmessage(255, 0, 0, -1.0, 0.01)     show_hudmessage(0, "Best Player: %s ^nKills: %i", name, bestscore) }

Don_Collione 12-15-2013 01:48

Re: [HELP] Best Player of the Round
 
PHP Code:

#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich> 
#include <cstrike> 
 
#define PLUGIN    "Best Player" 
#define AUTHOR    "STK | kHRYSTER" 
#define VERSION    "1.0" 
 
new g_iKills[32], g_iDmg[32
 
public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamage"
    
register_event("DeathMsg""EventDeathMsg""a"
    
register_logevent("RoundEnd"2"1=Round_End"

 
public 
client_disconnect(id

    
g_iDmg[id] = 0
    
g_iKills[id] = 0
}
public 
hamTakeDamage(victiminflictorattackerFloat:damageDamageBits

    if( 
<= attacker <= 32
    { 
        if(
cs_get_user_team(victim) != cs_get_user_team(attacker)) 
            
g_iDmg[attacker] += floatround(damage
        else 
            
g_iDmg[attacker] -= floatround(damage
    } 

 
public 
EventDeathMsg() 

    new 
killer read_data(1
    new 
victim read_data(2
 
    if(
killer != victim && killer && cs_get_user_team(killer) != cs_get_user_team(victim)) 
    { 
        
g_iKills[killer]++; 
    } 
    else 
        
g_iKills[killer]--; 

 
public 
RoundEnd() 

    new 
iBestPlayer get_best_player() 
    new 
szName[32
    
get_user_name(iBestPlayerszNamecharsmax(szName)) 
 
    
set_hudmessage(25500, -1.0, -1.0)
    
show_hudmessage(0"Best Player: %s Kills: %i"szNameg_iKills[iBestPlayer])
 
    for(new 
i31i++) 
    { 
        
g_iDmg[i] = 0
        
g_iKills[i] = 0
    } 

 
get_best_player() 

    new 
players[32], num
    
get_players(playersnum); 
    
SortCustom1D(playersnum"sort_bestplayer"
    return 
players[0

 
public 
sort_bestplayer(id1id2

    if(
g_iKills[id1] > g_iKills[id2]) 
        return -
1
    else if(
g_iKills[id1] < g_iKills[id2]) 
        return 
1
    else 
    { 
        if(
g_iDmg[id1] > g_iDmg[id2]) 
            return -
1
        else if(
g_iDmg[id1] < g_iDmg[id2]) 
            return 
1
        else 
            return 
0
    } 
    return 
0




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

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