String not writing correctly. (Y_INI)
#1

So I'm trying to write a string (And compare later on.) to a file. The file is a players title. For some reason, all I'm getting in the players file is "Title = " no string is written inside. Can you spot the issue here?

pawn Код:
//A dialog option.
if(dialogid == UCP_TITLE)
    {
        if(!response) return ShowPlayerDialog(playerid, UCP_MAIN, DIALOG_STYLE_LIST, "User Control Panel", "Change Title\nSpawn Personal Vehicle\n", "Select", "Cancel");
        if(listitem == 0) //hunter title 10 karma
        {
            if(GetPlayerScore(playerid) < 10) return SCM(playerid,COLOR_GREY, "[ERROR]: This title is 10 karma.");
            new INI:file = INI_Open(UserPath(playerid));
            INI_SetTag(file, "Player Data");
            INI_WriteString(file, "Title", "Hunter");
            INI_Close(file);
            SaveAccount(playerid);
            SCM(playerid, COLOR_LIGHTBLUE, "Title changed to: Hunter");
            return 1;
        }

//When they speak with the title. Under onplayertext
if(strcmp(pInfo[playerid][pTitle], "Hunter", true))
    {
        new string[200];
        format(string,sizeof(string), "{3737FF}[Hunter]{FFFFFF}%s: %s", GetName(playerid), text);
        SCMA(COLOR_WHITE, string);
        return 0;
    }
Reply
#2

Try removing SaveAccount(playerid); because it might be overwriting it.
Reply
#3

will try and get back to you.

EDIT: So it's writing fine, but now it doesn't change on the spot. It requires me to login before it reads. Could I do
pawn Код:
pInfo[playerid][pTitle] = "Hunter"; //or something of that sort?
Reply
#4

the way which u tol raflie should have this "if" line not which u tell in ur code
if(pInfo[playerid][pTitle]==1)

and also if u are usin way which raflie todl remeber to convert pTitle to integer value in enum means remove [] from its front in enum
Reply
#5

I'm not wanting to use an integer. But I just can't figure out how to load a string on the spot instead of having the player relog.
Reply
#6

Well try what you said above.

pawn Код:
pInfo[playerid][pTitle] = "Hunter"; //or something of that sort?
Reply
#7

You are correct range.....
Quote:

if(dialogid == UCP_TITLE)
{
if(!response) return ShowPlayerDialog(playerid, UCP_MAIN, DIALOG_STYLE_LIST, "User Control Panel", "Change Title\nSpawn Personal Vehicle\n", "Select", "Cancel");
if(listitem == 0) //hunter title 10 karma
{
if(GetPlayerScore(playerid) < 10) return SCM(playerid,COLOR_GREY, "[ERROR]: This title is 10 karma.");
new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file, "Player Data");
INI_WriteString(file, "Title", "Hunter");
INI_Close(file);
SaveAccount(playerid);
SCM(playerid, COLOR_LIGHTBLUE, "Title changed to: Hunter");
return 1;
}

You never assigned hunter a value
you can pInfo[playerid][pTitle] = "Hunter";
or format(pInfo[playerid][pTitle], sizeof(pInfo[playerid][pTitle]), "%s", pInfo[playerid][pTitle]);

Whatever floats you both, but you never gave pInfo[playerid][pTitle] a value, u just wrote it a ini file
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)