Game crashing
#1

This seems to be the reason as to why we are crashing when we die script wise.
PHP код:
[debugRun time error 4"Array index out of bounds"
[03:21:53] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[03:21:53] [debugAMX backtrace:
[
03:21:53] [debug#0 00061370 in public WC_OnPlayerWeaponShot (0, 24, 0, 65535, 1157821223, -991127359, 1095100765) from SCRP-R39.amx
[03:21:53] [debug#1 0003d8d0 in public OnPlayerWeaponShot (0, 24, 0, 65535, 1157821223, -991127359, 1095100765) from SCRP-R39.amx
[03:22:09] [partKamal_Rivers has left the server (1:0)
[
03:22:12] [partLingLing_Tofu has left the server (0:0
Any ideas why?
Reply
#2

You are doing something with hitid without checking if its valid.
So before using hitid directly do some checks for it:
PHP код:
if(hitid != INVALID_PLAYER_ID && IsPlayerConnected(hitid))
{

Reply
#3

I did that but I'm getting the same issue. I'm using a timer for some stuff.

PHP код:
 if (PlayerHealth <= 25 && Character[hitid][BrutalM] == && hitid != INVALID_PLAYER_ID && IsPlayerConnected(hitid))
        {
        if(
Character[hitid][BrutalM] == && weaponid 15)
           {
            
GetPlayerPos(hitidBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2]);
            
Character[hitid][BrutalM] = 1;
            
Character[hitid][CanAccept] = 0;
            
LegHit[hitid] = 0;
            
ApplyAnim(hitid);
            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(hitid), hitid);
            
label[hitid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2], 10.00);
            
Attach3DTextLabelToPlayer(label[hitid], hitid000.7);
            
ClearPlayerWeapons(hitid);
             
SetTimerEx("AllowDamage"3000false"i"hitid);
            
format(strsizeof(str),"%s was brutally wounded by %s.",GetRoleplayName(hitid),GetRoleplayName(playerid));
            
SendAdminsMessage(1COLOR_REDstr); 
PHP код:
forward AllowDamage(playerid);
public 
AllowDamage(playerid)
{
    
AllowDamageMode[playerid] = 1;
    return 
1;

It happens when the player is in AllowDamageMode and takes damage. Here is OnPlayerDamage

PHP код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    new 
Float:PlayerHealth;
    new 
str[256];
    if(
issuerid != INVALID_PLAYER_ID)
        {
    if(
Character[playerid][BrutalM] == && Character[playerid][Dead] == && issuerid != INVALID_PLAYER_ID)
    {
    
GetPlayerHealth(playeridPlayerHealth);
    if(
amount PlayerHealth) {
    
SetPlayerHealth(playerid20);
    return 
0;
    }
 }
    if(
Character[playerid][BrutalM] == && issuerid != INVALID_PLAYER_ID)
    {
    
GetPlayerHealth(playeridPlayerHealth);
    if(
amount PlayerHealth) {
    
SetPlayerHealth(playerid999);
    return 
1;
    }
}
        if(
Character[playerid][BrutalM] == && AllowDamageMode[playerid] == 1)
        {
        
Delete3DTextLabel(label[playerid]);
        
label2[playerid] = Create3DTextLabel("(( THIS PLAYER IS DEAD ))"COLOR_REDCharacter[playerid][DPosX], Character[playerid][DPosY], Character[playerid][DPosZ], 10.00);
        
Attach3DTextLabelToPlayer(label2[playerid], playerid000.7);
        
Character[playerid][Dead] = 1;
        
Character[playerid][BrutalM] = 0;
        
AllowDamageMode[playerid] = 0;
        
ApplyAnim(playerid);
        
SCM(playeridCOLOR_YELLOW">> You are now dead. You can use /respawnme after 60 seconds to respawn.");
        
Character[playerid][CanSpawn] = 0;
        
RespawnT 60;
        
RespawnEx SetTimer("RespawnTimer"999true);
        
SetTimerEx("RespawnTimer2"60000false"i"playerid);
        
format(strsizeof(str),"%s was finished off by %s.",GetRoleplayName(playerid),GetRoleplayName(issuerid));
        
SendAdminsMessage(1COLOR_LIGHTREDstr);
        } 
Reply
#4

Puts the checks first:
PHP код:
if (PlayerHealth <= 25 && hitid != INVALID_PLAYER_ID && IsPlayerConnected(hitid)  && Character[hitid][BrutalM] == 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)