Read a string saved with Y_ini
#1

Hey , when a player is banned , the admin name + reason are saved in the Ini file, I wanna load them when a player connect:
pawn Код:
if(PlayerInfo[playerid][pBanned]==1)
                    {
                    new INI:File = INI_Open(UserPath(playerid));
                    new string[200];
                    INI:File[](name[], value[])
                    {
                    INI_String("AdminBan", ad, 15);
                    INI_String("Reason", reason, 70);
                    return 0; // This is now required.
                    }
                    }
When compiling I get these errors:
Код:
C:\Documents and Settings\Administrateur\Bureau\Mrich's CnR\gamemodes\CnR.pwn(223) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrateur\Bureau\Mrich's CnR\gamemodes\CnR.pwn(223) : error 017: undefined symbol "@INI_File_"
C:\Documents and Settings\Administrateur\Bureau\Mrich's CnR\gamemodes\CnR.pwn(223) : error 017: undefined symbol "@INI_File_"
C:\Documents and Settings\Administrateur\Bureau\Mrich's CnR\gamemodes\CnR.pwn(223) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
How to fix it ? thanks.
Reply
#2

so it must be outside the Publics , then how the public(in this case onDialog..) will know it?

Or even how to make the code work any ideas?
thanks
Reply
#3

I read your tutorial but some parts aren't clear for me :
pawn Код:
ew
    gSomeInteger,
    Float:gAFloat,
    gTheString[32];

forward anyini_examples(name[], value[]);
public anyini_examples(name[], value[])
{
    INI_Int("some_integer", gSomeInteger);
}

forward anyini_more_examples(name[], value[]);
public anyini_more_examples(name[], value[])
{
    INI_Int("a_float", gAFloat);
    INI_String("the_string", gTheString, sizeof (gTheString));
}

main()
{
    INI_ParseFile("mine.INI", "anyini_%s");
    INI_ParseFile("other.INI", "anyini_%s");
}
what is its relation with my problem? the admin & reason are saved ; I ONLY WANNA load it but don't know how ...(ofc using Y_ini functions)...
Reply
#4

I read at the end you're talking about user file only how to save & load variables not strings..
Reply
#5

Is this what you're looking for?

pawn Код:
new gReason[70],
    gAdmin[MAX_PLAYER_NAME];

forward LoadReason(name[], value[])
public LoadReason(name[], value[])
{
    INI_String("Reason", gReason, sizeof(gReason));
    INI_String("AdminBan", gAdmin, sizeof(gAdmin));
    return 1;
}
Usage:
pawn Код:
if(PlayerInfo[playerid][pBanned] == 1)
{
    INI_ParseFile(UserPath(playerid), "LoadReason");

    printf("Player %d is banned for %s by admin %s.", playerid, gReason, gAdmin);
}
Reply
#6

Quote:
Originally Posted by Finn
Посмотреть сообщение
Is this what you're looking for?

pawn Код:
new gReason[70],
    gAdmin[MAX_PLAYER_NAME];

forward LoadReason(name[], value[])
public LoadReason(name[], value[])
{
    INI_String("Reason", gReason, sizeof(gReason));
    INI_String("AdminBan", gAdmin, sizeof(gAdmin));
    return 1;
}
Usage:
pawn Код:
if(PlayerInfo[playerid][pBanned] == 1)
{
    INI_ParseFile(UserPath(playerid), "LoadReason");

    printf("Player %d is banned for %s by admin %s.", playerid, gReason, gAdmin);
}
Exactly thank you for making huge effor writing this code , I save the admin name & reason in /ban command :
pawn Код:
INI_WriteString(File,"AdminBan",GetName(playerid));
INI_WriteString(File,"Reason",reason);
I wanna load them when a player connect again , so your code will do that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)