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

Solved How can i fix this Array index is out of bounds? :/


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-10-2017 , 22:11   How can i fix this Array index is out of bounds? :/
Reply With Quote #1

Errors:
Code:
L 11/10/2017 - 16:14:56: [SM] Exception reported: Array index is out of bounds
L 11/10/2017 - 16:14:56: [SM] Blaming: skill.smx
L 11/10/2017 - 16:14:56: [SM] Call stack trace:
L 11/10/2017 - 16:14:56: [SM]   [1] Line 949, C:\Users\Mot\addons\sourcemod\scripting\skill.sp::Function_GetRank3
L 11/10/2017 - 16:14:56: [SM]   [2] Line 999, C:\Users\Mot\addons\sourcemod\scripting\skill.sp::Native_GetChatRank
L 11/10/2017 - 16:14:56: [SM]   [4] SB_GetChatRank
L 11/10/2017 - 16:14:56: [SM]   [5] Line 349, C:\Users\Mot\custom-chatcolors-csgo.sp::OnChatMessage
L 11/10/2017 - 16:14:56: [SM]   [7] Call_Finish
L 11/10/2017 - 16:14:56: [SM]   [8] Line 387, C:\Users\anthony\Desktop\JoshOG\Sourcemod\addons\sourcemod\scripting\simple-chatprocessor.sp::OnSayText2
skill.sp Lines
PHP Code:
public void Function_GetRank3(int rankchar[] stringint maxlength
{
    
char sRank[64];
    
Format(sRanksizeof(sRank), "%s"Ranks[rank][tagRank]); // Line 949
    
strcopy(stringmaxlengthsRank);
}


public 
int Native_GetChatRank(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
    
char rank[64], status[8];
    
GetClientCookie(clientgH_sChatTagstatussizeof(status));
    if (!
StrEqual(status"off"false))
    {
        
Function_GetRank3(Function_GetRankNumber(client), ranksizeof(rank)); //Line 999
        
SetNativeString(2rankGetNativeCell(3), false);
    }
    else
    {
        
SetNativeString(2""GetNativeCell(3), false);
    }

custom-chatcolors
PHP Code:
public Action:OnChatMessage(&authorHandle:recipientsString:name[], String:message[]) {
    new 
String:tempString[12];
    new 
String:tagtemp[64];
    new 
tempAuthor author;
    
    
//new String:name[MAXLENGTH_NAME];
    //Format(name, sizeof(name), "%s", iname);
    //strcopy(name, MAXLENGTH_NAME, iname);
    
CStrip(nameMAXLENGTH_INPUT);
    
    
//new String:message[MAXLENGTH_MESSAGE];
    //Format(message, sizeof(message), "%s", imessage);
    
CStrip(messageMAXLENGTH_MESSAGE);
    
    if(
CheckForward(authormessageCCC_NameColor)) {
        if(
StrEqual(usernameColor[author], "G"false)) {
            
Format(nameMAXLENGTH_INPUT"\x04%s"name);
        } else if(
StrEqual(usernameColor[author], "O"false)) {
            
Format(nameMAXLENGTH_INPUT"\x05%s"name);
        } else if(
strlen(usernameColor[author]) == 6) {
            
Format(nameMAXLENGTH_INPUT"\x07%s%s"usernameColor[author], name);
        } else if(
strlen(usernameColor[author]) == 8) {
            
Format(nameMAXLENGTH_INPUT"\x08%s%s"usernameColor[author], name);
        } else if(
strlen(usernameColor[author]) == 4) {
            
strcopy(tempStringsizeof(tempString), usernameColor[author]);
            if(
StrEqual(tempString"{03}")) {
                
tempAuthor = -1;
            }
            
CFormat(tempStringsizeof(tempString));
            
Format(nameMAXLENGTH_INPUT"%s%s"tempStringname);
        } else {
            
Format(nameMAXLENGTH_INPUT"\x03%s"name); // team color by default!
        
}
    } else {
        
Format(nameMAXLENGTH_INPUT"\x03%s"name); // team color by default!
    
}

    if(
CheckForward(authormessageCCC_TagColor)) {
        if(
strlen(tag[author]) > 0) {
            if(
StrEqual(tagColor[author], "T"false)) {
                
Format(nameMAXLENGTH_INPUT"\x03%s%s"tag[author], name);
            } else if(
StrEqual(tagColor[author], "G"false)) {
                
Format(nameMAXLENGTH_INPUT"\x04%s%s"tag[author], name);
            } else if(
StrEqual(tagColor[author], "O"false)) {
                
Format(nameMAXLENGTH_INPUT"\x05%s%s"tag[author], name);
            } else if(
strlen(tagColor[author]) == 6) {
                
Format(nameMAXLENGTH_INPUT"\x07%s%s%s"tagColor[author], tag[author], name);
            } else if(
strlen(tagColor[author]) == 8) {
                
Format(nameMAXLENGTH_INPUT"\x08%s%s%s"tagColor[author], tag[author], name);
            } else if(
strlen(tagColor[author]) == 4) {
                
strcopy(tempStringsizeof(tempString), tagColor[author]);
                
strcopy(tagtempsizeof(tagtemp), tag[author]);
                
CFormat(tagtempsizeof(tagtemp));
                if(
StrEqual(tempString"{03}")) {
                    
tempAuthor = -1;
                }
                
CFormat(tempStringsizeof(tempString));
                
Format(nameMAXLENGTH_INPUT"%s%s%s"tempStringtagtempname);
            } else {
                
Format(nameMAXLENGTH_INPUT"\x01%s%s"tag[author], name);
            }
        }
    }

    if(
skillbot
    {
        new 
String:rank[64];
        
SB_GetChatRank(authorranksizeof(rank));  // Line 999

        
if(strlen(rank) != 0)
        {
            
CFormat(ranksizeof(rank));
            
Format(nameMAXLENGTH_INPUT"%s %s"rankname);
        }
    }
    
    new 
MaxMessageLength MAXLENGTH_MESSAGE strlen(name) - 5// MAXLENGTH_MESSAGE = maximum characters in a chat message, including name. Subtract the characters in the name, and 5 to account for the colon, spaces, and null terminator
    
    
if(strlen(chatColor[author]) > && CheckForward(authormessageCCC_ChatColor)) {
        if(
StrEqual(chatColor[author], "T"false)) {
            
Format(messageMaxMessageLength"\x03%s"message); 
        } else if(
StrEqual(chatColor[author], "G"false)) {
            
Format(messageMaxMessageLength"\x04%s"message);
        } else if(
StrEqual(chatColor[author], "O"false)) {
            
Format(messageMaxMessageLength"\x05%s"message);
        } else if(
strlen(chatColor[author]) == 6) {
            
Format(messageMaxMessageLength"\x07%s%s"chatColor[author], message);
        } else if(
strlen(chatColor[author]) == 8) {
            
Format(messageMaxMessageLength"\x08%s%s"chatColor[author], message);
        } else if(
strlen(chatColor[author]) == 4) {
            
strcopy(tempStringsizeof(tempString), chatColor[author]); 
            if(
StrEqual(tempString"{03}")) {
                
tempAuthor = -1;
            }
            
CFormat(tempStringsizeof(tempString));
            
Format(messageMaxMessageLength"%s%s"tempStringmessage);
        }
    }
    
decl String:game[64];
    
GetGameFolderName(gamesizeof(game));
    if(
StrEqual(game"csgo")) {
        
Format(nameMAXLENGTH_NAME"\x01\x0B %s"name);
    }
    
    
Call_StartForward(messageForward);
    
Call_PushCell(author);
    
Call_PushStringEx(messageMaxMessageLengthSM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPYSM_PARAM_COPYBACK);
    
Call_PushCell(MaxMessageLength);
    
Call_Finish();
    
author tempAuthor;
    return 
Plugin_Changed;

The thing is, it's supposed to show a tag when a player has a rank...
__________________

Last edited by Elitcky; 11-15-2017 at 04:37.
Elitcky is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 11-11-2017 , 10:56   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #2

PHP Code:
Format(sRanksizeof(sRank), "%s"Ranks[rank][tagRank]); // Line 949 
to
PHP Code:
Format(sRanksizeof(sRank), "%s"Ranks[rank]); // Line 949 
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...
Totenfluch is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-11-2017 , 15:33   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #3

didn't worked ( but thanks for the try :// anyone else ? :c
__________________
Elitcky is offline
Walgrim
AlliedModders Donor
Join Date: Dec 2015
Location: France
Old 11-12-2017 , 08:57   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #4

Not sure but, here you use a String.
PHP Code:
new String:rank[64];
SB_GetChatRank(authorranksizeof(rank));  // Line 999 
And here a char, why? I mean, why not just using a string too?
PHP Code:
public void Function_GetRank3(int rankchar[] stringint maxlength
{
    
char sRank[64];
    
Format(sRanksizeof(sRank), "%s"Ranks[rank][tagRank]); // Line 949
    
strcopy(stringmaxlengthsRank);
}


public 
int Native_GetChatRank(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
    
char rank[64], status[8];
    
GetClientCookie(clientgH_sChatTagstatussizeof(status));
    if (!
StrEqual(status"off"false))
    {
        
Function_GetRank3(Function_GetRankNumber(client), ranksizeof(rank)); //Line 999
        
SetNativeString(2rankGetNativeCell(3), false);
    }
    else
    {
        
SetNativeString(2""GetNativeCell(3), false);
    }

I'm not sure about that for real, maybe I say some stupid things
__________________
Walgrim is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-12-2017 , 13:37   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #5

Quote:
Originally Posted by Walgrim View Post
Not sure but, here you use a String.
PHP Code:
new String:rank[64];
SB_GetChatRank(authorranksizeof(rank));  // Line 999 
And here a char, why? I mean, why not just using a string too?
PHP Code:
public void Function_GetRank3(int rankchar[] stringint maxlength
{
    
char sRank[64];
    
Format(sRanksizeof(sRank), "%s"Ranks[rank][tagRank]); // Line 949
    
strcopy(stringmaxlengthsRank);
}


public 
int Native_GetChatRank(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
    
char rank[64], status[8];
    
GetClientCookie(clientgH_sChatTagstatussizeof(status));
    if (!
StrEqual(status"off"false))
    {
        
Function_GetRank3(Function_GetRankNumber(client), ranksizeof(rank)); //Line 999
        
SetNativeString(2rankGetNativeCell(3), false);
    }
    else
    {
        
SetNativeString(2""GetNativeCell(3), false);
    }

I'm not sure about that for real, maybe I say some stupid things
if im not wrong, "char" is used for the new syntax of sourcemod... and "new String:lalalala" was used in the old syntax... custom chat colors has all the code in old syntax so it need to be "new String:" and skillbot has defined the newdecls required new syntax :p so i need to use "char"

Pd:
__________________
Elitcky is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 11-12-2017 , 21:09   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #6

"Array index out of bounds" pretty clearly tells you what's wrong. One or more of the indices to your Ranks array are wrong. You didn't provide us any info as to how it's defined.
Fyren is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-13-2017 , 01:15   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #7

Are you asking me for this?
PHP Code:
enum Rank
{
    
rankPoints,
    
String:chatRank[64],
    
String:menuRank[64],
    
String:tagRank[64]
}
const 
MAX_RANKS 32;
Rank Ranks[MAX_RANKS][Rank];
int maxRank = -1
__________________
Elitcky is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-13-2017 , 12:22   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #8

you need to show us SB_GetChatRank function
and Function_GetRankNumber
__________________

Last edited by 8guawong; 11-13-2017 at 12:23.
8guawong is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-13-2017 , 12:45   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #9

SB_GetChatRank function
PHP Code:
public int Native_GetChatRank(Handle pluginint numParams)
{
    
int client GetNativeCell(1);

    
char rank[64], status[8];
    
GetClientCookie(clientgH_sChatTagstatussizeof(status));
    if(!
StrEqual(status"off"false))
    {
        
Function_GetRank3(Function_GetRankNumber(client), ranksizeof(rank));
        
SetNativeString(2rankGetNativeCell(3), false);
    }
    else
    {
        
SetNativeString(2""GetNativeCell(3), false);
    }

Function_GetRankNumber
PHP Code:
stock int Function_GetRankNumber(int client)
{
    
int points Function_ReturnPoints(client);
    if(
points <= Ranks[0][rankPoints]) return 0;
    if(
points >= Ranks[maxRank-1][rankPoints]) return maxRank-1;
    for(
int i maxRank-20i--) {
        if(
points >= Ranks[i][rankPoints]) return i;
    }
    return -
1;

hope this will help :/
__________________
Elitcky is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-13-2017 , 12:52   Re: How can i fix this Array index is out of bounds? :/
Reply With Quote #10

Your Function_GetRankNumber is probably the problem
__________________

Last edited by 8guawong; 11-13-2017 at 12:54.
8guawong 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 02:03.


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