Server Crash
#1

My server cash and give infinite paydays

Code crash:
Quote:

[00:16:41] [debug] AMX backtrace:
[00:16:41] [debug] #0 0010b670 in ?? () from LGG.amx
[00:16:41] [debug] #1 002b101c in public ServerHeartbeat () from LGG.amx
[00:16:43] [debug] Run time error 4: "Array index out of bounds"
[00:16:43] [debug] Accessing element at negative index -1

code script:
Quote:

task ServerHeartbeat[1000]() {
new
iTempVar,
Float: l_fPos[3],
iIndex,
Float: l_fDist[4];

if(iAdverTimer >= 1)
--iAdverTimer;

if(++AdminWarning == 15) {
for(new z = 0; z < MAX_REPORTS; z++) {
if(ReportData[z][r_iBeingUsed] == 1) {
if(ReportData[z][r_iReportPriority] == 1 || ReportData[z][r_iReportPriority] == 2) {
Admin_Message(COLOR_LIGHTRED,"A priority report is pending.", 1);
break;
}
}
}
AdminWarning = 0;
}

RobbankUpdate();

foreach(Player, i) {
if(PlayerData[i][pStatus] == 0) continue;

GetPlayerPos(i, l_fPos[0], l_fPos[1], l_fPos[2]);
if(PlayerData[i][pAdminDuty] == 0 && !GetPVarInt(i, "BeingDragged")) {
iIndex = GetPlayerAnimationIndex(i);

l_fDist[0] = ((Player_fPos[i][0] < l_fPos[0]) ? (Player_fPos[i][0] - l_fPos[0]) : (l_fPos[0] - Player_fPos[i][0]));
l_fDist[1] = ((Player_fPos[i][1] < l_fPos[1]) ? (Player_fPos[i][1] - l_fPos[1]) : (l_fPos[1] - Player_fPos[i][1]));
l_fDist[2] = ((Player_fPos[i][2] < l_fPos[2]) ? (Player_fPos[i][2] - l_fPos[2]) : (l_fPos[2] - Player_fPos[i][2]));
l_fDist[3] = floatsqroot(floatpower(l_fDist[0], 2.0) + floatpower(l_fDist[1], 2.0) + floatpower(l_fDist[2], 2.0));

if(l_fDist[3] > MAX_AIRBREAK_DISTANCE) {
if(GetPlayerState(i) == PLAYER_STATE_ONFOOT) {
for(new l = 0; l < sizeof(airbreakIndexes); l ++) {
if(iIndex == airbreakIndexes[l]) {
if(!floatcmp(Player_fPos[i][2], l_fPos[2])) {
if(funcidx("OnPlayerAirbreak") != -1)
OnPlayerAirbreak(i);

break;
}
}
}
}
}
}

Player_fPos[i][0] = l_fPos[0];
Player_fPos[i][1] = l_fPos[1];
Player_fPos[i][2] = l_fPos[2];

if(GetPVarType(i, "hFind")) {
new Float:h_fX, Float:h_fY, Float:h_fZ, pID = GetPVarInt(i, "hFind");
if(IsPlayerConnected(pID)) {
GetPlayerPos(pID, h_fX, h_fY, h_fZ);
SetPlayerCheckpointEx(i, h_fX, h_fY, h_fZ, 4.0);
}
}

if(IsPlayerInAnyVehicle(i) && GetPlayerVehicleSeat(i) == 0) UpdatePlayerVehicleSpeedMeter(i);

if(iPlayerInVeh[i] > 2 && PlayerData[i][pAdmin] < 1) {
new szString[128];
format(szString, sizeof(szString), "AdmWarn:{FFFFFF} %s has been automaticly kicked for suspected hacking (Vehicle Teleports - Crash players).", getPlayerName(i));
Admin_Message(COLOR_LIGHTRED, szString, 1);
SendClientMessage(i, COLOR_LIGHTRED, "You have been automaticly kicked for suspected hacking.");
KickEx(i);
}
if(IsPlayerInAnyVehicle(i)) {
if(GetPlayerState(i) == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(i, 0);
else if(PlayerData[i][pWeapon][4] == 0) SetPlayerArmedWeapon(i, 0);
else SetPlayerArmedWeapon(i, 29);
}
if((iTempVar = GetPVarInt(i, "adT")) != 0) {
if(--iTempVar <= 0) DeletePVar(i, "adT");
else SetPVarInt(i, "adT", iTempVar);
}
if(PlayerData[i][pAdminDuty] == 0) {
if(playerTabbed[i] == 0) {
switch(PlayerData[i][pLevel]) {
case 0 .. 2: PlayerData[i][pPayCheck] += 1;
case 3 .. 4: PlayerData[i][pPayCheck] += 2;
case 5 .. 6: PlayerData[i][pPayCheck] += 3;
case 7 .. 8: PlayerData[i][pPayCheck] += 4;
case 9 .. 10: PlayerData[i][pPayCheck] += 5;
case 11 .. 12: PlayerData[i][pPayCheck] += 6;
case 13 .. 14: PlayerData[i][pPayCheck] += 7;
case 15 .. 16: PlayerData[i][pPayCheck] += 8;
case 17 .. 18: PlayerData[i][pPayCheck] += 9;
case 19 .. 20: PlayerData[i][pPayCheck] += 10;
default: PlayerData[i][pPayCheck] += 11;
}

if(++PlayerData[i][pConnectSeconds] >= 3600)
PayDay(i);
}
}
if(TaxiCallTime[i] > 0)
{
if(TaxiAccepted[i] != INVALID_PLAYER_ID)
{
if(IsPlayerConnected(TaxiAccepted[i]))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(TaxiAccepted[i], X, Y, Z);
SetPlayerCheckpointEx(i, X, Y, Z, 5);
g_iPlayerCheckpoint[i] = 17;
}
}
}
if(PlayerStoned[i] >= 3) {
PlayerStoned[i] += 1;
SetPlayerDrunkLevel(i, 40000);
if(PlayerStoned[i] == 50) {
PlayerStoned[i] = 0;
SetPlayerDrunkLevel(i, 0);
SendClientMessage(i, COLOR_GRAD1, "You're no longer stoned.");
}
}
if(GodMode{i} == 1)
{
new iVehicle = GetPlayerVehicleID(i);
new Float:iVehicleHealth;

if(PlayerData[i][pAdmin] >= 1 && PlayerData[i][pAdminDuty] == 1 && PlayerData[i][pUndercover] == 0) {
if(IsPlayerInAnyVehicle(i)) {
GetVehicleHealth(iVehicle, iVehicleHealth);
if(iVehicleHealth < 750.0) {
SetVehicleHealth(iVehicle, 1000.0);
RepairVehicle(iVehicle);
}
}
}
}
if(GetPVarInt(i, "MaterialRunTime")) SetPVarInt(i, "MaterialRunTime", GetPVarInt(i, "MaterialRunTime") + 1);
if(GetPVarInt(i, "DropCarTimeout")) SetPVarInt(i, "DropCarTimeout", GetPVarInt(i, "DropCarTimeout") - 1);
if(PlayerData[i][pJailTime] > 0 && --PlayerData[i][pJailTime] <= 0) {

SetPlayerInteriorEx(i, 0);
PlayerData[i][pINT] = 0;
SetPlayerVirtualWorldEx(i, 0);
PlayerData[i][pVW] = 0;
SetPlayerPosEx(i, 1544.5059,-1675.5673,13.5585);

PlayerData[i][pJailTime] = 0;
PhoneOnline[i] = 0;
SendClientMessage(i, COLOR_GRAD1,"You have paid your debt to society.");
GameTextForPlayer(i, "~g~Freedom~n~~w~Try to be a better citizen", 5000, 1);
ClearCrimes(i);
strcpy(PlayerData[i][pPrisonReason], "None", 12;
SetPlayerToTeamColor(i);

SetPlayerSkinEx(i, PlayerData[i][pSkin]);
}
if(PlayerData[i][pCash] != GetPlayerMoney(i))
{
/*if((GetPlayerAnimationIndex(i) == 1660) && ((PlayerData[i][pCash] - GetPlayerMoney(i)) == 1))
{
new Float:hp;
GetPlayerHealth(i, hp);
if(hp + 35 >= 100.0) pSSHealth[i] = 100.0;
else pSSHealth[i] = hp + 35.0;
}*/
ResetPlayerMoney(i);
GivePlayerMoney(i, PlayerData[i][pCash]);
}
new string[128];
new Float, Float:y, Float:z;
if(CalledCops[i] >= 1)
{
if(CopsCallTime[i] < 1) { CopsCallTime[i] = 0; HidePlayerBeaconForCops(i); CalledCops[i] = 0; }
else
{
CopsCallTime[i]--;
}
}
if(GlobalChatTimer{i} > 0) {
GlobalChatTimer{i}--;
}
if(PlayerData[i][pTutorialStepDelay] > 0)
{
PlayerData[i][pTutorialStepDelay]--;
}
if (PlayerData[i][pDrugsTime] > 0)
{
if (PlayerData[i][pDrugsTime] <= 60)
{
PlayerData[i][pDrugsTime]--;
}
}
if(PlayerData[i][pLawyerTime] > 0)
{
if(PlayerData[i][pLawyerTime] <= 60)
{
PlayerData[i][pLawyerTime]--;
}
}
if (PlayerData[i][pMechTime] > 0)
{
if (PlayerData[i][pMechTime] <= 60)
{
PlayerData[i][pMechTime]--;
}
}
if(CommandSpamTimes[i] != 0)
{
CommandSpamTimes[i]--;
}
if(TextSpamTimes[i] != 0)
{
TextSpamTimes[i]--;
}
if(NewbieTimer[i] > 0)
{
NewbieTimer[i]--;
}
if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK && JetPack{i} == 0 && PlayerData[i][pAdmin] < 4) {
format( string, sizeof( string ), "AdmWarn:{FFFFFF} %s (ID %d) may possibly be jetpack hacking.", getPlayerName(i), i);
Admin_Message(COLOR_LIGHTRED, string, 1);
format(string, sizeof(string), "%s (ID %d) may possibly be jetpack hacking.", getPlayerName(i), i);
Log("logs/hack.log", string);
if(++iJetPackHackWarnings{i} >= 5) {
format(string, sizeof(string), "%s (ID %d) has been auto banned for jetpack hacking.", getPlayerName(i), i);
Log("logs/hack.log", string);
scriptBan(i, "Script", "Jetpack hacking");
}
}
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(i);
if(!IsBicycle(vehicleid) && Fuel[vehicleid] > 0)
{
Fuel[vehicleid] -= GetPlayerSpeed(i)/1000.0;
if(Fuel[vehicleid] <= 0)
{
ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
GameTextForPlayer(i, "~r~out of fuel", 3000, 3);
SendClientMessage(i, COLOR_RED, "This vehicle is out of fuel!");
}
}
}
if(FindTime[i] >= 1) {
if(FindTime[i] == FindTimePoints[i]) {
FindTime[i] = 0;
FindTimePoints[i] = 0;
FindingPlayer[i] = -1;
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
DisablePlayerCheckpoint(i);
GameTextForPlayer(i, "~r~RedMarker gone", 2500, 1);
}
else {
format(string, sizeof(string), "%d", FindTimePoints[i] - FindTime[i]);
GameTextForPlayer(i, string, 1500, 6);
FindTime[i] += 1;
}
}
if(UsedFind[i] >= 1)
{
UsedFind[i] += 1;
if(UsedFind[i] >= 120)
{
UsedFind[i] = 0;
}
}
if(EMSCallTime[i] > 0)
{
if(EMSAccepted[i] != INVALID_PLAYER_ID)
{
if(IsPlayerConnected(EMSAccepted[i]))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(EMSAccepted[i], X, Y, Z);
new zone[MAX_ZONE_NAME];
GetPlayer3DZone(EMSAccepted[i], zone, sizeof(zone));
format(string, sizeof(string), "Your patient is located in %s.", zone);
SetPlayerCheckpointEx(i, X, Y, Z, 5);
g_iPlayerCheckpoint[i] = 16;
}
}
}
if(TrackCar[i])
{
GetVehiclePos(TrackCar[i], x, y, z);
SetPlayerCheckpointEx(i, x, y, z, 3);
}
if(PlayerCuffed{i} == 1)
{
if(PlayerCuffedTime[i] <= 0)
{
TogglePlayerControllable(i, 1);
PlayerCuffed{i} = 0;
PlayerCuffedTime[i] = 0;
ClearAnimations(i);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(i, X, Y, Z);
SetPlayerPosEx(i, X, Y, Z);
}
else
{
PlayerCuffedTime[i] -= 1;
}
}
if(PlayerCuffed{i} == 2)
{
if(PlayerCuffedTime[i] <= 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(i, X, Y, Z);
new copinrange;
foreach(Player, j)
{
if(IsPlayerInRangeOfPoint(j, 30, X, Y, Z) && GetPlayerProfession(j) == 1)
{
copinrange = 1;
}
}
if(copinrange == 0)
{
GameTextForPlayer(i, "~r~You broke the Cuffs, you are free!", 2500, 3);
TogglePlayerControllable(i, 1);
ClearAnimations(i, 1);
SetPlayerSpecialAction(i, SPECIAL_ACTION_NONE);
ClearAnimations(i);
PlayerCuffed{i} = 0;
PlayerCuffedTime[i] = 0;
}
else
{
PlayerCuffedTime[i] = 60;
}
}
else
{
PlayerCuffedTime[i] -= 1;
}
}
playerConnectedS[i]++;
if(playerSeconds[i] < gettime()-1 && playerTabbed[i] != 1 && playerConnectedS[i] >= 5 && 1 <= GetPlayerState(i) <= 3)
{
playerTabbed[i] = 1;
SetTimerEx("AFKick",1000,false,"d",i);
}
playerLastTyped[i]++;
GetPlayerPos(i, PlayerPos[i][0], PlayerPos[i][1], PlayerPos[i][2]);
if(PlayerPos[i][0] == PlayerPos[i][3] && PlayerPos[i][1] == PlayerPos[i][4] && PlayerPos[i][2] == PlayerPos[i][5] && playerTabbed[i] != 1)
{
if(playerLastTyped[i] < playerAFKTime[i]) playerAFKTime[i] = playerLastTyped[i];
if(playerAFK[i] != 0) playerAFKTime[i]++;
else playerAFK[i] = 1;
if(playerAFKTime[i] >= 900 && PlayerData[i][pAdmin] < 5)
{
SendClientMessage(i, COLOR_WHITE, "You have been kicked for being AFK more than 15 minutes.");
KickEx(i);
}
}
else
{
if(playerAFK[i] != 0) playerAFK[i] = 0, playerAFKTime[i] = 0;
}
PlayerPos[i][3] = PlayerPos[i][0];
PlayerPos[i][4] = PlayerPos[i][1];
PlayerPos[i][5] = PlayerPos[i][2];
}
}

Reply
#2

Enable debug level 3 and compile the script again.
Reply
#3

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Enable debug level 3 and compile the script again.
The problem persists
Reply
#4

Quote:
Originally Posted by jose005
Посмотреть сообщение
The problem persists
Indeed it does persist, I asked you to enable debug level 3 to show us the log the console prints, which now should point out the exact line in which the crash occurs.
Reply
#5

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Indeed it does persist, I asked you to enable debug level 3 to show us the log the console prints, which now should point out the exact line in which the crash occurs.
this is the line:

Quote:

if(TaxiCallTime[i] > 0)

Reply
#6

Bump.
Reply
#7

I can't understand this code, please indent it I will try to help you.
Reply
#8

Your code doesn't make any sense to me, is this supposed to be a function ? timer ? array ? which one ?
task ServerHeartbeat[1000]() {
remove [1000] if it's a function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)