PDA

View Full Version : Please help!!


RcoN!
10/10/2011, 08:14 PM
iam used crashdetect plugin

detect new warnings



gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".


what is the error ?

my function in playerdeath


public OnPlayerDeath(playerid, killerid, reason)
{
DeathCamera(playerid);

Informacion[playerid][Deaths]++;

GameTextForPlayer(killerid,KSMensajes[random(sizeof(KSMensajes))], 3000, 6);

SendDeathMessage(killerid, playerid, reason);

SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);

GivePlayerMoney(killerid,1000);


if(EnZona[playerid] == 0)
{
OnWeaponDrop(playerid);
}

if(EnZona[killerid] == 0)
{
new ArmaCheck = GetPlayerWeapon(killerid);
if(ArmaCheck == 35 || ArmaCheck == 36 || ArmaCheck == 37 || ArmaCheck == 38 || ArmaCheck == 39)
{
new string[300],wea[500];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, PlayerName, MAX_PLAYER_NAME);
new year,month,day; getdate(year, month, day);
new hour,minute,second; gettime(hour,minute,second);

format(string,sizeof(string),"* Admin NPC kickeo a %s (Armas prohibidas)", PlayerName);
SendClientMessageToAll(naranja,string);
print(string);

format(wea,sizeof(wea),"{FFFFFF}Disculpa %s, tu has sido Kickeado del servidor!\
\n\n{FFFFFF}Admin: NPC\
\n{FFFFFF}Razon: Armas prohibidas.\
\n{FFFFFF}Fecha: %i/%i/%i Hora: %i:%i :%i\
\n\n{FFFFFF}* Intenta no ser un novato y vuelve sin cheats.",PlayerName,day,month,year, hour, minute, second);
ShowPlayerDialog(killerid, 8000, DIALOG_STYLE_MSGBOX, " * ", wea, "OK", "");

for(new p = 0; p < MAX_PLAYERS; p++) {
if(IsPlayerConnected(p)) {
PlayerPlaySound(p,1140,0.0,0.0,0.0);}}
Kick(killerid);
}
}

//Duelo
new
sString[428],
pNamexd[MAX_PLAYER_NAME],
zName[MAX_PLAYER_NAME],
Float:Health,
Float:Armor;

if(g_IsPlayerDueling[playerid] == 1 && g_IsPlayerDueling[killerid] == 1)
{
GetPlayerHealth(killerid, Health);
GetPlayerArmour(killerid, Armor);
SetPlayerVirtualWorld(killerid, 0);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(killerid, 0);
//SpawnPlayer(playerid);
SpawnPlayer(killerid);

GetPlayerName(playerid, pNamexd, MAX_PLAYER_NAME);
GetPlayerName(killerid, zName, MAX_PLAYER_NAME);

if(Health > 90.0 && Armor > 90.0)
{
format(sString, sizeof(sString),"{770CC9}* %s a ganado el duelo contra %s! y termino la batalla con %.2f de vida , y %.2f de blindaje!", zName,pNamexd,Health,Armor);
SendClientMessageToAll(0xFF8040FF, sString);

g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid] = 0;
g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid] = 0;
g_DuelInProgress = 0;

EnZona[playerid] = 0;
EnZona[killerid] = 0;
return 1;
}
else
{
format(sString, sizeof(sString),"{770CC9}* %s a ganado el duelo contra %s! y termino la batalla con %.2f de vida , y %.2f de blindaje!", zName,pNamexd,Health,Armor);
SendClientMessageToAll(0xFF8040FF, sString);

g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid] = 0;
g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid] = 0;
g_DuelInProgress = 0;

EnZona[playerid] = 0;
EnZona[killerid] = 0;
return 1;
}
}

new Float:XD, Float:YD, Float:ZD;
GetPlayerPos(killerid, XD, YD, ZD);
if(IsPlayerInVehicle(killerid,GetPlayerVehicleID(k illerid)))
{

if(reason == 49)//carkill
{
SetPlayerPos(killerid, XD, YD, ZD+50); GivePlayerWeapon(killerid, 46, 1);
GameTextForPlayer(killerid, "~r~NO HAGAS CAR-KILL!", 4000, 4);

}

if(reason == 50)//helikill
{
SetPlayerPos(killerid, XD, YD, ZD+50); GivePlayerWeapon(killerid, 46, 1);
GameTextForPlayer(killerid, "~r~NO HAGAS HELI-KILL!", 4000, 4);
}

if(Informacion[killerid][GodCar] == 1)
{
if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(killerid) == PLAYER_STATE_DRIVER && (reason == WEAPON_TEC9 || reason == WEAPON_UZI || reason == WEAPON_MP5) && GetDistanceBetweenPlayers(playerid,killerid) < 100)
{
SetPlayerPos(killerid, XD, YD, ZD+50); GivePlayerWeapon(killerid, 46, 1);
GameTextForPlayer(killerid, "~g~~h~No hagas drive by!~n~~b~~h~autofix apagado!", 4000, 4);
Informacion[killerid][GodCar] = 0;
}
}
}

if(Joined[playerid] == true)
{
JoinCount--;
Joined[playerid] = false;
DestroyVehicle(CreatedRaceVeh[playerid]);
DisablePlayerRaceCheckpoint(playerid);
CPProgess[playerid] = 0;
KillTimer(InfoTimer[playerid]);
}

if(BuildRace[playerid] == 1)
{
BuildRace[playerid] = 0;
}

if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
{
Informacion[killerid][Killsxd]++;
}

for(new x=0; x<MAX_PLAYERS; x++)
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && Informacion[x][SpecID] == playerid)
AdvanceSpectate(x);
return 1;
}


please please helpme

matias1994
10/10/2011, 08:21 PM
if(EnZona[killerid] == 0)
{
new ArmaCheck = GetPlayerWeapon(killerid);
if(ArmaCheck == 35 || ArmaCheck == 36 || ArmaCheck == 37 || ArmaCheck == 38 || ArmaCheck == 39)
{
new string[300],wea[500];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, PlayerName, MAX_PLAYER_NAME);
new year,month,day; getdate(year, month, day);
new hour,minute,second; gettime(hour,minute,second);

format(string,sizeof(string),"* Admin NPC kickeo a %s (Armas prohibidas)", PlayerName);
SendClientMessageToAll(naranja,string);
print(string);

format(wea,sizeof(wea),"{FFFFFF}Disculpa %s, tu has sido Kickeado del servidor!\
\n\n{FFFFFF}Admin: NPC\
\n{FFFFFF}Razon: Armas prohibidas.\
\n{FFFFFF}Fecha: %i/%i/%i Hora: %i:%i :%i\
\n\n{FFFFFF}* Intenta no ser un novato y vuelve sin cheats.",PlayerName,day,month,year, hour, minute, second);
ShowPlayerDialog(killerid, 8000, DIALOG_STYLE_MSGBOX, " * ", wea, "OK", "");

for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
}
Kick(killerid);
}
}

Dripac
10/10/2011, 08:21 PM
Try to add at the end a bracket }

grand.Theft.Otto
10/10/2011, 08:24 PM
Matias, you can at least use [pawn] tags to make his code less confusing and sloppy.

Joe Staff
10/10/2011, 08:25 PM
The problem is that 'killerid' isn't always a playerid, sometimes it's INVALID_PLAYER_ID. You can't search an array for INVALID_PLAYER_ID without causing a script cease.


if(killerid!=INVALID_PLAYER_ID)
{
//Code containing killerid
}else{
//player died of other causes
}

RcoN!
10/10/2011, 08:25 PM
if(EnZona[killerid] == 0)
{
new ArmaCheck = GetPlayerWeapon(killerid);
if(ArmaCheck == 35 || ArmaCheck == 36 || ArmaCheck == 37 || ArmaCheck == 38 || ArmaCheck == 39)
{
new string[300],wea[500];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, PlayerName, MAX_PLAYER_NAME);
new year,month,day; getdate(year, month, day);
new hour,minute,second; gettime(hour,minute,second);

format(string,sizeof(string),"* Admin NPC kickeo a %s (Armas prohibidas)", PlayerName);
SendClientMessageToAll(naranja,string);
print(string);

format(wea,sizeof(wea),"{FFFFFF}Disculpa %s, tu has sido Kickeado del servidor!\
\n\n{FFFFFF}Admin: NPC\
\n{FFFFFF}Razon: Armas prohibidas.\
\n{FFFFFF}Fecha: %i/%i/%i Hora: %i:%i :%i\
\n\n{FFFFFF}* Intenta no ser un novato y vuelve sin cheats.",PlayerName,day,month,year, hour, minute, second);
ShowPlayerDialog(killerid, 8000, DIALOG_STYLE_MSGBOX, " * ", wea, "OK", "");

for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
}
Kick(killerid);
}
}


thanks

GrimR
10/10/2011, 08:46 PM
Out of bounds errors are usually due to you trying to access a non existant array index.

Often happens when you loop through or call access to an array index where you have forgotten to specify in the loop or call to the length of the array -1 (as the index starts from 0, not from 1).

RcoN!
10/10/2011, 09:03 PM
The warning is ubicated in playerdeath

function:


if(EnZona[killerid] == 0)
{
new ArmaCheck = GetPlayerWeapon(killerid);
if(ArmaCheck == 35 || ArmaCheck == 36 || ArmaCheck == 37 || ArmaCheck == 38 || ArmaCheck == 39)
{
new string[300],wea[500];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, PlayerName, MAX_PLAYER_NAME);
new year,month,day; getdate(year, month, day);
new hour,minute,second; gettime(hour,minute,second);

format(string,sizeof(string),"* Admin NPC kickeo a %s (Armas prohibidas)", PlayerName);
SendClientMessageToAll(naranja,string);
print(string);

format(wea,sizeof(wea),"{FFFFFF}Disculpa %s, tu has sido Kickeado del servidor!\
\n\n{FFFFFF}Admin: NPC\
\n{FFFFFF}Razon: Armas prohibidas.\
\n{FFFFFF}Fecha: %i/%i/%i Hora: %i:%i :%i\
\n\n{FFFFFF}* Intenta no ser un novato y vuelve sin cheats.",PlayerName,day,month,year, hour, minute, second);
ShowPlayerDialog(killerid, 8000, DIALOG_STYLE_MSGBOX, " * ", wea, "OK", "");

for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
Kick(killerid);
}
}
}
}

Warings in crashdetect.log


Plugin succesfully loaded (version 3.1.3)
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
gamemodes\FTS.amx: During execution of OnPlayerDeath:
gamemodes\FTS.amx: Run time error 4: "Array index out of bounds".
Plugin succesfully loaded (version 3.1.3)

GrimR
10/10/2011, 09:10 PM
The problem is with:


for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
Kick(killerid);
}
}


If players start from 0 ID, I would assume your max players is set 1 too high, so you either need to lower max players by 1 or in loops put MAX_PLAYERS-1.

RcoN!
10/10/2011, 09:13 PM
The problem is with:


for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
Kick(killerid);
}
}


If players start from 0 ID, I would assume your max players is set 1 too high, so you either need to lower max players by 1 or in loops put MAX_PLAYERS-1.


for(new p = -1; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
PlayerPlaySound(p,1140,0.0,0.0,0.0);
Kick(killerid);
}
}

?