Array index out of bounds
#3

Hello.

You break up an array.
Write it like this:
PHP код:
public OnPlayerTakeDamage(playerid,issueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {
        if(
gHelmet[playerid] == true)
        {
            
gHelmet[playerid]=false// << There, as simple as that
               
return GameTextForPlayer(issuerid,"~r~Player have helmet protection",5000,3);
        }
         if(
gTeam[issuerid] == TEAM_USA && gTeam[playerid] == TEAM_USA && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
        }
        if(
gTeam[issuerid] == TEAM_EURASIA && gTeam[playerid] == TEAM_EURASIA && EDM[playerid] == && weaponid != 18)
        {
            
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
        }
        if(
gTeam[issuerid] == TEAM_ARAB && gTeam[playerid] == TEAM_ARAB && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
        }
        if(
gTeam[issuerid] == TEAM_SOVIET && gTeam[playerid] == TEAM_SOVIET && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
        }
        if(
gTeam[issuerid] == TEAM_AUS && gTeam[playerid] == TEAM_AUS && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
           }
        if(
AntiSK[playerid] == 1)return 0;
        if((
weaponid == 34/*|| weaponid == 32 || weaponid == 31 || weaponid == 30 || weaponid == 29 || weaponid == 28 || weaponid == 27 || weaponid == 26*/ || weaponid == 33) && issuerid != INVALID_PLAYER_ID && bodypart == 9)
        {
            
SetPlayerHealth(playerid,0.0);
            
GameTextForPlayer(playerid,"~r~YOU GOT HEADSHOT~n~Type /buy To get Helmet",5000,3);
            
GameTextForPlayer(issuerid,"~r~wOw. Perfect Shot",5000,3);
            
PlayerPlaySound(playerid10500.00.00.0);
            
PlayerPlaySound(issuerid10500.00.00.0);
            
RemovePlayerAttachedObject(playerid1);
        }
        if(
AntiSK[playerid] == 1)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-5);
             
GameTextForPlayer(issuerid,"~r~Player Have Anti Spawn Kill Protection"30003);
        }
        
// anti-team-attack
        
if(gTeam[issuerid] == TEAM_USA && gTeam[playerid] == TEAM_USA && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003);
        }
        if(
gTeam[issuerid] == TEAM_EURASIA && gTeam[playerid] == TEAM_EURASIA && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003);
        }
        if(
gTeam[issuerid] == TEAM_ARAB && gTeam[playerid] == TEAM_ARAB && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003);
        }
        if(
gTeam[issuerid] == TEAM_SOVIET && gTeam[playerid] == TEAM_SOVIET && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003);
        }
        if(
gTeam[issuerid] == TEAM_AUS && gTeam[playerid] == TEAM_AUS && EDM[playerid] == && weaponid != 18)
        {
             
GetPlayerHealth(issuerid,amount);
             
SetPlayerHealth(issuerid,amount-2);
             
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003);
        }
        
// anti team knifing
        
if(gTeam[issuerid] == TEAM_USA && gTeam[playerid] == TEAM_USA && weaponid == 4)
        {
             
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates"30003);
             
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync"30003);
             
SetPlayerHealth(issuerid0);
        }
        if(
gTeam[issuerid] == TEAM_EURASIA && gTeam[playerid] == TEAM_EURASIA && weaponid == 4)
        {
             
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates"30003);
             
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync"30003);
             
SetPlayerHealth(issuerid0);
        }
        if(
gTeam[issuerid] == TEAM_ARAB && gTeam[playerid] == TEAM_ARAB && weaponid == 4)
        {
             
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates"30003);
             
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync"30003);
             
SetPlayerHealth(issuerid0);
        }
        if(
gTeam[issuerid] == TEAM_SOVIET && gTeam[playerid] == TEAM_SOVIET && weaponid == 4)
        {
             
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates"30003);
             
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync"30003);
             
SetPlayerHealth(issuerid0);
        }
        if(
gTeam[issuerid] == TEAM_AUS && gTeam[playerid] == TEAM_AUS && weaponid == 4)
        {
             
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates"30003);
             
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync"30003);
             
SetPlayerHealth(issuerid0);
        }
        if(
issuerid != INVALID_PLAYER_ID)
        {
              new 
str[26];
              
format(strsizeof(str),"-%.0f"amount);
              
SetPlayerChatBubble(playeridstr0xFF0000FF100.02000);
        }
    }
    return 
1;

Reply


Messages In This Thread
Array index out of bounds - by Younes44 - 10.08.2016, 10:56
Re: Array index out of bounds - by Vince - 10.08.2016, 11:12
Re: Array index out of bounds - by Mencent - 10.08.2016, 11:13
Re: Array index out of bounds - by Logic_ - 10.08.2016, 11:21
Re: Array index out of bounds - by Younes44 - 10.08.2016, 21:10
Re: Array index out of bounds - by Younes44 - 11.08.2016, 07:20
Re: Array index out of bounds - by Logic_ - 11.08.2016, 13:08

Forum Jump:


Users browsing this thread: 2 Guest(s)