y_ini load
#1

I have a problem with my script .
It doesn't load Vip_Level from %s.ini
It create's %s.ini and everything is fine but it doesn't load
This is how my code looks
Код:
public OnPlayerConnect( playerid )
{
LoadPlayerVip( playerid );
}

public OnPlayerDisconnect( playerid )
{
SavePlayerVip( playerid );
}

forward load_user_vip(playerid, name[], value[]);
public load_user_vip(playerid, name[], value[])
{
	INI_Int("Vip_Level", PlayerData[ playerid ][ VIP_LEVEL ] );
    return 1;
}

LoadPlayerVip( playerid )
{
    new
        userFile[32];
    format(userFile, sizeof (userFile), "Vips/%s.ini", pName( playerid ) );
    INI_ParseFile(userFile, "load_user_vip", .extra = playerid);
}

SavePlayerVip( playerid )
{
    new
        userFile[32];
    format(userFile, sizeof (userFile), "Vips/%s.ini", pName( playerid ) );
    new
    INI:file = INI_Open(userFile);
    INI_WriteInt(file, "Vip_Level", PlayerData[ playerid ][ VIP_LEVEL ] );
    INI_Close(file);
}
What the problem could be ?
Reply
#2

Do you get any errors/warnings compiling this ?
Also check with debugmessages if pName( playerid ) returns the correct name,
and "/Vips/%s.ini" try isntead of "Vips/%s.ini".
Reply
#3

You can't use INI_Int for that. You need strcmp.
pawn Код:
forward load_user_vip(playerid, name[], value[]);
public load_user_vip(playerid, name[], value[])
{
    if( !strcmp( name, "Vip_Level", true ) )
        PlayerData[ playerid ][ VIP_LEVEL ] = strval( value );
    return 1;
}
And
pawn Код:
INI_ParseFile( userFile, "load_user_vip", false, true, playerid, true, false );
Reply
#4

Quote:
Originally Posted by Mean
Посмотреть сообщение
You can't use INI_Int for that. You need strcmp.
False, you actually can!
I use it on several scripts, never had problems with it (INI_Float, INI_Int etc), heres a example from gCamera:

pawn Код:
forward LoadCam(cameraid,name[],value[]);
public LoadCam(cameraid,name[],value[])
{
    INI_Float("_x",SpeedCameras[cameraid][_x]);
    INI_Float("_y",SpeedCameras[cameraid][_y]);
    INI_Float("_z",SpeedCameras[cameraid][_z]);
    INI_Float("_rot",SpeedCameras[cameraid][_rot]);
    INI_Int("_range",SpeedCameras[cameraid][_range]);
    INI_Int("_limit",SpeedCameras[cameraid][_limit]);
    INI_Int("_fine",SpeedCameras[cameraid][_fine]);
    INI_Int("_usemph",SpeedCameras[cameraid][_usemph]);
    return 1;
}
Works without any problems at all.
Reply
#5

Quote:
Originally Posted by gamer931215
Посмотреть сообщение
False, you actually can!
I use it on several scripts, never had problems with it (INI_Float, INI_Int etc), heres a example from gCamera:

pawn Код:
forward LoadCam(cameraid,name[],value[]);
public LoadCam(cameraid,name[],value[])
{
    INI_Float("_x",SpeedCameras[cameraid][_x]);
    INI_Float("_y",SpeedCameras[cameraid][_y]);
    INI_Float("_z",SpeedCameras[cameraid][_z]);
    INI_Float("_rot",SpeedCameras[cameraid][_rot]);
    INI_Int("_range",SpeedCameras[cameraid][_range]);
    INI_Int("_limit",SpeedCameras[cameraid][_limit]);
    INI_Int("_fine",SpeedCameras[cameraid][_fine]);
    INI_Int("_usemph",SpeedCameras[cameraid][_usemph]);
    return 1;
}
Works without any problems at all.
Never saw that way, but okay. Let him try the way I posted, also the ParseFile might be wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)