if(GetWeekDay() == 1 || GetWeekDay() == 4 || GetWeekDay() == 6) return SCM(playerid, COLOR_WHITE,, "You can use this command only Monday, Wednesday, Friday and Sunday.");
public GetWeekDay() { new year,month,day; getdate(year, month, day); new weekday, j, e; if (month <= 2) { month += 12; --year; } j = year % 100; e = year / 100; switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7) { case 0: weekday = 1; case 1: weekday = 2; case 2: weekday = 3; case 3: weekday = 4; case 4: weekday = 5; case 5: weekday = 6; case 6: weekday = 7; } return weekday; }
[18:10:10] [debug] Run time error 4: "Array index out of bounds" [18:10:10] [debug] AMX backtrace: [18:10:10] [debug] #0 001a86d0 in public cmd_attack (playerid=9, params[]=@0155f83c "") at D:\gamemode\gamemodes\exgaming.pwn:25599 [18:10:10] [debug] #1 native CallLocalFunction () from samp03svr [18:10:10] [debug] #2 0003c25c in public OnPlayerCommandText (playerid=9, cmdtext[]=@0155f81c "/attack") at D:\gamemode\pawno\include\zcmd.inc:102
The problem is in /attack command, specifically at line 25599. When you receive a run time error 4, always post the whole logs so we can know the upper bound index and the index it tried to access element from.
|
Attempted to read/write array element at negative index -1
InWar[TurfInfo[turf][zOwned]]
Not all, it's missing one important part. An example of what I meant in my previous post is:
pawn Код:
Код:
InWar[TurfInfo[turf][zOwned]] |
if(TurfInfo[turf][zOwned] == faction) return SS(playerid, COLOR_WHITE, "Nu iti poti ataca propriul turf.", "You can't attack your own turf.");
Is the version of the crashdetect plugin you have loaded an old one? It is apparently off (the line reported) and neither does print the index accessed/upper bound. Try to update to the latest version for more details.
Alright, this is a different report so post IsPlayerInTurf function. |
Is the version of the crashdetect plugin you have loaded an old one? It is apparently off (the line reported) and neither does print the index accessed/upper bound. Try to update to the latest version for more details.
Alright, this is a different report so post IsPlayerInTurf function. |
public IsPlayerInTurf(playerid, turfid) { if(IsPlayerConnected(playerid)) { if(turfid == -1 || turfid >= MAX_TURFS || turfid < 1) { return 0; } new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); if(x >= TurfInfo[turfid][zMinX] && x < TurfInfo[turfid][zMaxX] && y >= TurfInfo[turfid][zMinY] && y < TurfInfo[turfid][zMaxY]) { return 1; } } return 0; } public GetPlayerTurf(playerid) { for(new i = 1; i < sizeof(Turfs); i++) { if(IsPlayerInTurf(playerid, i)) { return i; } } return -1; }
new turf = GetPlayerTurf(playerid), faction = PlayerInfo[playerid][pMember], string[128], players; if(turf == 0 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf."); if(TurfInfo[turf][zOwned] == faction) return SS(playerid, COLOR_WHITE, "Nu iti poti ataca propriul turf.", "You can't attack your own turf.");
if(turf == 0 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf.");
if(turf == -1 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf.");
Problem is here:
Код:
new turf = GetPlayerTurf(playerid), faction = PlayerInfo[playerid][pMember], string[128], players; if(turf == 0 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf."); if(TurfInfo[turf][zOwned] == faction) return SS(playerid, COLOR_WHITE, "Nu iti poti ataca propriul turf.", "You can't attack your own turf."); So, change this: Код:
if(turf == 0 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf."); Код:
if(turf == -1 || turf >= MAX_TURFS) return SS(playerid, COLOR_WHITE, "Nu esti pe turf.", "You are not on a turf."); |