25.07.2012, 06:25
[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at negative index -1
[debug] AMX 0002271c in public turftaking <> from gm.amx
Hopefully someone can spot the error?
[debug] Accessing element at negative index -1
[debug] AMX 0002271c in public turftaking <> from gm.amx
Hopefully someone can spot the error?
Код:
forward turftaking(playerid); public turftaking(playerid) { new cpid = CP_GetActiveCheckPoint(playerid); new tmp,str[128]; for(new i; i < sizeof(turfs); i++) { if(cpid == turfs[i][E_TURF_CP_ID] && IsPlayerInCheckpoint(playerid) && IsPlayerInGang(playerid)) { TurfTimer[playerid]++; turfs[i][E_UNDERATTACK] = true; if(TurfTimer[playerid] == 30 && turfs[i][E_OWNER] == -2){ GangZoneStopFlashForAll(turfs[i][E_TURFID]); GangZoneHideForAll(turfs[i][E_TURFID]); INI_Open(ReturnGangFilename(g_playerdata[playerid][GANG])); tmp = INI_ReadInt("COLOUR"); INI_Save(); INI_Close(); turfs[i][E_COLOUR] = (tmp & 0xFFFFFF00 ) | 0x80; turfs[i][E_OWNER] = g_playerdata[playerid][GANG]; turfs[i][E_UNDERATTACK] = false; strcpy(turfs[i][E_NAME], g_playerdata[playerid][GANGNAME], MAX_STRING); for(new x =0 ; x < MAX_PLAYERS ; x++){ if(IsCop[x] == 0 ) GangZoneShowForPlayer(x,turfs[i][E_TURFID],turfs[i][E_COLOUR]); } TurfTimer[playerid] = 0; format(str,sizeof(str),"%s's ~s~Territory",g_playerdata[playerid][GANGNAME]); TextDrawSetString(turfs[i][E_TURFNAME],str); format(str,sizeof(str),"%s's Territory",g_playerdata[playerid][GANGNAME]); Update3DTextLabelText(turfs[i][E_CP_ID],COLOUR_YELLOW,str); TextDrawColor(turfs[i][E_TURFNAME], turfs[i][E_COLOUR]); GivePlayerXP(playerid, 2);//xp to player who taken the turf to themseleves GivePlayerMoney(playerid, 500); for(new z = 0; z < MAX_PLAYERS ; z++){ if(g_playerdata[playerid][GANG] == g_playerdata[z][GANG]) TextDrawShowForPlayer(z,TEXT_TurfIsYours); } SetTimerEx("ResetTimer",4000,false,"i",g_playerdata[playerid][GANG]); return 1; } if(TurfTimer[playerid] == 30){ strcpy(turfs[i][E_NAME], "~y~Territory", MAX_STRING); for(new z = 0; z < MAX_PLAYERS ; z++){ if(turfs[i][E_OWNER] == g_playerdata[z][GANG]) TextDrawShowForPlayer(z,TEXT_TurfLost); } SetTimerEx("ResetTimer",4000,false,"i",turfs[i][E_OWNER]); turfs[i][E_OWNER] = -2; turfs[i][E_COLOUR] = DEF_COLOUR_TURF; TextDrawSetString(turfs[i][E_TURFNAME],"~y~Territory"); TextDrawColor(turfs[i][E_TURFNAME], turfs[i][E_COLOUR]); Update3DTextLabelText(turfs[i][E_CP_ID],COLOUR_YELLOW,"Territory"); GangZoneHideForAll(turfs[i][E_TURFID]); for(new x =0 ; x < MAX_PLAYERS ; x++){ if(IsCop[x] == 0 ) GangZoneShowForPlayer(x,turfs[i][E_TURFID],turfs[i][E_COLOUR]); } GangZoneFlashForAll(turfs[i][E_TURFID],0xFF000080); GivePlayerXP(playerid, 2);//xp to player who have taken down turf from other player GivePlayerMoney(playerid, 500); } if(TurfTimer[playerid] >= 60){ GangZoneStopFlashForAll(turfs[i][E_TURFID]); GangZoneHideForAll(turfs[i][E_TURFID]); INI_Open(ReturnGangFilename(g_playerdata[playerid][GANG])); tmp = INI_ReadInt("COLOUR"); INI_Save(); INI_Close(); turfs[i][E_COLOUR] = (tmp & 0xFFFFFF00 ) | 0x80; turfs[i][E_OWNER] = g_playerdata[playerid][GANG]; turfs[i][E_UNDERATTACK] = false; format(str,sizeof(str),"%s's ~s~Territory",g_playerdata[playerid][GANGNAME]); TextDrawSetString(turfs[i][E_TURFNAME],str); TextDrawColor(turfs[i][E_TURFNAME], turfs[i][E_COLOUR]); format(str,sizeof(str),"%s's Territory",g_playerdata[playerid][GANGNAME]); Update3DTextLabelText(turfs[i][E_CP_ID],COLOUR_YELLOW,str); strcpy(turfs[i][E_NAME], g_playerdata[playerid][GANGNAME], MAX_STRING); for(new x =0 ; x < MAX_PLAYERS ; x++){ if(IsCop[x] == 0 ) GangZoneShowForPlayer(x,turfs[i][E_TURFID],turfs[i][E_COLOUR]); } TurfTimer[playerid] = 0; GivePlayerXP(playerid, 2);//xp to player who have taken the turf GivePlayerMoney(playerid, 500); for(new z = 0; z < MAX_PLAYERS ; z++){ if(g_playerdata[playerid][GANG] == g_playerdata[z][GANG]) TextDrawShowForPlayer(z,TEXT_TurfIsYours); } INI_Open(ReturnGangFilename(g_playerdata[playerid][GANG])); g_playerdata[playerid][GBANK] = INI_ReadInt("Bank"); g_playerdata[playerid][GBANK] += 500; INI_WriteInt("Bank",g_playerdata[playerid][GBANK]); INI_Save(); INI_Close(); turfs[i][E_UNDERATTACK] = false; SetTimerEx("ResetTimer",4000,false,"i",g_playerdata[playerid][GANG]); return 1; } turffix = i; SetTimerEx("turftaking",1000, false, "i", playerid); print("Turf"); return 1; } } GangZoneStopFlashForAll(turfs[turffix][E_TURFID]); turfs[turffix][E_UNDERATTACK] = false; TurfTimer[playerid] = 0; return 1; }