SA-MP Forums Archive
y_ini load - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: y_ini load (/showthread.php?tid=247474)



y_ini load - Rock_Ro - 09.04.2011

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 ?


Re: y_ini load - gamer931215 - 09.04.2011

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".


Re: y_ini load - Mean - 09.04.2011

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 );



Re: y_ini load - gamer931215 - 09.04.2011

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.


Re: y_ini load - Mean - 09.04.2011

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.