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

Array Issue or Wrong Loop?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 06-16-2017 , 12:38   Array Issue or Wrong Loop?
Reply With Quote #1

I am using this plugin as my stats plugin...
But when my server gets full with 32 players it doesn't show "best score" hud message.
But during less players it works fine and show best score at the end of the round..
Is it Array isssue?

Plugin is very big so m pasting declaration code & best score function.
Attaching full plugin also..


Code:
#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <cstrike>
#include <nvault>
#include <geoip>


//--------------------------------


//Connect announcements.
new name[33][33]
new authid[33][32]
new country[33][46]
new city[33][46]
new user_state[33][46]
new ip[33][32]

new saytext_msgid
new bool:g_changelevel=false


/*Color Chat*/
#define MAXSLOTS 32

enum ChatColor
{
	CHATCOLOR_NORMAL = 1,
	CHATCOLOR_GREEN,
	CHATCOLOR_TEAM_COLOR,
	CHATCOLOR_GREY, 	
	CHATCOLOR_RED, 		
	CHATCOLOR_BLUE, 	
}

new g_TeamName[][] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
}

new g_msgSayText
new g_msgTeamInfo

// Uncomment to activate log debug messages.
//#define STATSX_DEBUG

// HUD statistics duration in seconds (minimum 1.0 seconds).
#define HUD_DURATION_CVAR   "amx_statsx_duration"
#define HUD_DURATION        "12.0"

// HUD statistics stop relative freeze end in seconds.
// To stop before freeze end use a negative value.
#define HUD_FREEZE_LIMIT_CVAR   "amx_statsx_freeze"
#define HUD_FREEZE_LIMIT        "-2.0"

// HUD statistics minimum duration, in seconds, to trigger the display logic.
#define HUD_MIN_DURATION    0.2

// Config plugin constants.
#define MODE_HUD_DELAY      0   // Make a 0.01 sec delay on HUD reset process.

// You can also manualy enable or disable these options by setting them to 1
// For example:
// public ShowAttackers = 1
// However amx_statscfg command is recommended


//rank chat
new SzMaxPlayers, SzSayText; 

new SzGTeam[3][] = { 
    "Spectator", 
    "Terrorist", 
    "Counter-Terrorist" 
} 

new PlayerRank[33]


// Standard Contstants.
#define MAX_TEAMS               2

#define MAX_WEAPON_LENGTH       31
#define MAX_TEXT_LENGTH         255
#define MAX_BUFFER_LENGTH       2047

// User stats parms id
#define STATS_KILLS             0
#define STATS_DEATHS            1
#define STATS_HS                2
#define STATS_TKS               3
#define STATS_SHOTS             4
#define STATS_HITS              5
#define STATS_DAMAGE            6

// Killer information, save killer info at the time when player is killed.
#define KILLED_KILLER_ID        0   // Killer userindex/user-ID
#define KILLED_KILLER_HEALTH    1   // Killer's health
#define KILLED_KILLER_ARMOUR    2   // Killer's armour
#define KILLED_TEAM             3   // Killer's team
#define KILLED_KILLER_STATSFIX  4   // Fix to register the last hit/kill

new g_izKilled[MAX_PLAYERS][5]

// Menu variables and configuration
#define MAX_PPL_MENU_ACTIONS    2   // Number of player menu actions
#define PPL_MENU_OPTIONS        7   // Number of player options per displayed menu

new g_iPluginMode                                   = 0

new g_izUserMenuPosition[MAX_PLAYERS]               = {0, ...}
new g_izUserMenuAction[MAX_PLAYERS]                 = {0, ...}
new g_izUserMenuPlayers[MAX_PLAYERS][32]

new g_izSpecMode[MAX_PLAYERS]                       = {0, ...}

new g_izShowStatsFlags[MAX_PLAYERS]                 = {0, ...}
new g_izStatsSwitch[MAX_PLAYERS]                    = {0, ...}
new Float:g_fzShowUserStatsTime[MAX_PLAYERS]        = {0.0, ...}
new Float:g_fShowStatsTime                          = 0.0
new Float:g_fFreezeTime                             = 0.0
new Float:g_fFreezeLimitTime                        = 0.0
new Float:g_fHUDDuration                            = 0.0

new g_iRoundEndTriggered                            = 0
new g_iRoundEndProcessed                            = 0

new Float:g_fStartGame                              = 0.0
new g_izTeamScore[MAX_TEAMS]                        = {0, ...}
new g_izTeamEventScore[MAX_TEAMS]                   = {0, ...}
new g_izTeamRndStats[MAX_TEAMS][8]
new g_izTeamGameStats[MAX_TEAMS][8]
new g_izUserUserID[MAX_PLAYERS]                     = {0, ...}
new g_izUserAttackerDistance[MAX_PLAYERS]           = {0, ...}
new g_izUserVictimDistance[MAX_PLAYERS][MAX_PLAYERS]
new g_izUserRndName[MAX_PLAYERS][MAX_NAME_LENGTH + 1]
new g_izUserRndStats[MAX_PLAYERS][8]
new g_izUserGameStats[MAX_PLAYERS][8]

// Common buffer to improve performance, as Small always zero-initializes all vars
new g_sBuffer[MAX_BUFFER_LENGTH + 1]                = ""
new g_sScore[MAX_TEXT_LENGTH + 1]                   = ""
new g_sAwardAndScore[MAX_BUFFER_LENGTH + 1]         = ""

new t_sText[MAX_TEXT_LENGTH + 1]                    = ""
new t_sName[MAX_NAME_LENGTH + 1]                    = ""
new t_sWpn[MAX_WEAPON_LENGTH + 1]                   = ""

new g_HudSync_EndRound
new g_HudSync_SpecInfo

// MastaMan Edition

#define MAX_SORT_COUNT		100

#define MM_MINUTE 60
#define MM_HOUR 3600
#define MM_DAY 86400
#define MM_WEEK 604800
#define MM_MONTH 2592000
#define MM_YEAR 31536000

new bool:szTrigger = true

//New ROUND RANK INFO.
new bool:hasOldRank[33] = false
new OldStats[33]

new marquee_iID

new m_sName[MAX_NAME_LENGTH + 1]                  	= ""
new marquee_place[40]				= ""



// Get and format best score.
add_best_score(sBuffer[MAX_BUFFER_LENGTH + 1])
{
	new id, iMaxKillsId, iMaxKills, iMaxHeadShots

	iMaxKillsId = 0
	iMaxKills = 0
	iMaxHeadShots = 0

	// Find player
	for (id = 1; id < MAX_PLAYERS; id++)
	{
		if (g_izUserRndStats[id][STATS_KILLS] >= iMaxKills && (g_izUserRndStats[id][STATS_KILLS] > iMaxKills || g_izUserRndStats[id][STATS_HS] > iMaxHeadShots))
		{
			iMaxKillsId = id
			iMaxKills = g_izUserRndStats[id][STATS_KILLS]
			iMaxHeadShots = g_izUserRndStats[id][STATS_HS]
		}
	}

	// Format statistics.
	if (iMaxKillsId)
	{
		id = iMaxKillsId
		
		new Float:fGameEff = effec(g_izUserGameStats[id])
		new Float:fRndAcc = accuracy(g_izUserRndStats[id])
		
		format(t_sText, MAX_TEXT_LENGTH, "%L: %s^n%d %L / %d hs -- %0.2f%% %L / %0.2f%% %L^n", LANG_SERVER, "BEST_SCORE", g_izUserRndName[id], 
				iMaxKills, LANG_SERVER, "KILL_S", iMaxHeadShots, fGameEff, LANG_SERVER, "EFF", fRndAcc, LANG_SERVER, "ACC")
		add(sBuffer, MAX_BUFFER_LENGTH, t_sText)
	}
	
	return iMaxKillsId
}
Attached Files
File Type: sma Get Plugin or Get Source (statsx_modified.sma - 526 views - 125.8 KB)

Last edited by xExperienced; 06-16-2017 at 12:40.
xExperienced is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-16-2017 , 21:19   Re: Array Issue or Wrong Loop?
Reply With Quote #2

Show the definition of MAX_PLAYERS. And your loop should use get_players() instead of looping 1 to MAX_PLAYERS...if you do loop from 1 to MAX_PLAYERS, it should be id <= MAX_PLAYERS, not id < MAX_PLAYERS.
__________________
Bugsy is offline
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 06-17-2017 , 03:32   Re: Array Issue or Wrong Loop?
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Show the definition of MAX_PLAYERS. And your loop should use get_players() instead of looping 1 to MAX_PLAYERS...if you do loop from 1 to MAX_PLAYERS, it should be id <= MAX_PLAYERS, not id < MAX_PLAYERS.
I tried to find definition MAX_PLAYERS but didn't find in whole plugin.
so I attached plugin so you pawn coders will come to know what exactly the issue is.
Because I don't have proper knowledge of pawn language.


I will change code as per your instructions:
id < MAX_PLAYERS to id <= MAX_PLAYERS


Hope it will fix my issue

I think this how author has defined MAX_PLAYERS
Code:
//rank chat
new SzMaxPlayers, SzSayText;
But sir it will be good if you download sma and check definition of MAX_PLAYERS.
[Request]

Last edited by xExperienced; 06-17-2017 at 03:35.
xExperienced 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 19:36.


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