error 032: array index out of bounds (variable "gInfo") -
danielpalade - 09.01.2016
This is my loadgroups
Код:
stock LoadGroups()
{
new tmp[512], query[512], groups;
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `groups` ORDER BY `id`");
mysql_tquery(mysql, query);
gInfo[MAX_FACTIONS][gID] = cache_get_field_content_int(0, "ID");
gInfo[MAX_FACTIONS][gName] = cache_get_field_content_int(0, "groupName");
gInfo[MAX_FACTIONS][gType] = cache_get_field_content_int(0, "groupType");
cache_get_field_content(0, "groupRank1", tmp, mysql), pInfo[MAX_FACTIONS][gRank1] = strval(tmp);
cache_get_field_content(0, "groupRank2", tmp, mysql), pInfo[MAX_FACTIONS][gRank2] = strval(tmp);
cache_get_field_content(0, "groupRank3", tmp, mysql), pInfo[MAX_FACTIONS][gRank3] = strval(tmp);
cache_get_field_content(0, "groupRank4", tmp, mysql), pInfo[MAX_FACTIONS][gRank4] = strval(tmp);
cache_get_field_content(0, "groupRank5", tmp, mysql), pInfo[MAX_FACTIONS][gRank5] = strval(tmp);
cache_get_field_content(0, "groupRank6", tmp, mysql), pInfo[MAX_FACTIONS][gRank6] = strval(tmp);
cache_get_field_content(0, "groupRank7", tmp, mysql), pInfo[MAX_FACTIONS][gRank7] = strval(tmp);
gInfo[MAX_FACTIONS][gSlots] = cache_get_field_content_int(0, "groupSlots");
groups ++;
printf("%d groups loaded.", groups);
return 1;
}
This is my enum
Код:
enum groupData
{
gID,
gName[256],
gType[10],
gRank1[256],
gRank2[256],
gRank3[256],
gRank4[256],
gRank5[256],
gRank6[256],
gRank7[256],
gSlots[10]
}
new gInfo[MAX_FACTIONS][groupData];
This is my variable
Код:
#define MAX_FACTIONS 14
How can I fix that error?
Re: error 032: array index out of bounds (variable "gInfo") -
danielpalade - 09.01.2016
Bumping..
Re: error 032: array index out of bounds (variable "gInfo") -
danielpalade - 10.01.2016
Bumping
Re: error 032: array index out of bounds (variable "gInfo") -
CodeStyle175 - 10.01.2016
idk if you're stupid ors, but what the hell are you scripting.
PHP код:
enum groupData
{
gID,
gName[30],
gType,
gRank1[30],
gRank2[30],
gRank3[30],
gRank4[30],
gRank5[30],
gRank6[30],
gRank7[30],
gSlots
}
new gInfo[MAX_FACTIONS][groupData];
public OnGameModeInit(){
mysql_tquery(mysql,"SELECT * FROM groups","LoadGroups","");
return 1;
}
forward LoadGroups();
public LoadGroups(){
new rows=cache_num_rows();
if(!rows)return print("No groups added!");
for(new i; i < rows; i++){ //uses this 'cache_get_field_content' for strings and this 'cache_get_field_content_int' for numbers
gInfo[i][gID] = cache_get_field_content_int(i, "ID");
cache_get_field_content(i,"groupName",gInfo[i][gName],mysql,30);
gInfo[i][gType] = cache_get_field_content_int(i, "groupType");
gInfo[i][gSlots] = cache_get_field_content_int(i, "groupSlots");
cache_get_field_content(i,"groupRank1",gInfo[i][gRank1],mysql,30);
cache_get_field_content(i,"groupRank2",gInfo[i][gRank2],mysql,30);
cache_get_field_content(i,"groupRank3",gInfo[i][gRank3],mysql,30);
cache_get_field_content(i,"groupRank4",gInfo[i][gRank4],mysql,30);
cache_get_field_content(i,"groupRank5",gInfo[i][gRank5],mysql,30);
cache_get_field_content(i,"groupRank6",gInfo[i][gRank6],mysql,30);
cache_get_field_content(i,"groupRank7",gInfo[i][gRank7],mysql,30);
}
printf("%d groups loaded.",rows);
return 1;
}
Re: error 032: array index out of bounds (variable "gInfo") -
OwlIT - 10.01.2016
I recommend to you to read something about "array", you don't know what you are doing and in facts your code doesn't make sense.
https://sampforum.blast.hk/showthread.php?tid=318212