PDA

View Full Version : One big problem...


DusanInfinity
05/12/2015, 10:09 AM
Greetings to everyone! I wanted to test my script with bots (raksamp) and saw a big mistake in the script, when you connect the player 21 or more, each player whose ID is bigger than 24 has this bug (I have 5 NPC in script):

[11:50:04] [join] Infinity has joined the server (28:25.73.135.217)
[11:50:04] [debug] Run time error 4: "Array index out of bounds"
[11:50:04] [debug] Accessing element at index 28 past array upper bound 24
[11:50:04] [debug] AMX backtrace:
[11:50:04] [debug] #0 00228544 in PonistiSveVarijable (playerid=28) at C:\...\BS_RP.pwn:31428
[11:50:04] [debug] #1 0005a4f0 in public SSCANF_OnPlayerConnect (playerid=28) at C:\...\BS_RP.pwn:6476
[11:50:04] [debug] #2 00026884 in ?? (... <1 argument>) at C:\...\sscanf2.inc:205
[11:50:04] [debug] #3 00009aa8 in public Itter_OnPlayerConnect (playerid=28) at C:\...\YSI\y_hooks/impl.inc:618
[11:50:04] [debug] #4 00002460 in public OnPlayerConnect (playerid=28) at C:\...\YSI\y_iterate.inc:646

I dont know how is this possible, in the first 20 players everything is normal, and 21+ players have this...

Lines:

Line BS_RP.pwn:31428 PlayerPressedJump[playerid] = 0;
Im using that variable for Anti BunnyHop, and thats defined like this: new PlayerPressedJump[MAX_PLAYERS char];
Line BS_RP.pwn:6476 PonistiSve(playerid);
I have stock PonistiSve(playerid) and in that stock some player variables go to 0. ex: PlayerInfo[playerid][pLevel] = 0;
But under the line 6476 is PonistiSveVarijable(playerid); and in that stock is line 31428! I think in that stock is problem...
Line sscanf2.inc:205
public OnPlayerConnect(playerid)
{
new
name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof (name));
SSCANF_Join(playerid, name, IsPlayerNPC(playerid));
#if defined SSCANF_OnPlayerConnect
SSCANF_OnPlayerConnect(playerid);
#endif
return 1; // this is line 205!
}
Line y_hooks/impl.inc:618
public OnPlayerConnect(playerid)
{
P:2("Hooks_OnPlayerConnect called: %d", playerid);
new
end = _:YSI_g_sCallbackEnd[ALS_OnPlayerConnect],
start = _:YSI_g_sCallbackStart[ALS_OnPlayerConnect],
ret = ALS_R_PlayerConnect;
while (start++ != end) // this is line 618!
{
#emit PUSH.S playerid
#emit PUSH.C 4
#emit CONST.alt YSI_g_sCallbackAddresses
#emit LOAD.S.pri start
//#emit INC.pri
//#emit STOR.S.pri start
#emit LIDX
#emit MOVE.alt
#emit LCTRL 6
#emit ADD.C 24
#emit PUSH.pri
#emit MOVE.pri
#emit SCTRL 6
#emit MOVE.alt
#emit CONST.pri 0xFFFFFFFE
#emit AND
#emit PUSH.pri
#emit LOAD.S.pri ret
#emit AND
#emit POP.alt
#emit OR
#emit STOR.S.pri ret
if (ret < 0) return ret + 1;
}
return ret;
}
Line YSI\y_iterate.inc:646
P:2("Iter_OnPlayerConnect end");
#if defined Itter_OnPlayerConnect
return Itter_OnPlayerConnect(playerid); // this is line 646
#else
return 1;
#endif


Thank you!

TwinkiDaBoss
05/12/2015, 10:18 AM
Show us the
PonistiSveVarijable
PonistiSve(playerid);

DusanInfinity
05/12/2015, 10:51 AM
Show us the
PonistiSveVarijable
PonistiSve(playerid);

I fix my problem, thank you!

One big mistake i found... When i use char variables, i need to replace this brackets [ ] with this { }... I forgot to do that...
Ex: PlayerPressedJump[playerid] = 0; to PlayerPressedJump{playerid} = 0;