[debug] Run time error 4: "Array index out of bounds"
#1

My server has 3 factions, and for some reason the first one(OG) is being bugged. Randomly the player will spawn with no weapons and armour due and the server will receive a warning "[debug] Run time error 4: "Array index out of bounds
Quote:

"[19:45:12] [debug] Accessing element at index 4 past array upper bound 2
[19:45:12] [debug] AMX backtrace:
[19:45:12] [debug] #0 0000657c in public OnPlayerSpawn (playerid=0) at D:\testing this\gamemodes\daddy.pwn:1002"

I have tried what not but it seems pointless so I came here to see if somebody can help me out. This is the code:
PHP код:
new Float:OGSP[3][4] = {
{
2275.755173.932934.983498.1074},
{
2269.661661.794126.4844281.2002},
{
2285.201284.820226.4844298.2320}
};
if(
gTeam[playerid] == OG)
    {
    if(
dead[playerid] == 0)
    {
    
SetPlayerPos(playerid,OGSP[rand][0],OGSP[rand][1],OGSP[rand][2]); //1003rd line where I get the error from.
    
SetPlayerFacingAngle(playerid,OGSP[rand][3]);
    
SetPlayerArmour(playerid100);
    
SetCameraBehindPlayer(playerid);
    
GivePlayerWeapon(playerid24300);
    return 
1;
    } 
Reply
#2

Код:
new rand = random(sizeof(OGSP));
Reply
#3

Thank you, this worked pretty well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)