Raised This Month: $ Target: $400
 0% 

[HELP] Fix Best Player Round 32Slots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extream87
Senior Member
Join Date: Aug 2011
Old 03-11-2014 , 09:27   [HELP] Fix Best Player Round 32Slots
Reply With Quote #1

My server have 32slots, and sometimes show "Best player round extream87 killed 27 players" how i can fix this?
Code:
#include <amxmodx>   #include <amxmisc>   #include <hamsandwich>   #include <cstrike> #include <colorchat>     #define PLUGIN    "Best Player Round"   #define AUTHOR    "extream87"   #define VERSION   "1.1"     new g_iKills[33], g_iDmg[33], zTAG   public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     RegisterHam(Ham_TakeDamage, "player", "hamTakeDamage")     register_event("DeathMsg", "EventDeathMsg", "a")       register_logevent("RoundEnd", 2, "1=Round_End")     zTAG = register_cvar("bp_prefix", "Prefix*") }     public client_disconnect(id)   {       g_iDmg[id] = 0;       g_iKills[id] = 0;   } public hamTakeDamage(victim, inflictor, attacker, Float:damage, DamageBits)   {       if( 1 <= 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[33]       get_user_name(iBestPlayer, szName, charsmax(szName))           new szTAG[25];     get_pcvar_string(zTAG, szTAG, charsmax(szTAG));         if (g_iKills[iBestPlayer] <1 ){     ColorChat(0, GREEN, "[%s] ^x01Esta ronda nao foi jogada.", szTAG);     }         else if (g_iKills[iBestPlayer] ==1 ){     ColorChat(0, GREEN, "[%s] ^x01Melhor jogador da ronda: ^x04%s ^x01matou ^x04%i ^x01jogador.", szTAG, szName, g_iKills[iBestPlayer]);     }         else if (g_iKills[iBestPlayer] >1 ){     ColorChat(0, GREEN, "[%s] ^x01Melhor jogador da ronda: ^x04%s ^x01matou ^x04%i ^x01jogadores.", szTAG, szName, g_iKills[iBestPlayer]);     }           for(new i; i < 31; i++)       {           g_iDmg[i] = 0;           g_iKills[i] = 0;       }   }     get_best_player()   {       new players[32], num;     get_players(players, num);     SortCustom1D(players, num, "sort_bestplayer")     return players[0] }     public sort_bestplayer(id1, id2)   {       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;   }
extream87 is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 03-11-2014 , 12:58   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #2

PHP Code:
for(new i31i++) 
-->

PHP Code:
for(new 1<= 32i++) 
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 03-11-2014 , 15:42   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #3

You should store get_maxplayers() value in memory at plugin startup to loop players...
__________________

Last edited by Neeeeeeeeeel.-; 03-11-2014 at 15:42.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
extream87
Senior Member
Join Date: Aug 2011
Old 03-11-2014 , 17:03   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #4

How can i make it?
extream87 is offline
minato
Senior Member
Join Date: May 2010
Location: Rosario
Old 03-11-2014 , 17:34   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #5

PHP Code:
new g_maxplayers;

public 
plugin_init(){
          
g_maxplayers get_maxplayers();
}

public 
startFunction(){

    for( new 
0<= g_maxplayersi++)
    {
                   
// DO SOMETHING
    
}

__________________
minato is offline
Send a message via MSN to minato
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-11-2014 , 17:38   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #6

Quote:
Originally Posted by minato View Post
PHP Code:
new g_maxplayers;

public 
plugin_init(){
          
g_maxplayers get_maxplayers();
}

public 
startFunction(){

    for( new 
0<= g_maxplayersi++)
    {
                   
// DO SOMETHING
    
}

No

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
You should store get_maxplayers() value in memory at plugin startup to loop players...
Agree with the cache maxplayers, but not the loop

Quote:
Originally Posted by extream87 View Post
How can i make it?
Code:
g_maxplayers = get_maxplayers(); // put this in plugin_init

if( 1 <= attacker <= g_maxplayers)

for(new i; i < g_maxplayers; i++) // you might want to consider get_players for this loop
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 03-11-2014 at 17:39.
YamiKaitou is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-11-2014 , 17:39   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #7

So this is what i have... Where i put this?
for(new i = 1; i <= g_maxplayers; i++)

for(new i; i < g_maxplayers; i++) // you might want to consider get_players for this loop
Code:
#include <amxmodx>   #include <amxmisc>   #include <hamsandwich>   #include <cstrike> #include <colorchat>     #define PLUGIN    "Best Player Round"   #define AUTHOR    "extream87"   #define VERSION   "1.1"     new g_iKills[33], g_iDmg[33], zTAG, g_maxplayers;   public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     g_maxplayers = get_maxplayers();     RegisterHam(Ham_TakeDamage, "player", "hamTakeDamage")     register_event("DeathMsg", "EventDeathMsg", "a")       register_logevent("RoundEnd", 2, "1=Round_End")     zTAG = register_cvar("bp_prefix", "Prefix*") }     public client_disconnect(id)   {       g_iDmg[id] = 0;       g_iKills[id] = 0;   } public hamTakeDamage(victim, inflictor, attacker, Float:damage, DamageBits)   {       if( 1 <= 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[33]       get_user_name(iBestPlayer, szName, charsmax(szName))           new szTAG[25];     get_pcvar_string(zTAG, szTAG, charsmax(szTAG));         if (g_iKills[iBestPlayer] <1 ){     ColorChat(0, GREEN, "[%s] ^x01Esta ronda nao foi jogada.", szTAG);     }         else if (g_iKills[iBestPlayer] ==1 ){     ColorChat(0, GREEN, "[%s] ^x01Melhor jogador da ronda: ^x04%s ^x01matou ^x04%i ^x01jogador.", szTAG, szName, g_iKills[iBestPlayer]);     }         else if (g_iKills[iBestPlayer] >1 ){     ColorChat(0, GREEN, "[%s] ^x01Melhor jogador da ronda: ^x04%s ^x01matou ^x04%i ^x01jogadores.", szTAG, szName, g_iKills[iBestPlayer]);     }           for(new i = 1; i <= 32; i++)       {           g_iDmg[i] = 0;           g_iKills[i] = 0;       }   }     get_best_player()   {       new players[32], num;     get_players(players, num);     SortCustom1D(players, num, "sort_bestplayer")     return players[0] }     public sort_bestplayer(id1, id2)   {       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;   }

Last edited by extream87; 03-11-2014 at 17:41.
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-11-2014 , 17:40   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #8

Quote:
Originally Posted by extream87 View Post
So this is what i have... What i need to put:
See my post, not minato's
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-11-2014 , 17:42   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #9

Last post edited YamiKaitou
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-11-2014 , 17:46   Re: [HELP] Fix Best Player Round 32Slots
Reply With Quote #10

Look again, I just showed you the replacements. This is Scripting Help, you should be able to figure this out yourself
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Reply


Thread Tools
Display Modes

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 05:59.


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