• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] PAWN error 028
#8
To fix the "array index out of bounds" error, you need to ensure that the playerid you're using to access PlayerInfo is within the bounds of the array
PHP Code:
function UpdatePaddy(playerid)
{
    if(
playerid || playerid >= MAX_PLAYERS// Check if playerid is within bounds
    
{
        
printf("Error: Invalid player ID %d"playerid);
        return 
0;
    }

    for(new 
0MAX_PADDYSi++)
    {
        if(
PlayerInfo[playerid][pPaddyUsed][i] == 1)
        {
            if(
PlayerInfo[playerid][pPaddyProgress][i] < 100)
            {
                
PlayerInfo[playerid][pPaddyProgress][i] += 1;

                if(
PlayerInfo[playerid][pPaddyProgress][i] == 100)
                {
                    
// Update paddy appearance
                    
new Float:xFloat:yFloat:z;
                    
GetDynamicObjectPos(PlayerInfo[playerid][pPaddyObject][i], xyz);
                    
SetDynamicObjectMaterial(PlayerInfo[playerid][pPaddyObject][i], 2862"gta_procdesert""sm_Agave_bloom");
                    
DestroyDynamic3DTextLabel(PlayerInfo[playerid][pPaddyText][i]);
                    
PlayerInfo[playerid][pPaddyText][i] = CreateDynamic3DTextLabel("", -1xy25.0);
                }

                
// Update dynamic text label
                
new string[128];
                
format(stringsizeof(string), "Ültetvény\n %d%"PlayerInfo[playerid][pPaddyProgress][i]);
                
UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i], -1string);
            }
        }
    }
    return 
1;

  Reply


Messages In This Thread
PAWN error 028 - by ironsolari - 2024-03-15, 01:37 PM
RE: PAWN error 028 - by N0FeaR - 2024-03-15, 02:28 PM
RE: PAWN error 028 - by ironsolari - 2024-03-15, 02:52 PM
RE: PAWN error 028 - by N0FeaR - 2024-03-15, 03:21 PM
RE: PAWN error 028 - by ironsolari - 2024-03-15, 03:37 PM
RE: PAWN error 028 - by N0FeaR - 2024-03-15, 04:00 PM
RE: PAWN error 028 - by ironsolari - 2024-03-15, 04:17 PM
RE: PAWN error 028 - by N0FeaR - 2024-03-16, 09:17 AM

Forum Jump: