Server crash -
Marcuse - 20.01.2016
I get a proble when I connect to the server, after the login, i get stuck on the class selection (this didnt happen until i made a function)
PHP код:
stock setUpFriendVars(playerid){
for(new i = 0; i < MAX_FRIENDS; i ++){
Friends[playerid][i][dbid] = 0;
Friends[playerid][i][serverid] = -1;
Friends[playerid][i][online] = false;
}
return true;
}
So what this does is set the values to default when then player connects
But when I put this on OnPlayerConnect i get
Код:
[15:51:35] [debug] Run time error 4: "Array index out of bounds"
[15:51:35] [debug] Accessing element at negative index -1
[15:51:35] [debug] AMX backtrace:
[15:51:35] [debug] #0 000258f4 in ?? (-1, 0, 9411992, 9411996, 0) from main.amx
[15:51:35] [debug] #1 0002b9f0 in ?? (0) from main.amx
[15:51:35] [debug] #2 0001fda0 in public OnAccountLoad (0) from main.amx
[15:51:43] [debug] Run time error 4: "Array index out of bounds"
[15:51:43] [debug] Accessing element at negative index -1
[15:51:43] [debug] AMX backtrace:
[15:51:43] [debug] #0 000258f4 in ?? (-1, 1, 9412000, 9412004, 0) from main.amx
[15:51:43] [debug] #1 0002bbf0 in ?? (0) from main.amx
[15:51:43] [debug] #2 00026b58 in ?? (0, 1) from main.amx
[15:51:43] [debug] #3 00011474 in public SSCANF_OnPlayerDisconnect (0, 1) from main.amx
[15:51:43] [debug] #4 0000265c in public Itter_OnPlayerDisconnect (0, 1) from main.amx
[15:51:43] [debug] #5 00001740 in public OnPlayerDisconnect (0, 1) from main.amx
[15:51:43] [part] Champa has left the server (0:1)
Re: Server crash -
Jstylezzz - 20.01.2016
My guess is that you either go past the maximum size with the [i] thingie, or that it somehow doesn't like the -1, the value you give to serverid. Can you show how you create the friends array? That would give me a clearer picture of how the array is built.
A little confused because the log says
Код:
[15:51:35] [debug] Accessing element at negative index -1
which leads me to believe that
Код:
Friends[playerid][i][serverid] = -1; //<-- this value you set it to
is the thing that causes your issue, since I see no other '-1' there. But that would be rather odd.
Anyways; If you show how you create your Friends array, it would make it a lot easier to rule things out I guess
![Smiley](images/smilies/smile.png)
The possibility might also be, that it is not in this function that you posted. The log also says 'OnAccountLoad ()', so you could also post that so we can check that out if we don't find anything in the Friends array and that function.
Re: Server crash -
Marcuse - 20.01.2016
PHP код:
enum friendsEnum{
bool: online,
imePrijatelja[25], //Friend name
serverid,
dbid
}
new Friends[MAX_PLAYERS][MAX_FRIENDS][friendsEnum];
That function is called before OnAccountLoad (Before the query anyway)
PHP код:
hook OnPlayerConnect(playerid){
new q[128];
ResetPlayerVariables(playerid);
mysql_format(con, q, sizeof(q),"SELECT `Id`, `Password`, `Banned` FROM `Players` WHERE `Username` = '%e' LIMIT 1", ImeIgraca(playerid));
mysql_tquery(con, q, "OnAccountCheck", "i", playerid);
CleanChat(playerid, 20);
return true;
}
PHP код:
protected OnAccountLoad(playerid)
{
LoadPlayerTextDraws(playerid);
PData[playerid][Id] = cache_get_field_content_int(0, "Id");
cache_get_field_content(0, "Email", PData[playerid][Email], con, 150);
PData[playerid][Sex] = cache_get_field_content_int(0, "Sex");
cache_get_field_content(0, "Country", PData[playerid][Country], con, 40);
PData[playerid][Admin] = cache_get_field_content_int(0, "Admin");
PData[playerid][GameMaster] = cache_get_field_content_int(0, "GM");
PData[playerid][StaffCode] = cache_get_field_content_int(0, "SCode");
cache_get_field_content(0, "Banned", PData[playerid][Banned], con, 255);
PData[playerid][Level] = cache_get_field_content_int(0, "Level");
PData[playerid][Exp] = cache_get_field_content_int(0, "Exp");
PData[playerid][Skin] = cache_get_field_content_int(0, "Skin");
PData[playerid][Money] = cache_get_field_content_int(0, "Money");
PData[playerid][Bank] = cache_get_field_content_int(0, "Bank");
loadFriendsForPlayer(playerid);
alertFriendsOnConnection(playerid);
SetPlayerSpawn(playerid);
return true;
}
PHP код:
stock ResetPlayerVariables(playerid){
setUpFriendVars(playerid);
format(PData[playerid][Password], 150, "");
format(PData[playerid][Email], 100, "");
PData[playerid][LoginErrors] = 0;
PData[playerid][StaffCodeErrors] = 0;
PData[playerid][Id] = 0;
PData[playerid][Sex] = 0;
PData[playerid][Admin] = 0;
PData[playerid][GameMaster] = 0;
PData[playerid][StaffCode] = 0;
PData[playerid][Level] = 0;
PData[playerid][Exp] = 0;
PData[playerid][Money] = 0;
PData[playerid][Bank] = 0;
PData[playerid][Skin] = 0;
PData[playerid][StaffLogged] = false;
PData[playerid][StaffDuty] = false;
format(PData[playerid][Banned], 255, "");
ResetFriendRequest(playerid);
return true;
}
Re: Server crash -
Marcuse - 20.01.2016
Help?
Re: Server crash -
Prokill911 - 20.01.2016
Hi,
Looking at your backtrace it looks like it's your onaccountload
Check your SQL to see what the default value is
Also check if anyone has the value of -1
-
You're looking for something which outputs 5 parameters
the first parameter is being set to -1