AMX Backtrace problem
#1

I have problem. I tried to search for it, but I couln't find any solutions.
When player die this happens in my console:

Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 65535 in array of size 1000
[debug] AMX backtrace:
[debug] #0 00038a48 in public OnPlayerDeath (0, 65535, 255) from SCRP.amx
This is the code from script:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    taser[playerid] = false;
    GiveTaserAgainTimer[playerid] = 0;
    lastWeapon[playerid] = 0;
    
    rp[killerid]++;
    GameTextForPlayer(killerid, "~y~+1 RP", 3000, 6);
    if(bounted[playerid] > 499)
    {
        if(playerid != killerid)
        {
            GivePlayerCash(killerid, bounted[playerid]);
            SCM(playerid, COLOR_LIGHTRED, "Ubijen si! Tvoja cijena za glavu je ukinuta.");
            SCM(killerid, COLOR_LIGHTBLUE, "Ubio si igraca s cijenom za njegovu/njezinu glavu.");
            bounted[playerid] = 0;
        }
    }
    if(robbing == 1)
	{
		KillTimer(robbingtimer);
		robbing = 0;
		new string[128], name[MAX_PLAYER_NAME];
		GetPlayerName(killerid, name, sizeof(name));
		format(string, sizeof(string), "[VIJESTI]: Banka je spaљena od pljackanja. Pomogao u tome: %s (%i)", name,killerid);
		SendClientMessageToAll(COLOR_YELLOW, string);
	}
	if(Player[playerid][police] == 1)
	{
	    if(playerid != killerid)
	    {
	    	SetPlayerWantedLevel(killerid, 4);
	    	SCM(killerid, COLOR_LIGHTRED, "Ubio si policajca! Dobio si wanted level 4!");
	    }
	}
	zaposlen[playerid] = 0;
	DisablePlayerCheckpoint(playerid);
	if(gTime[playerid][firsttime] == 1)
	{
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid,name,sizeof(name));
		format(thisfile,sizeof(thisfile),mydata,name);
		dini_IntSet(thisfile,"firsttime",1);
	}
	return 1;
}
Thanks for anyone who knows right solution.
Reply
#2

You have to check if killer id is valid [ not self kill ] then do actions on killerid..

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
taser[playerid] = false;
    
GiveTaserAgainTimer[playerid] = 0;
    
lastWeapon[playerid] = 0;
    if(
killerid != 65535)
    {
        
rp[killerid]++;
        
GameTextForPlayer(killerid"~y~+1 RP"30006);
    }
    if(
bounted[playerid] > 499)
    {
        if(
killerid != 65535/* && playerid != killerid*/)
        {
            
GivePlayerCash(killeridbounted[playerid]);
            
SCM(playeridCOLOR_LIGHTRED"Ubijen si! Tvoja cijena za glavu je ukinuta.");
            
SCM(killeridCOLOR_LIGHTBLUE"Ubio si igraca s cijenom za njegovu/njezinu glavu.");
            
bounted[playerid] = 0;
        }
    }
    if(
robbing == 1)
    {
        
KillTimer(robbingtimer);
        
robbing 0;
        if(
killerid != 65535)
        {
            new 
string[128], name[MAX_PLAYER_NAME];
            
GetPlayerName(killeridnamesizeof(name));
            
format(stringsizeof(string), "[VIJESTI]: Banka je spaљena od pljackanja. Pomogao u tome: %s (%i)"name,killerid);
            
SendClientMessageToAll(COLOR_YELLOWstring);
        }
    }
    if(
Player[playerid][police] == 1)
    {
        if(
killerid != 65535/* && playerid != killerid*/)
        {
            
SetPlayerWantedLevel(killerid4);
            
SCM(killeridCOLOR_LIGHTRED"Ubio si policajca! Dobio si wanted level 4!");
        }
    }
    
zaposlen[playerid] = 0;
    
DisablePlayerCheckpoint(playerid);
    if(
gTime[playerid][firsttime] == 1)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playerid,name,sizeof(name));
        
format(thisfile,sizeof(thisfile),mydata,name);
        
dini_IntSet(thisfile,"firsttime",1);
    }
    return 
1;

Reply
#3

Thanks! Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)