14.08.2015, 08:30
Hello , i can't get this work , i have 25 turfs in my mysql database, i want to show an error when a player is not near them , i make this with IsPlayerInRange , don't ask why.
I get SERVER:Unknown command if i am not in a turf , and if i am it's goes SUCCESS!
Error:
I tried to put 25 instead of 26 but gamemode goes to Unknown.
I get SERVER:Unknown command if i am not in a turf , and if i am it's goes SUCCESS!
Error:
pawn Код:
[11:27:42] [debug] Run time error 4: "Array index out of bounds"
[11:27:42] [debug] Accessing element at index 26 past array upper bound 25
pawn Код:
new TurfInfo[26][ttInfo];
new TurfInfo[26];
CMD:attack(playerid, params[])
{
new turfid;
for(new xf = 0; xf <= sizeof(TurfInfo); xf++)
{
if(IsPlayerInRangeOfPoint(playerid, 4.0, TurfInfo[xf][ttPosX], TurfInfo[xf][ttPosY], TurfInfo[xf][ttPosZ]))
{
turfid = xf;
break;
}
}
if(turfid == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR!");
if(turfid > 0) return SendClientMessage(playerid, COLOR_WHITE, "SUCCES!");
return 1;
}