16.07.2016, 21:51
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:
I don't know what is the problem.
Here's CreateZombieForPlayer:
Here's UpdatePlayer:
Sorry for the long code. Update player gets executed on OnGameModeInit:
Anyone can help me?
Also, on TextDraw, where the count of zombie should show, it goes negative and counts on negatively.
PHP код:
[17:32:45] [debug] Run 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] [debug] AMX 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
Here's CreateZombieForPlayer:
PHP код:
stock CreateZombieForPlayer(playerid,Float:x,Float:y,Float:z,Float:a,Float:distancespawn = 70.0,timerespawn = 20000)
{
if(PlayerZombieCount[playerid] > 0 ||IsZombieCreatedForPlayer(playerid) == true) return 0;
new str[128];
IsPlayerCreatedZombie[playerid] = 1;
DistanceZSpawn[playerid] = distancespawn;
TimerRespawnZombie[playerid] = timerespawn;
for(new i = 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;
}
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(strwep, sizeof(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(strwep, sizeof(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 2: pInfo[i][pTemp] += 4.0;
case 8: pInfo[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.0, i, str2, COLOR_GREY);
SendClientMessage(i,-1,"*"COL_RED" You freezed to death!");
SetPlayerHealth(i, 0.0);
}
if(IsPlayerInAnyVehicle(i))
{
switch(random(40))
{
case 5: pInfo[i][pTemp] += 0.2;
case 10: pInfo[i][pTemp] += 0.3;
case 15: pInfo[i][pTemp] += 0.1;
}
}
if(GetPlayerAnimationIndex(i))
{
new animname[32], animlib[32];
GetAnimationName(GetPlayerAnimationIndex(i), animlib, sizeof(animlib), animname, sizeof(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 < 8 || hour > 21)
{
if(IsPlayerMoving(i))
{
switch(random(600))
{
case 50: pInfo[i][pTemp] += 0.1;
case 12: pInfo[i][pTemp] += 0.4;
case 16: pInfo[i][pTemp] += 0.6;
case 200: pInfo[i][pTemp] += 0.5;
case 1: pInfo[i][pTemp] += 0.6;
case 7: pInfo[i][pTemp] += 0.7;
case 170: pInfo[i][pTemp] += 0.5;
}
}
}
if(hour < 0 || hour > 7)
{
if(IsPlayerMoving(i))
{
switch(random(200))
{
case 50: pInfo[i][pTemp] -= 0.9;
case 12: pInfo[i][pTemp] -= 2.1;
case 16: pInfo[i][pTemp] -= 5.1;
case 200: pInfo[i][pTemp] -= 1.3;
case 1: pInfo[i][pTemp] -= 0.9;
case 7: pInfo[i][pTemp] -= 3.1;
case 170: pInfo[i][pTemp] -= 2.1;
}
}
}
if(GetWeather() == 8 || GetWeather() == 16 || GetWeather() == 9 || GetWeather() == 32)
{
if(IsPlayerMoving(i))
{
switch(random(250))
{
case 50: pInfo[i][pTemp] -= 0.9;
case 12: pInfo[i][pTemp] -= 1.2;
case 16: pInfo[i][pTemp] -= 1.8;
case 80: pInfo[i][pTemp] -= 1.2;
}
}
}
else
{
if(IsPlayerMoving(i))
{
switch(random(49))
{
case 3: pInfo[i][pTemp] += 0.4;
case 9: pInfo[i][pTemp] += 0.2;
case 10: pInfo[i][pTemp] += 0.2;
case 26: pInfo[i][pTemp] += 0.3;
case 48: pInfo[i][pTemp] += 0.5;
}
}
}
}
}
if(pInfo[i][pBlood] <= 8000)
{
if(pInfo[i][pFade] == 0)
{
PlayerTextDrawShow(i, PlayerFade[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(i, 1);
pInfo[i][Backpack] = 1;
pInfo[i][BackpackSlots] = 16;
SetPlayerAttachedObject( i, 1, 371, 1, 0.000000, -0.100000, 0.000000, 3.000000, 90.000000, 1.000000, 1.000000, 1.000000, 1.000000);
RemoveSlotToInventory(i,"Czech Vest Pouch",1);
if(!IsPlayerInAnyVehicle(i))
{
ApplyAnimation(i, "BOMBER", "BOM_Plant",4.1,0,1,0,1000,1);
defer ResetAction(i, ACTION_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(i, 1);
pInfo[i][Backpack] = 2;
pInfo[i][BackpackSlots] = 28;
SetPlayerAttachedObject( i, 1, 1310, 1, 0.000000, -0.100000, 0.000000, 3.000000, 90.000000, 1.000000, 1.000000, 1.000000, 1.000000 );
RemoveSlotToInventory(i,"Alice Pack",1);
if(!IsPlayerInAnyVehicle(i))
{
ApplyAnimation(i, "BOMBER", "BOM_Plant",4.1,0,1,0,1000,1);
defer ResetAction(i, ACTION_ANIMATION);
}
}
}
if(PlayerHasItem(i,"Coyote Backpack"))
{
RemovePlayerAttachedObject(i, 1);
pInfo[i][Backpack] = 3;
pInfo[i][BackpackSlots] = 38;
SetPlayerAttachedObject( i, 1, 1550, 1, 0.200000, -0.200000, 0.000000, 0.000000, 85.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
RemoveSlotToInventory(i,"Coyote Backpack",1);
if(!IsPlayerInAnyVehicle(i))
{
ApplyAnimation(i, "BOMBER", "BOM_Plant",4.1,0,1,0,1000,1);
defer ResetAction(i, ACTION_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), animlib, sizeof(animlib), animname, sizeof(animname));
if (!strcmp(animname, "SWIM_CRAWL", true) && !IsPlayerInAnyVehicle(i))
{
new Float:velocityX, Float:velocityY, Float:velocityZ, Float:speed;
GetPlayerVelocity(i, velocityX, velocityY, velocityZ);
speed = floatsqroot((velocityX * velocityX) + (velocityY * velocityY) + (velocityZ * velocityZ) * 100);
if (floatround(speed, floatround_round) >= 3)
{
jBan(i, -1, "Fly Hack", 0);
}
}
if(GetPlayerAnimationIndex(i))
{
GetAnimationName(GetPlayerAnimationIndex(i), animlib, sizeof(animlib), animname, sizeof(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(vehicleid, vehicleVelocity[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 257: pInfo[i][pInfection] = 1;
case 183: pInfo[i][pInfection] = 1;
case 751: pInfo[i][pInfection] = 1;
case 521: pInfo[i][pInfection] = 1;
}
}
}
}
}
}
}
}
}
return 1;
}
PHP код:
repeat UpdatePlayer();
Also, on TextDraw, where the count of zombie should show, it goes negative and counts on negatively.