Array index out of bounds
#1

Код:
[09:39:27] [debug] AMX backtrace:
[09:39:27] [debug] #0 00098848 in public OnPlayerTakeDamage (0, 65535, 1037805030, 37, 3) from _dark_.amx
[09:39:27] [debug] Run time error 4: "Array index out of bounds"
[09:39:27] [debug]  Accessing element at index 65535 past array upper bound 99
[09:39:27] [debug] AMX backtrace:
PHP код:
public OnPlayerTakeDamage(playerid,issueridFloatamountweaponidbodypart) {
   if(
issuerid != INVALID_PLAYER_ID && 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(
issuerid != INVALID_PLAYER_ID && 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
#2

You are not checking if issuerid is valid before using it in an array. Also you can delete those five individual checks and replace them with this:
PHP код:
if(issuerid != INVALID_PLAYER_ID)
{
   if(
gTeam[issuerid] == gTeam[playerid] && EDM[playerid] == && weaponid != 18)
    {
         
GetPlayerHealth(issuerid,amount);
         
SetPlayerHealth(issuerid,amount-2);
         return 
GameTextForPlayer(issuerid,"~r~Don't Attack Your Team Mate",5000,3);
    } 

Furthermore, that anti-team attacking and anti-team knifing down below (which suffer from the same naive copy-paste problem, by the way) will never get executed because they're blocked by the code above.
Reply
#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
#4

Learn how to shorten the code, how to use variables and if statements properly. You made the code very big, so I cleaned it up and fixed some bugs. Fix the indentation kindly, i wrote it in the browser. if you want to you can break the helmet and let player get headshot after getting their helmet broke, uncomment the lines to enable it.

PHP код:
public OnPlayerTakeDamage(playerid,issueridFloatamountweaponidbodypart

    if(
issuerid != INVALID_PLAYER_ID
    { 
        if((
weaponid == 34 || weaponid == 33) && bodypart == && gTeam[issuerid] != gTeam[playerid]) 
        {
                if(
gHelmet[playerid] == false)
                {
                    
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); 
                }
                else
                {
                        
/*gHelmet[playerid] = false;*/
                        
GameTextForPlayer(issuerid,"~w~Player has a ~r~helmet",5000,3); 
                        
/*RemovePlayerAttachedObject(playerid, 1);*/
                
}
        }
        
// anti-team-attack 
        
if(gTeam[issuerid] == gTeam[playerid] && EDM[playerid] == && weaponid != 18
        {
                if(
AntiSK[playerid])
                {
                        
GetPlayerHealth(issuerid,amount);
                        
SetPlayerHealth(issuerid,amount-5);
                        
GameTextForPlayer(issuerid,"~r~Player Have Anti Spawn Kill Protection"30003);
                }
                else
                {
                        
GetPlayerHealth(issuerid,amount);
                        
SetPlayerHealth(issuerid,amount-2);
                        
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003); 
                }
        }
        
// anti team knifing 
        
if(gTeam[issuerid] == gTeam[playerid] && 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); 
        }
        new 
str[26]; 
        
format(strsizeof(str),"-%.0f"amount); 
        
SetPlayerChatBubble(playeridstr0xFF0000FF100.02000); 
    }
    return 
1;

Reply
#5

Fixed.. but i got another error :v
Код:
[05:14:27] [debug] Run time error 4: "Array index out of bounds"
[05:14:27] [debug]  Accessing element at index 5 past array upper bound 4
[05:14:27] [debug] AMX backtrace:
[05:14:27] [debug] #0 00156740 in public OnPlayerEnterCheckpoint (0) from _dark_.amx
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
new 
text[128];
    if(
IsCapturing[playerid][usapro] == 1)
    {
        if(
IsPlayerInVehicle(playeridusapro))
        {
             
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][usapro] = 0;
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
                        
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
GivePlayerMoney(playerid6000);
SetVehicleToRespawn(usapro);
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
TextStats(playerid);
                
Savestatus(playerid);
        }
        else
        {
             
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the USA Prototype.");
        }
    }
    if(
IsCapturing[playerid][auspro] == 1)
    {
        if(
IsPlayerInVehicle(playeridauspro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][auspro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~ Australia prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(auspro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
              
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Australia Prototype.");
        }
    }
    if(
IsCapturing[playerid][arabpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridarabpro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][arabpro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Arabian prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(arabpro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Arabian Prototype.");
        }
    }
    if(
IsCapturing[playerid][sovpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridsovpro))
        {
            
DisablePlayerCheckpoint(playerid);
                   
RemovePlayerFromVehicle(playerid);
                   
TextStats(playerid);
                
Savestatus(playerid);
                   
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Soviet prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][sovpro] = 0;
                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
                
SetVehicleToRespawn(sovpro);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
                 
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Soviet Prototype.");
        }
    }
    if(
IsCapturing[playerid][eurapro] == 1)
    {
        if(
IsPlayerInVehicle(playerideurapro))
        {
            
DisablePlayerCheckpoint(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Erusia prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][eurapro] = 0;
                
RemovePlayerFromVehicle(playerid);
                
TextStats(playerid);
                
Savestatus(playerid);
                 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
             
SetVehicleToRespawn(eurapro);
             
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
              
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Erusia Prototype.");
        }
    }
    return 
1;

Reply
#6

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
Learn how to shorten the code, how to use variables and if statements properly. You made the code very big, so I cleaned it up and fixed some bugs. Fix the indentation kindly, i wrote it in the browser. if you want to you can break the helmet and let player get headshot after getting their helmet broke, uncomment the lines to enable it.

PHP код:
public OnPlayerTakeDamage(playerid,issueridFloatamountweaponidbodypart

    if(
issuerid != INVALID_PLAYER_ID
    { 
        if((
weaponid == 34 || weaponid == 33) && bodypart == && gTeam[issuerid] != gTeam[playerid]) 
        {
                if(
gHelmet[playerid] == false)
                {
                    
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); 
                }
                else
                {
                        
/*gHelmet[playerid] = false;*/
                        
GameTextForPlayer(issuerid,"~w~Player has a ~r~helmet",5000,3); 
                        
/*RemovePlayerAttachedObject(playerid, 1);*/
                
}
        }
        
// anti-team-attack 
        
if(gTeam[issuerid] == gTeam[playerid] && EDM[playerid] == && weaponid != 18
        {
                if(
AntiSK[playerid])
                {
                        
GetPlayerHealth(issuerid,amount);
                        
SetPlayerHealth(issuerid,amount-5);
                        
GameTextForPlayer(issuerid,"~r~Player Have Anti Spawn Kill Protection"30003);
                }
                else
                {
                        
GetPlayerHealth(issuerid,amount);
                        
SetPlayerHealth(issuerid,amount-2);
                        
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health"30003); 
                }
        }
        
// anti team knifing 
        
if(gTeam[issuerid] == gTeam[playerid] && 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); 
        }
        new 
str[26]; 
        
format(strsizeof(str),"-%.0f"amount); 
        
SetPlayerChatBubble(playeridstr0xFF0000FF100.02000); 
    }
    return 
1;

last time i did that but didn't work
anyway anyone know how to fix..
Quote:
Originally Posted by Younes44
Посмотреть сообщение
Fixed.. but i got another error :v
Код:
[05:14:27] [debug] Run time error 4: "Array index out of bounds"
[05:14:27] [debug]  Accessing element at index 5 past array upper bound 4
[05:14:27] [debug] AMX backtrace:
[05:14:27] [debug] #0 00156740 in public OnPlayerEnterCheckpoint (0) from _dark_.amx
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
new 
text[128];
    if(
IsCapturing[playerid][usapro] == 1)
    {
        if(
IsPlayerInVehicle(playeridusapro))
        {
             
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][usapro] = 0;
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
                        
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
GivePlayerMoney(playerid6000);
SetVehicleToRespawn(usapro);
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
TextStats(playerid);
                
Savestatus(playerid);
        }
        else
        {
             
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the USA Prototype.");
        }
    }
    if(
IsCapturing[playerid][auspro] == 1)
    {
        if(
IsPlayerInVehicle(playeridauspro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][auspro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~ Australia prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(auspro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
              
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Australia Prototype.");
        }
    }
    if(
IsCapturing[playerid][arabpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridarabpro))
        {
            
DisablePlayerCheckpoint(playerid);
            
IsCapturing[playerid][arabpro] = 0;
            
TextStats(playerid);
                
Savestatus(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Arabian prototype ~w~for his team!"pName(playerid));
                
RemovePlayerFromVehicle(playerid);
 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
 
GivePlayerMoney(playerid6000);
 
SetVehicleToRespawn(arabpro);
 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Arabian Prototype.");
        }
    }
    if(
IsCapturing[playerid][sovpro] == 1)
    {
        if(
IsPlayerInVehicle(playeridsovpro))
        {
            
DisablePlayerCheckpoint(playerid);
                   
RemovePlayerFromVehicle(playerid);
                   
TextStats(playerid);
                
Savestatus(playerid);
                   
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Soviet prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][sovpro] = 0;
                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
                
SetVehicleToRespawn(sovpro);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
                 
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Soviet Prototype.");
        }
    }
    if(
IsCapturing[playerid][eurapro] == 1)
    {
        if(
IsPlayerInVehicle(playerideurapro))
        {
            
DisablePlayerCheckpoint(playerid);
                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Erusia prototype ~w~for his team!"pName(playerid));
                
IsCapturing[playerid][eurapro] = 0;
                
RemovePlayerFromVehicle(playerid);
                
TextStats(playerid);
                
Savestatus(playerid);
                 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");
                 
GivePlayerMoney(playerid6000);
             
SetVehicleToRespawn(eurapro);
             
SetPlayerScore(playeridGetPlayerScore(playerid)+6);
              
TogglePlayerAllDynamicCPs(playerid1);
        }
        else
        {
            
DisablePlayerCheckpoint(playerid);
            
SCM(playeridRED"You're not in the Erusia Prototype.");
        }
    }
    return 
1;

Reply
#7

It can be shortened and also fixed, probably you're using the same variable name of the vehicle as for the one being used in the Enum, must be causing this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)