Accessing element at index 65535 past array upper bound 999
#1

Hello. I'm using Kittens DayZ gamemode v9.1, and I'm experiencing this weird problem. If I run the server with 200 slots, and 100 maxnpc, everything works as intended. But my server host is just 30 slots. When I tried to run the GM there, it showed an warning, that maxnpc is more than max players. So I changed maxnpc to 15, half of max players. Now it starts without warnings, but when I start playing, and zombies should start appearing, this pops up in console:
PHP код:
[17:32:45] [debugRun time error 4"Array index out of bounds"
[17:32:45] [debug]  Accessing element at index 65535 past array upper bound 999
[17:32:45] [debugAMX backtrace:
[
17:32:45] [debug#0 0059b330 in CreateZombieForPlayer (playerid=0, Float:x=1391.86682, Float:y=-1386.29333, Float:z=14.09060, Float:a=151.00000, Float:distancespawn=70.00000, timerespawn=20000) at C:\Users\Madars\Desktop\DayZ 9.1\gamemodes\dayzmysql.pwn:17810
[17:32:45] [debug#1 004b8910 in UpdatePlayer () at C:\Users\Madars\Desktop\DayZ 9.1\gamemodes\dayzmysql.pwn:4154
[17:32:45] [debug#2 004b7a64 in public UpdatePlayer@_yT () at C:\Users\Madars\Desktop\DayZ 9.1\gamemodes\dayzmysql.pwn:4108 
I don't know what is the problem.

Here's CreateZombieForPlayer:
PHP код:
stock CreateZombieForPlayer(playerid,Float:x,Float:y,Float:z,Float:a,Float:distancespawn 70.0,timerespawn 20000)
{
    if(
PlayerZombieCount[playerid] > ||IsZombieCreatedForPlayer(playerid) == true) return 0;
    new 
str[128];
    
IsPlayerCreatedZombie[playerid] = 1;
    
DistanceZSpawn[playerid] = distancespawn;
    
TimerRespawnZombie[playerid] = timerespawn;
    for(new 
0;i<MAX_ZOMBIE_FOR_PLAYER;i++)
    {
        
format(str,sizeof(str),"%i_Zombie[%d]",playerid,MAX_PLAYERS-(i+playerid));
        
ZombieForPlayerID[playerid][i] = FCNPC_Create(str);
        
a=float(random(360));
        
x=x+DistanceZSpawn[playerid]*floatsin(a,degrees);
        
y=y+DistanceZSpawn[playerid]*floatcos(a,degrees);
        
z=z+0.7;
        
FCNPC_Spawn(ZombieForPlayerID[playerid][i],DayZ_Z_RandSkinZombie[random(sizeof(DayZ_Z_RandSkinZombie))],x,y,z+0.7);
        
FCNPC_SetAngle(ZombieForPlayerID[playerid][i],a);
        
ZombieAttackPID[ZombieForPlayerID[playerid][i]] = playerid;
        
PlayerZombieCount[playerid]++;
        
ZombieTimer[ZombieForPlayerID[playerid][i]] = repeat ZombieMove(ZombieForPlayerID[playerid][i]);
        
SetPlayerColor(ZombieForPlayerID[playerid][i],0xFF0000FF);
        
IsAZombie[ZombieForPlayerID[playerid][i]] = 1;
    }
    
ZombiesAlive += MAX_ZOMBIE_FOR_PLAYER;
    
PlayerZTimer[playerid] = repeat RespawnZombieForPlayer(playerid);
    return 
1;

Here's UpdatePlayer:
PHP код:
timer UpdatePlayer[1000]()
{
    if(
PlayersAlive >= 1)
    {
        foreach(
Player,i)
        {
            if(!
IsPlayerNPC(i))
            {
                if(
isPlayerInMenu[i] == 0)
                {
                    if(
pInfo[i][pLogged] == 1)
                    {
                        if(
pInfo[i][IsPlayerSpawned] == 1)
                        {
                            
SetPlayerHealth(i,100.0);
                            
CheckBars(i);
                            
DecreaseBars(i);
                            
pInfo[i][pAliveTime]++;
                            
UpdatePlayer3DName(i);
                            if(
IsSpecing[i] == 0)
                            {
                                
format(strupdate,sizeof(strupdate),"Zombies Killed: %i~n~Headshots: %i~n~Murders: %i~n~Bandits Killed: %i~n~Blood: %i~n~Zombies: %i~n~Temperature: %0.2f F~n~Alive Time: %s~n~Name: %s",
                                
pInfo[i][ZombiesKilled],pInfo[i][Headshots],pInfo[i][Murders],pInfo[i][BanditsKilled],pInfo[i][pBlood],ZombiesAlive,pInfo[i][pTemp],TimeConvert(pInfo[i][pAliveTime]),PlayerName(i));
                                
format(strwepsizeof(strwep), "%s / %i Ammo"DayZSA_GetWeaponName(i),GetPlayerAmmo(i));
                                
PlayerTextDrawSetString(i,DebugInfo[i],strupdate);
                                
PlayerTextDrawSetString(i,Debug_GunInfo[i],strwep);
                            }
                            else
                            {
                                
format(strupdate,sizeof(strupdate),"Zombies Killed: %i~n~Headshots: %i~n~Murders: %i~n~Bandits Killed: %i~n~Zombies: %i~n~Temperature: %0.2f F~n~Alive Time: %s~n~Name: %s",
                                
pInfo[spectatorid[i]][ZombiesKilled],pInfo[spectatorid[i]][Headshots],pInfo[spectatorid[i]][Murders],pInfo[spectatorid[i]][BanditsKilled],ZombiesAlive,pInfo[spectatorid[i]][pTemp],TimeConvert(pInfo[spectatorid[i]][pAliveTime]),PlayerName(spectatorid[i]));
                                
format(strwepsizeof(strwep), "%s / %i Ammo"DayZSA_GetWeaponName(spectatorid[i]),GetPlayerAmmo(spectatorid[i]));
                                
PlayerTextDrawSetString(i,DebugInfo[i],strupdate);
                                
PlayerTextDrawSetString(i,Debug_GunInfo[i],strwep);
                                
//format(strupdate,sizeof(strupdate),"Zombies Killed: %i~n~Headshots: %i~n~Murders: %i~n~Bandits Killed: %i~n~Blood: %i~n~Zombies Alive: %i(%i)~n~Temperature: %0.2f F~n~Alive Time: %s~n~Wep: %s / %i AMMO~n~Name: %s",
                                //pInfo[spectatorid[i]][ZombiesKilled], pInfo[spectatorid[i]][Headshots],pInfo[spectatorid[i]][Murders],pInfo[spectatorid[i]][BanditsKilled],pInfo[spectatorid[i]][pBlood],ZombiesAlive,ZombieMax,pInfo[spectatorid[i]][pTemp],TimeConvert(pInfo[spectatorid[i]][pAliveTime]),DayZSA_GetWeaponName(i),GetPlayerAmmo(i),PlayerName(i));
                            
}
                            if(
pInfo[i][ZombiesWarn] == 8)
                            {
                                if(
IsZombieCreatedForPlayer(i) == false)
                                {
                                    new 
Float:x,Float:y,Float:z,Float:a;
                                    
GetPlayerPos(i,x,y,z);
                                    
GetPlayerFacingAngle(i,a);
                                    
CreateZombieForPlayer(i,x,y,z,a);
                                }
                            }
                            if(
pInfo[i][ZombiesWarn] == 0)
                            {
                                if(
IsZombieCreatedForPlayer(i) == true)
                                {
                                    
DestroyZombieForPlayer(i);
                                }
                                
pInfo[i][ZombiesWarn] = 1;
                            }
                            if(
pInfo[i][ZombiesWarn] >= 8)
                            {
                                
pInfo[i][ZombiesWarn] = 8;
                            }
                            if(
pInfo[i][ZombiesWarn] <= 0)
                            {
                                
pInfo[i][ZombiesWarn] = 1;
                            }
                            
UpdateVehicleStatus(i);
                               
ChangeTextdrawColor(i);
                            
UpdateVehicleParts(i);
                            
StartVehicle(i);
                            
CheckPlayerColor(i);
                            if(
GetPlayerPing(i) >= 850)
                            {
                                
SendClientMessage(i, -1""chat""COL_RED" You have been kicked. Reason: High Ping Over 850");
                                
KickEx(i);
                            }
                            if(
pInfo[i][pTemp] >= 87.0)
                            {
                                
pInfo[i][pTemp] = 87.0;
                            }
                            if(
IsPlayerInWater(i))
                            {
                                
pInfo[i][pTemp] -= 0.9;
                            }
                             if(
IsPlayerInRangeOfPoint(i,3.5,CampFire[GetCampID(i)][xTent],CampFire[GetCampID(i)][yTent],CampFire[GetCampID(i)][zTent]))
                            {
                                if(!
IsPlayerMoving(i))
                                {
                                    switch(
random(20))
                                    {
                                        case 
2pInfo[i][pTemp] += 4.0;
                                        case 
8pInfo[i][pTemp] += 2.1;
                                    }
                                }
                            }
                            if(
pInfo[i][pTemp] <= -00.0)
                            {
                                new 
str2[180];
                                 
pInfo[i][pInfection] = 0;
                                 
pInfo[i][pTemp] = 100.0;
                                
format(str2,sizeof(str2),"*"COL_RED" %s(%i) has freezed to death!",PlayerName(i),i);
                                
ProxDetector(60.0istr2COLOR_GREY);
                                
SendClientMessage(i,-1,"*"COL_RED" You freezed to death!");
                                
SetPlayerHealth(i0.0);
                            }
                            if(
IsPlayerInAnyVehicle(i))
                            {
                                switch(
random(40))
                                   {
                                    case 
5pInfo[i][pTemp] += 0.2;
                                    case 
10pInfo[i][pTemp] += 0.3;
                                       case 
15pInfo[i][pTemp] += 0.1;
                                }
                            }
                            if(
GetPlayerAnimationIndex(i))
                            {
                                new 
animname[32], animlib[32];
                                
GetAnimationName(GetPlayerAnimationIndex(i), animlibsizeof(animlib), animnamesizeof(animname));
                                if(!
strcmp(animname"IDLE_stance"true) || !strcmp(animname"IDLE_armed"true) || !strcmp(animname"IDLE_tired"true))
                                {
                                    
// N / A
                                
}
                                else
                                {
                                    new 
hour,minute,second;
                                    
gettime(hour,minute,second);
                                    if(
hour || hour 21)
                                    {
                                        if(
IsPlayerMoving(i))
                                        {
                                            switch(
random(600))
                                            {
                                                case 
50pInfo[i][pTemp] += 0.1;
                                                case 
12pInfo[i][pTemp] += 0.4;
                                                case 
16pInfo[i][pTemp] += 0.6;
                                                case 
200pInfo[i][pTemp] += 0.5;
                                                case 
1pInfo[i][pTemp] += 0.6;
                                                case 
7pInfo[i][pTemp] += 0.7;
                                                case 
170pInfo[i][pTemp] += 0.5;
                                            }
                                        }
                                    }
                                    if(
hour || hour 7)
                                    {
                                        if(
IsPlayerMoving(i))
                                        {
                                            switch(
random(200))
                                            {
                                                case 
50pInfo[i][pTemp] -= 0.9;
                                                case 
12pInfo[i][pTemp] -= 2.1;
                                                case 
16pInfo[i][pTemp] -= 5.1;
                                                case 
200pInfo[i][pTemp] -= 1.3;
                                                case 
1pInfo[i][pTemp] -= 0.9;
                                                case 
7pInfo[i][pTemp] -= 3.1;
                                                case 
170pInfo[i][pTemp] -= 2.1;
                                            }
                                        }
                                    }
                                    if(
GetWeather() == || GetWeather() == 16 || GetWeather() == || GetWeather() == 32)
                                    {
                                        if(
IsPlayerMoving(i))
                                        {
                                            switch(
random(250))
                                            {
                                                case 
50pInfo[i][pTemp] -= 0.9;
                                                case 
12pInfo[i][pTemp] -= 1.2;
                                                case 
16pInfo[i][pTemp] -= 1.8;
                                                case 
80pInfo[i][pTemp] -= 1.2;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if(
IsPlayerMoving(i))
                                        {
                                            switch(
random(49))
                                            {
                                                case 
3pInfo[i][pTemp] += 0.4;
                                                case 
9pInfo[i][pTemp] += 0.2;
                                                case 
10pInfo[i][pTemp] += 0.2;
                                                case 
26pInfo[i][pTemp] += 0.3;
                                                case 
48pInfo[i][pTemp] += 0.5;
                                            }
                                        }
                                    }
                                }
                            }
                            if(
pInfo[i][pBlood] <= 8000)
                            {
                                if(
pInfo[i][pFade] == 0)
                                {
                                    
PlayerTextDrawShow(iPlayerFade[i]);
                                    
pInfo[i][pFade] = 1;
                                }
                            }
                            if(
PlayerHasItem(i,"None"))
                            {
                                
RemoveSlotToInventory(i,"None",1);
                            }
                            if(
PlayerHasItem(i,"Empty Slot"))
                            {
                                
RemoveSlotToInventory(i,"Empty Slot",1);
                            }
                            if(
PlayerHasItem(i,"0\tEmpty Slot"))
                            {
                                
RemoveSlotToInventory(i,"0\tEmpty Slot",1);
                            }
                            if(
PlayerHasItem(i,"mpty Slot"))
                            {
                                
RemoveSlotToInventory(i,"mpty Slot",1);
                            }
                              if(
GetPlayerMoney(i) >= 1)
                              {
                                
jBan(i, -1"Money Hack"0);
                            }
                            if(
GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK)
                            {
                                
jBan(i, -1"Jetpack Hack"0);
                            }
                            new 
Float:armor;
                            
GetPlayerArmour(i,armor);
                            if(
armor 1)
                            {
                                
jBan(i, -1"Armour Hack"0);
                            }
                            if(
PlayerHasItem(i,"Coyote Patrol Pack"))
                            {
                                
SendClientMessage(i,-1,"*"COL_RED" You already have an larger backpack!");
                                
RemoveSlotToInventory(i,"Coyote Patrol Pack",1);
                            }
                            if(
PlayerHasItem(i,"Czech Vest Pouch"))
                            {
                                if(
pInfo[i][BackpackSlots] >= 28)
                                {
                                    
SendClientMessage(i,-1,"*"COL_RED" You already have an larger backpack!");
                                    
RemoveSlotToInventory(i,"Czech Vest Pouch",1);
                                }
                                else
                                {
                                    
RemovePlayerAttachedObject(i1);
                                    
pInfo[i][Backpack] = 1;
                                    
pInfo[i][BackpackSlots] = 16;
                                    
SetPlayerAttachedObjecti137110.000000, -0.1000000.0000003.00000090.0000001.0000001.0000001.0000001.000000);
                                    
RemoveSlotToInventory(i,"Czech Vest Pouch",1);
                                       if(!
IsPlayerInAnyVehicle(i))
                                    {
                                        
ApplyAnimation(i"BOMBER""BOM_Plant",4.1,0,1,0,1000,1);
                                        
defer ResetAction(iACTION_ANIMATION);
                                    }
                                }
                            }
                            if(
PlayerHasItem(i,"Alice Pack"))
                            {
                                if(
pInfo[i][BackpackSlots] >= 38)
                                {
                                    
SendClientMessage(i,-1,"*"COL_RED" You already have an larger backpack!");
                                    
RemoveSlotToInventory(i,"Alice Pack",1);
                                }
                                else
                                {
                                    
RemovePlayerAttachedObject(i1);
                                    
pInfo[i][Backpack] = 2;
                                    
pInfo[i][BackpackSlots] = 28;
                                    
SetPlayerAttachedObjecti1131010.000000, -0.1000000.0000003.00000090.0000001.0000001.0000001.0000001.000000 );
                                    
RemoveSlotToInventory(i,"Alice Pack",1);
                                     if(!
IsPlayerInAnyVehicle(i))
                                    {
                                        
ApplyAnimation(i"BOMBER""BOM_Plant",4.1,0,1,0,1000,1);
                                        
defer ResetAction(iACTION_ANIMATION);
                                    }
                                }
                            }
                            if(
PlayerHasItem(i,"Coyote Backpack"))
                            {
                                
RemovePlayerAttachedObject(i1);
                                
pInfo[i][Backpack] = 3;
                                
pInfo[i][BackpackSlots] = 38;
                                
SetPlayerAttachedObjecti1155010.200000, -0.2000000.0000000.00000085.0000000.0000001.0000001.0000001.000000 );
                                
RemoveSlotToInventory(i,"Coyote Backpack",1);
                                if(!
IsPlayerInAnyVehicle(i))
                                {
                                    
ApplyAnimation(i"BOMBER""BOM_Plant",4.1,0,1,0,1000,1);
                                    
defer ResetAction(iACTION_ANIMATION);
                                }
                            }
                            if(
IsPlayerInWater(i))
                            {
                                
pInfo[i][pHunger]--;
                                
pInfo[i][pThrist]--;
                                if(
PlayerHasItem(i,"Empty Water Bottle"))
                                {
                                    
RemoveSlotToInventory(i,"Empty Water Bottle",1);
                                    
AddSlotToInventoryWorld(i,"Full Water Bottle",1);
                                }
                                
DayZSA_SetPlayerNoiseLevel(i,4);
                                
DayZSA_SetPlayerEyeLevel(i,2);
                            }
                            new 
animname[32], animlib[32];
                            
GetAnimationName(GetPlayerAnimationIndex(i), animlibsizeof(animlib), animnamesizeof(animname));
                            if (!
strcmp(animname"SWIM_CRAWL"true) && !IsPlayerInAnyVehicle(i))
                            {
                                new 
Float:velocityXFloat:velocityYFloat:velocityZFloat:speed;
                                
GetPlayerVelocity(ivelocityXvelocityYvelocityZ);
                                
speed floatsqroot((velocityX velocityX) + (velocityY velocityY) + (velocityZ velocityZ) * 100);
                                if (
floatround(speedfloatround_round) >= 3)
                                {
                                
jBan(i, -1"Fly Hack"0);
                                }
                            }
                            if(
GetPlayerAnimationIndex(i))
                            {
                                
GetAnimationName(GetPlayerAnimationIndex(i), animlibsizeof(animlib), animnamesizeof(animname));
                                if(!
strcmp(animlib"PARACHUTE"true) && !strcmp(animname"FALL_SkyDive_Accel"true))
                                {
                                    if(
GetPlayerWeapon(i) != 46)
                                    {
                                        
jBan(i, -1"Fly Hack"0);
                                    }
                                }
                            }
                            if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
                              {
                                new 
vehicleid GetPlayerVehicleID(i);
                                if(
DayZSA_GetVehicleSpeed(vehicleid) > MAX_SPEED)
                                   {
                                      if(
GetVehicleModel(vehicleid) != 487)
                                     {
                                           new 
Float:vehicleVelocity[3];
                                          
GetVehicleVelocity(vehicleidvehicleVelocity[0], vehicleVelocity[1], vehicleVelocity[2]);
                                        if(
vehicleVelocity[2] > -0.5)
                                         {
                                            
jBan(i, -1"Veicle Speed Hack"0);
                                        }
                                    }
                                }
                            }
                            if(
GetPlayerState(i) == PLAYER_STATE_PASSENGER || GetPlayerState(i) == PLAYER_STATE_DRIVER)
                            {
                                
SetPlayerArmedWeapon(i,0);
                            }
                            if(
pInfo[i][pTemp] <= 36.0)
                            {
                                if(
pInfo[i][pInfection] == 0)
                                {
                                    switch(
random(800))
                                    {
                                        case 
257pInfo[i][pInfection] = 1;
                                        case 
183pInfo[i][pInfection] = 1;
                                        case 
751pInfo[i][pInfection] = 1;
                                        case 
521pInfo[i][pInfection] = 1;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 
1;

Sorry for the long code. Update player gets executed on OnGameModeInit:
PHP код:
repeat UpdatePlayer(); 
Anyone can help me?

Also, on TextDraw, where the count of zombie should show, it goes negative and counts on negatively.
Reply
#2

The problem is with ZombieForPlayerID[playerid][i]. FCNPC_Create returns INVALID_ENTITY_ID (limit reached?) so to avoid it:
pawn Код:
if ((ZombieForPlayerID[playerid][i] = FCNPC_Create(str)) == INVALID_ENTITY_ID) break;
When it cannot create more NPCs, it stops the loop. Have a variable that counts the NPCs created (after the above line) and add that amount (instead of MAX_ZOMBIE_FOR_PLAYER which may not be true that all of them were created) to ZombiesAlive variable.
Reply
#3

I'm sorry for being such a noob, but could you please show me, where I should add that above line? And what did you mean with the variable that count's NPC's? I've gout no idea how to create that.
Reply
#4

In CreateZombieForPlayer function, replace:

pawn Код:
ZombieForPlayerID[playerid][i] = FCNPC_Create(str);
with
pawn Код:
if ((ZombieForPlayerID[playerid][i] = FCNPC_Create(str)) == INVALID_ENTITY_ID) break;
ZombiesCountForPlayer++;
---

pawn Код:
ZombiesAlive += MAX_ZOMBIE_FOR_PLAYER;
with
pawn Код:
ZombiesAlive += ZombiesCountForPlayer;
Last, declare the variable along with "str":
pawn Код:
new str[128], ZombiesCountForPlayer;
---

It will add only the amount of zombies were created.
Reply
#5

Thank you for your efforts in helping me.

I've ran into another problem - error 017: undefined symbol "INVALID_ENTITY_ID"
Reply
#6

The plugin's thread mentioned so I thought it would be defined. Anyway, replace it with 65535 or INVALID_PLAYER_ID (more readable form).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)