open.mp forum
[Pawn] PAWN error 028 - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] PAWN error 028 (/showthread.php?tid=2638)



PAWN error 028 - ironsolari - 2024-03-15

Hi,

I'm trying to build a filterscript into my gamemode, and I'm facing these 4 errors:
Code:
(3762) :error 028: invalid subscript (not an array or too many subscripts): "PlayerData"
(3762) : warning 215: expression has no effect
(3762) : error 001: expected token: ";", but found "]"
(3762) : error 029: invalid expression, assumed zero
(3762) : fatal error 107: too many error messages on one line

Line 3762 is:
Code:
PlayerData[ playerid ][ pUpdateTime ] = SetTimerEx("UpdatePaddy",TIME_UPDATEPADDY,1,"i", playerid);

And these are the enums:
Code:
enum fj
{
pPaddyUsed[MAX_PADDYS] = 0,
pPaddyObject[MAX_PADDYS],
pPaddyProgress[MAX_PADDYS],
pPaddyFillWater[MAX_PADDYS],
Float:pPaddyPosX[MAX_PADDYS],
Float:pPaddyPosY[MAX_PADDYS],
Float:pPaddyPosZ[MAX_PADDYS],
Text3D:pPaddyText[MAX_PADDYS],
/////////////////////////////
pPaddyHarvestUsed[MAX_PADDYS],
pPaddyHarvestObject[MAX_PADDYS],
Float:pPaddyHarvestPosX[MAX_PADDYS],
Float:pPaddyHarvestPosY[MAX_PADDYS],
Float:pPaddyHarvestPosZ[MAX_PADDYS],
Text3D:pPaddyHarvestText[MAX_PADDYS],
/////////////////////////////
pHasHireVehicle,
pVehicleHire,
pTrailerVehicleHire,
pPaddyInTrailer,
Text3D:pTrailerText,
////////////////////////////
pPaddyHarvestInVehicle,
pPaddyHarvestInVehicleObject[5],
////////////////////////////
pUpdateTime,
}

Code:
enum            PlayerData          {

PlayerPassword[ MAX_PASS_LEN ],

PlayerAdmin,
PlayerAdminName[ MAX_PLAYER_NAME ],

PlayerAge,
PlayerGender,

PlayerSkin,
PlayerMoney,
PlayerPhoneNumber,

PlayerBankMoney,
PlayerBankNumber,

PlayerJob,
PlayerFraction,
PlayerFractionRank[ MAX_PLAYER_NAME ],

PlayerKLicense,
PlayerFLicense,

PlayerLPenalty,
PlayerTicket,

PlayerHouseKey,
PlayerVehicleKey,

PlayerBiz,
    PlayerTogReports,
    PlayerVBiz,

PlayerPHour,
PlayerPMinute,
PlayerPSecond,

PlayerWarn,
PlayerBaned,
PlayerJailTime,

Float: PlayerLastX,
Float: PlayerLastY,
Float: PlayerLastZ,
Float: PlayerLastA,

PlayerLastVWorld,
PlayerLastInterior,

WeaponStick,
WeaponKnife,

WeaponColt,
WeaponDeagle,

WeaponShotgun,
WeaponRifle,

bool: NewPlayer,

ClickedPlayer,

UsedItemName[ 128 ],
UsedItemAmount,

Float: PlayerHunger,
Float: PlayerThirst
};

new    PlayerInfo[ MAX_PLAYERS ][ PlayerData ];
Code:
function UpdatePaddy(playerid)
{
for(new i =0;i<MAX_PADDYS;i++)
{
    if(PlayerInfo[playerid][pPaddyUsed][i] == 1)
    {
        if(PlayerInfo[playerid][pPaddyProgress][i] < 100)
{
    /*if(PlayerInfo[playerid][pPaddyProgress][i] > 50)
{
    if(PlayerInfo[playerid][pPaddyFillWater][i] == 0)
    {
    new string[128];
    format(string,sizeof(string),"Paddy Owner %s\nSlot %d\nProgress :%d\nNEED WATER",GetName(playerid),i,PlayerInfo[playerid][pPaddyProgress][i]);
    UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i],-1,string);
    return 1;
    }
}*/
    PlayerInfo[playerid][pPaddyProgress][i] += 1;
if(PlayerInfo[playerid][pPaddyProgress][i] == 100)
{
new Float:x,Float:y,Float:z;
GetDynamicObjectPos(PlayerInfo[playerid][pPaddyObject][i],x,y,z);
SetDynamicObjectMaterial(PlayerInfo[playerid][pPaddyObject][i], 2, 862, "gta_procdesert", "sm_Agave_bloom");
// MoveDynamicObject(PlayerInfo[playerid][pPaddyObject][i],x,y,z+1,2);
DestroyDynamic3DTextLabel(PlayerInfo[playerid][pPaddyText][i]);
PlayerInfo[playerid][pPaddyText][i]=CreateDynamic3DTextLabel("",-1,x,y,z+2,5.0);
}
new string[128];
    format(string,sizeof(string),"Ültetvény\n %d%",PlayerInfo[playerid][pPaddyProgress][i]);
    UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i],-1,string);
    if(PlayerInfo[playerid][pPaddyProgress][i] == 100)
{
format(string,sizeof(string),"Ültetvény\n %d%",PlayerInfo[playerid][pPaddyProgress][i]);
    UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i],-1,string);
}
}
    }
}
return 1;
}

What am I doing wrong?


RE: PAWN error 028 - N0FeaR - 2024-03-15

Try this, make sure to replace your existing code with the fixed version. If you encounter any further issues feel free to ask!

PHP Code:
enum fj
{
    pPaddyUsed[MAX_PADDYS] = 0,
    pPaddyObject[MAX_PADDYS],
    pPaddyProgress[MAX_PADDYS],
    pPaddyFillWater[MAX_PADDYS],
    Float:pPaddyPosX[MAX_PADDYS],
    Float:pPaddyPosY[MAX_PADDYS],
    Float:pPaddyPosZ[MAX_PADDYS],
    Text3D:pPaddyText[MAX_PADDYS],
    pPaddyHarvestUsed[MAX_PADDYS],
    pPaddyHarvestObject[MAX_PADDYS],
    Float:pPaddyHarvestPosX[MAX_PADDYS],
    Float:pPaddyHarvestPosY[MAX_PADDYS],
    Float:pPaddyHarvestPosZ[MAX_PADDYS],
    Text3D:pPaddyHarvestText[MAX_PADDYS],
    pHasHireVehicle,
    pVehicleHire,
    pTrailerVehicleHire,
    pPaddyInTrailer,
    Text3D:pTrailerText,
    pPaddyHarvestInVehicle,
    pPaddyHarvestInVehicleObject[5],
    pUpdateTime // Remove the comma at the end
};

// Fixing enum syntax error by adding commas after the last enum value
enum PlayerData
{
    PlayerPassword[MAX_PASS_LEN],
    PlayerAdmin,
    PlayerAdminName[MAX_PLAYER_NAME],
    PlayerAge,
    PlayerGender,
    PlayerSkin,
    PlayerMoney,
    PlayerPhoneNumber,
    PlayerBankMoney,
    PlayerBankNumber,
    PlayerJob,
    PlayerFraction,
    PlayerFractionRank[MAX_PLAYER_NAME],
    PlayerKLicense,
    PlayerFLicense,
    PlayerLPenalty,
    PlayerTicket,
    PlayerHouseKey,
    PlayerVehicleKey,
    PlayerBiz,
    PlayerTogReports,
    PlayerVBiz,
    PlayerPHour,
    PlayerPMinute,
    PlayerPSecond,
    PlayerWarn,
    PlayerBaned,
    PlayerJailTime,
    Float:PlayerLastX,
    Float:PlayerLastY,
    Float:PlayerLastZ,
    Float:PlayerLastA,
    PlayerLastVWorld,
    PlayerLastInterior,
    WeaponStick,
    WeaponKnife,
    WeaponColt,
    WeaponDeagle,
    WeaponShotgun,
    WeaponRifle,
    bool:NewPlayer,
    ClickedPlayer,
    UsedItemName[128],
    UsedItemAmount,
    Float:PlayerHunger,
    Float:PlayerThirst // Remove the comma at the end
};

new 
PlayerInfo[MAX_PLAYERS][PlayerData];

// Fixing subscript error and other syntax/logic issues in the UpdatePaddy function
forward UpdatePaddy(playerid);
public 
UpdatePaddy(playerid)
{
    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)
                {
                    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);
                }
                new string[128];
                format(stringsizeof(string), "Ültetvény\n %d%%"PlayerInfo[playerid][pPaddyProgress][i]);
                UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i], -1string);
                if(PlayerInfo[playerid][pPaddyProgress][i] == 100)
                {
                    format(stringsizeof(string), "Ültetvény\n %d%%"PlayerInfo[playerid][pPaddyProgress][i]);
                    UpdateDynamic3DTextLabelText(PlayerInfo[playerid][pPaddyText][i], -1string);
                }
            }
        }
    }
    return 1;




RE: PAWN error 028 - ironsolari - 2024-03-15

I'm still getting the same error for the same line unfortunately


RE: PAWN error 028 - N0FeaR - 2024-03-15

Please give me line 3762


RE: PAWN error 028 - ironsolari - 2024-03-15

Code:
PlayerData[ playerid ][ pUpdateTime ] = SetTimerEx("UpdatePaddy",TIME_UPDATEPADDY,1,"i", playerid);



RE: PAWN error 028 - N0FeaR - 2024-03-15

Replace
PHP Code:
PlayerDataplayerid ][ pUpdateTime ] = SetTimerEx("UpdatePaddy",TIME_UPDATEPADDY,1,"i"playerid); 

with this
PHP Code:
PlayerInfo[playerid][pUpdateTime] = SetTimerEx("UpdatePaddy"TIME_UPDATEPADDY1"i"playerid); 

Let me know if u still get same error.


RE: PAWN error 028 - ironsolari - 2024-03-15

I'm getting a different error now

Code:
error 032: array index out of bounds (variable "PlayerInfo")



RE: PAWN error 028 - N0FeaR - 2024-03-16

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;