Jump to content

Question

Posted

Salut ! Ma puteti ajuta cu aceasta problema ?

public OnPlayerDeath(playerid, killerid, reason)
{
	if( IsPlayerAnyClanMember(playerid) && IsPlayerAnyClanMember(killerid) )
	{
	new clanquery[300];
	format(clanquery, sizeof(clanquery), "UPDATE clans SET clankills = %d WHERE clanname = '%s'", GetClanKills(GetPlayerClan(killerid)) + 1, GetPlayerClan(killerid));
  	db_query( Database, clanquery );
	format(clanquery, sizeof(clanquery), "UPDATE clans SET clandeaths = %d WHERE clanname = '%s'", GetClanDeaths(GetPlayerClan(playerid)) + 1, GetPlayerClan(playerid));
 	db_query( Database, clanquery );
	}

	// SendDeathMessage(killerid, playerid, reason);
	 KillingSpree{ playerid } = 0;

	 if ( KillingSpree{ killerid } != bKillingSpree{ killerid } )
	 {
	 ++KillingSpree{ killerid };
	 }
	 else
	 {
	 ++KillingSpree{ killerid };
	 ++bKillingSpree{ killerid };
	 }
	 format( stringgg, sizeof( stringgg ), "~r~~d~~d~~d~Killing Spree: ~h~~g~%d", KillingSpree{ killerid } );
	 GameTextForPlayer( killerid, stringgg, 3000, 5 );
     new string[1000];

    if(GetPlayerScore(killerid) == 5) // Amount of required kills to get rank 1 *Baby Killa'*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *Baby Killa'* by killing %d players", string, GetPlayerScore(killerid) );
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        pRank[playerid] = 1;
    }
     else if(GetPlayerScore(killerid) == 25) // Amount of required kills to get rank 2 *Soldier*
	{
	    GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *Soldier* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        pRank[playerid] = 2;
	}
	 else if(GetPlayerScore(killerid) == 50) // Amount of required kills to get rank 3 *Gangsta'*
	{
        GetPlayerName(killerid, string, sizeof(string) );
	    format(string, sizeof(string), ">> %s advanced to rank *Gangsta'* by killing %d players", string, GetPlayerScore(killerid));
	    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	    pRank[playerid] = 3;
	}
	 else if(GetPlayerScore(killerid) == 150) // Amount of required kills to get rank 4 *Underboss*
	{
	    GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *UnderBoss* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	    pRank[playerid] = 4;
	}
	 else if(GetPlayerScore(killerid) == 300) // Amount of required kills to get rank 5 *Tha' Boss*
	{
	    GetPlayerName(killerid, string, sizeof(string) );
	    format(string, sizeof(string), ">> %s advanced to rank *The Boss* by killing %d players", string, GetPlayerScore(killerid));
	    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	    pRank[playerid] = 5;
	}
	#if defined USE_STATS
    ++PlayerInfo[playerid][Deaths];
	#endif
    InDuel[playerid] = 0;
    
    //Race
 	if(Joined[playerid] == true)
    {
		JoinCount--;
		Joined[playerid] = false;
		DestroyVehicle(CreatedRaceVeh[playerid]);
		DisablePlayerRaceCheckpoint(playerid);
		TextDrawHideForPlayer(playerid, Text:RaceInfo[playerid]);
		CPProgess[playerid] = 0;
		KillTimer(InfoTimerRace[playerid]);
		#if defined RACE_IN_OTHER_WORLD
		SetPlayerVirtualWorld(playerid, 0);
		#endif
	}
	//
   	if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
	{
		#if defined USE_STATS
		++PlayerInfo[killerid][Kills];
	    #endif
	if(InDuel[playerid] == 1) && InDuel[killerid] == 1)
		{
			GameTextForPlayer(playerid,"Loser !",3000,3);
			GameTextForPlayer(killerid,"Winner !",3000,3);
			InDuel[killerid] = 0;
			SetPlayerPos(killerid, 0.0, 0.0, 0.0);
			SpawnPlayer(killerid);
		}
		else if(InDuel[playerid] == 1) && InDuel[killerid] == 0)
		{
			GameTextForPlayer(playerid,"Loser !",3000,3);
		}
	}

	#if defined ENABLE_SPEC
	for(new x=0; x<MAX_PLAYERS; x++)
	    if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerInfo[x][SpecID] == playerid)
	       AdvanceSpectate(x);
	#endif

	if(InSumo[playerid] == 1)
	{
		DestroyVehicle(SumoCar[playerid]);
	    SumoPlayers--;
		InSumo[playerid] = 0;
		new strec[256];
	    format(strec, sizeof(strec), "{FF5A00}%s {FFFFFF}a pierdut la competitia Sumo cu Phoenix!", PlayerName2(playerid));
	    SendClientMessageToAll(0x6495EDAA,strec);
	    if(SumoPlayers == 1)
	    {
		    for(new i = 0; i < GetMaxPlayers(); i++)
		    {
			    if(InSumo[i] == 1)
			    {
				    format(strec, sizeof(strec), "{FF5A00}%s {FFFFFF}a castigat competitia Sumo cu Phoenix! {FF5A00}+%d {FFFFFF}Coins si {FF5A00}+%d$", PlayerName2(i),ScoreWin,CashWin);
					SendClientMessageToAll(0x6495EDAA,string);
					pInfo[ i ][Coins] += ScoreWin;
					GivePlayerMoney(i,CashWin);
					SumoPlayers = 0;
					SumoStarted = 0;
					new Float:x,Float:y,Float:z;
					GetPlayerPos(i,x,y,z);
					SetPlayerPos(i,x,y,z+1);
					DestroyVehicle(SumoCar[i]);
					SetTimerEx("SpawnPP",1000,0,"i",i);
					TogglePlayerControllable(i,1);
					InSumo[i] = 0;
			    }
		    }
	    }
	}

	return 1;
}
 [22:16:27] [debug] Run time error 4: "Array index out of bounds"
[22:16:27] [debug]  Accessing element at index 65535 past array upper bound 499
[22:16:27] [debug] AMX backtrace:
[22:16:27] [debug] #0 0006c428 in public OnPlayerDeath () from LoS.amx

idiots.png

3 answers to this question

Recommended Posts

Posted

Nu ai verificat daca killerid este INVALID_PLAYER_ID inainte de al folosi intr-o arie ca un index.

INVALID_PLAYER_ID = 65536

Ca un exemplu:

[pawn]new testarie [ MAX_PLAYERS ] ;

testarie [ 65536 ] = TEST ; // Aici 65536 este valoarea.[/pawn]

In acest caz, OnPlayerDeath ar trebuii sa arate cam asa:

[pawn]public OnPlayerDeath ( playerid , killerid , reason ) {

    if ( killerid ! = INVALID_PLAYER_ID ) {

        ++KillingSpree { killerid } ;

        ++PlayerInfo [ playerid ] [ Deaths ] ;

    } else {

        ++PlayerInfo [ playerid ] [ Deaths ] ; } // Aici nu folosesti killerid.De ce ? Pentru ca aici este partea cand killerid nu este valid.

    return (1) ; }[/pawn]

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.