Y_Ini Error for loading a string.
#1

Error Help


Hello, I've recently tried to fix this problem, however, its really confused me therefore I have came here to request some help.

Код:
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : warning 215: expression has no effect
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 001: expected token: ";", but found "]"
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 029: invalid expression, assumed zero
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : fatal error 107: too many error messages on one line
I'll give a bit off code as shown below:

pawn Код:
enum pInfo
{
    pColor,
    pAccent[70]
}

new PlayerInfo[MAX_PLAYERS][pInfo];// Stores the player data

//This is were the error occurs below on 'PlayerInfo[playerid][pAccent]
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Color",PlayerInfo[playerid][pColor]);
    INI_String("Accent",PlayerInfo[playerid][pAccent], sizeof(PlayerInfo[playerid][pAccent]));//Error line. :(
    return 1;
}
If I do it this way, I don't get no errors what so ever, so this is why its confused me

pawn Код:
new pAccent[70];

public LoadUser_data(playerid, name[], value[])
{
        INI_String("Accent",pAccent, sizeof(pAccent));
        return 1;
}
Please can someone point me in the correct direction were I have made my mistake. I'm not perfect, though I wish to be. I'd just like to know, I have searched SA-MP forums, but nothing really helped me.

Thank you for those who reply to this topic.

NOTE: I have copied this from my current script that I have been editing!
Reply
#2

Sizeof doesn't work with enum fields AFAIK.
Reply
#3

So I should create a string for sizeof then? but this still doesn't fix the problem though.
Reply
#4

pawn Код:
INI_String("Accent",PlayerInfo[playerid][pAccent], 70);
Even printf fails when using sizeof in it with an enum field:
pawn Код:
enum pInfo
{
    pColor,
    pAccent[70]
}

new PlayerInfo[MAX_PLAYERS][pInfo];

printf("%i", sizeof(PlayerInfo[0][pAccent]));
Reply
#5

Код:
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : warning 215: expression has no effect
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 001: expected token: ";", but found "]"
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : error 029: invalid expression, assumed zero
C:\Users\Death\Desktop\SA-MP custom script\BD-RP\gamemodes\myscript.pwn(4211) : fatal error 107: too many error messages on one line
I still get these error's. I've changed pAccent in my players info and changed line 4211 to:

pawn Код:
INI_String("Accent",PlayerInfo[playerid][pAccent], 70);
I guess the problem would be were my data is stored or the '[', ']'. I mainly get the error in:

pawn Код:
PlayerInfo[playerid][pAccent]
but why though? :/
Reply
#6

That's weird.
I'm not using Y_ini, so I can't test this if it's specific to INI_String or not.

But I had a similar problem when using MySQL, where I needed to place the length of the destination array which is also an enum field.
I had to put the length as a number and it works fine.
Reply
#7

pawn Код:
new accent;
INI_String("Accent",accent, 70);//Works but won't load my players data ofc.
INI_String("Accent",PlayerInfo[playerid][pAccent], 70); // Yet this doesn't, though PlayerInfo is were my players data is stored
INI_Int("Color",PlayerInfo[playerid][pColor]);// Yet, this works fine? This has confused me a LOT
Please try and help me out, that's if you can.
Reply
#8

Fixed! With a bit off luck by doing random things.

To fix it I did:

pawn Код:
enum pInfo
{
       pAccent[50]
       return 1;
}

PlayerInfo[playerid][pInfo];

//Then did
INI_String("Accent",PlayerInfo[playerid][pAccent], 70);
No errors, but I haven't tested it yet. I will do it now.

EDIT: I have given you a reputation point for helping out, thank you very much.
Reply
#9

You are doing it wrong i think?Try like this:

Код:
enum pInfo
{
    pColor,
    pAccent[70]
}

new PlayerInfo[MAX_PLAYERS][pInfo];// Stores the player data

//This is were the error occurs below on 'PlayerInfo[playerid][pAccent]
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Color",PlayerInfo[playerid][pColor]);
    INI_String("Accent",PlayerInfo[playerid][pAccent], 70);
    return 1;
}
Reply
#10

Quote:
Originally Posted by MrTinder
Посмотреть сообщение
You are doing it wrong i think?Try like this:

Код:
enum pInfo
{
    pColor,
    pAccent[70]
}

new PlayerInfo[MAX_PLAYERS][pInfo];// Stores the player data

//This is were the error occurs below on 'PlayerInfo[playerid][pAccent]
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Color",PlayerInfo[playerid][pColor]);
    INI_String("Accent",PlayerInfo[playerid][pAccent], 70);
    return 1;
}
Thanks for the help, but I just figured this out a moment ago.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)