Raised This Month: $51 Target: $400
 12% 

[HELP] BestRoundPlayer fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extream87
Senior Member
Join Date: Aug 2011
Old 04-08-2014 , 04:28   [HELP] BestRoundPlayer fix
Reply With Quote #1

What is wrong with the code?
Sometimes i kill 1 player and im the bestplayerround with 2 kills?

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx>  #include <amxmisc>  #include <hamsandwich>  #include <cstrike> #include <colorchat>    #define PLUGIN    "Best Player Round"  #define AUTHOR    "extream87"  #define VERSION   "1.0"    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", "servername") }    public client_disconnect(id)  {      g_iDmg[id] = 0;      g_iKills[id] = 0} public hamTakeDamage(victim, inflictor, attacker, Float:damage, DamageBits)  {      if(1 <= attacker <= g_maxplayers)      {          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] ^1Esta ronda nao foi jogada.", szTAG);     }         else if (g_iKills[iBestPlayer] ==1 ){         ColorChat(0, GREEN, "[%s] ^1Melhor jogador da ronda: ^4%s ^1matou ^4%i ^1jogador.", szTAG, szName, g_iKills[iBestPlayer]);     }         else if (g_iKills[iBestPlayer] >1 ){         ColorChat(0, GREEN, "[%s] ^1Melhor jogador da ronda: ^4%s ^1matou ^4%i ^1jogadores.", szTAG, szName, g_iKills[iBestPlayer]);     }         arrayset(g_iDmg, 0, sizeof g_iDmg);     arrayset(g_iKills, 0, sizeof g_iKills); }    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; 04-08-2014 at 04:29.
extream87 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-12-2014 , 17:15   Re: [HELP] BestRoundPlayer fix
Reply With Quote #2

Since you're using Round_End logevent you are still able to play after that, right?
Let's say you kill someone after the round is over but you haven't respawned yet. It will still count as a kill of the next round since it was after you reset the array.
So what you should do is print the message on round end, reset arrays on round start.

When you're using Ham, why not use Ham_Killed instead of DeathMsg?
__________________
Black Rose is offline
extream87
Senior Member
Join Date: Aug 2011
Old 04-13-2014 , 07:54   Re: [HELP] BestRoundPlayer fix
Reply With Quote #3

Thanks Black Rose is that?
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx>  #include <amxmisc>  #include <hamsandwich>  #include <cstrike> #include <colorchat>    #define PLUGIN    "Best Player Round"  #define AUTHOR    "extream87"  #define VERSION   "1.0"    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")     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")     register_logevent("RoundEnd", 2, "1=Round_End")     zTAG = register_cvar("bp_prefix", "servername") }    public client_disconnect(id)  {      g_iDmg[id] = 0;      g_iKills[id] = 0} public hamTakeDamage(victim, inflictor, attacker, Float:damage, DamageBits)  {      if(1 <= attacker <= g_maxplayers)      {          if(cs_get_user_team(victim) != cs_get_user_team(attacker))              g_iDmg[attacker] += floatround(damage)          else              g_iDmg[attacker] -= floatround(damage)      }  }    public fw_PlayerKilled()  {      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 event_new_round() {     arrayset(g_iDmg, 0, sizeof g_iDmg);     arrayset(g_iKills, 0, sizeof g_iKills); }    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] ^1Esta ronda nao foi jogada.", szTAG);     }         else if (g_iKills[iBestPlayer] ==1 ){         ColorChat(0, GREEN, "[%s] ^1Melhor jogador da ronda: ^4%s ^1matou ^4%i ^1jogador.", szTAG, szName, g_iKills[iBestPlayer]);     }         else if (g_iKills[iBestPlayer] >1 ){         ColorChat(0, GREEN, "[%s] ^1Melhor jogador da ronda: ^4%s ^1matou ^4%i ^1jogadores.", szTAG, szName, g_iKills[iBestPlayer]);     }    }    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
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-13-2014 , 08:52   Re: [HELP] BestRoundPlayer fix
Reply With Quote #4

Yeah, that's my best guess.
But I'm not sure when Round_End is called.
__________________
Black Rose is offline
extream87
Senior Member
Join Date: Aug 2011
Old 04-13-2014 , 11:34   Re: [HELP] BestRoundPlayer fix
Reply With Quote #5

When one team win the round.
The code not work properly. When one player attack and kill another he breack.

Last edited by extream87; 04-13-2014 at 14:14.
extream87 is offline
Reply



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 06:06.


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