SA-MP Forums Archive
Y_ini save sys.. - 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)
+--- Thread: Y_ini save sys.. (/showthread.php?tid=535649)



Y_ini save sys.. - jimis - 05.09.2014

hi guys, with a little help i have create the following but it has a problem. when i connect to the game i type /skata1 and then mitsos = 1 , when i disconnect it save tha on the player name's file (i opened the file on scriptfiles and i saw mitsos =1) .But when i connect again and type /sta then its says me that MIT: 0. I checked th player file again to make sure that mitsos = 1 and it was 1. So, the problem is that it does NOT load the player file. Something wrong with parse file??
PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
#define COLOR_BLUE 0x0000FFAA
native WP_Hash(buffer[], len, const str[]);
enum playerInfo
{
    
Score,
    
Money,
    
Deaths,
    
Mitsos
}
new
    
pInfo[MAX_PLAYERS][playerInfo]
;
stock playerPath(playerid)
{
    new
        
string[128],
        
pName[MAX_PLAYER_NAME]
    ;
    
GetPlayerName(playeridpNamesizeof(pName));
    
format(stringsizeof(string), "Fakelos/%s.ini"pName);
    return 
string;
}
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
forward loadAccount_User(playeridname[], value[]);
public 
loadAccount_User(playeridname[], value[])
{
    
INI_Int("Score"pInfo[playerid][Score]);
    
INI_Int("Money"pInfo[playerid][Money]);
    
INI_Int("Deaths"pInfo[playerid][Deaths]);
    
INI_Int("Mitsos"pInfo[playerid][Mitsos]);
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
fexist(playerPath(playerid)))
    {
        
INI_ParseFile(playerPath(playerid), "loadAccount_%s", .bExtra true, .extra playerid);
        
SendClientMessage(playeridCOLOR_BLUE"prwto einai");
    }
    else
    {
        new
            
INI:File INI_Open(playerPath(playerid))
        ;
        
INI_SetTag(File"statistics");
        
INI_WriteInt(File"Score"0);
        
INI_WriteInt(File"Money"0);
        
INI_WriteInt(File"Deaths"0);
        
INI_WriteInt(File"Mitsos"0);
        
INI_Close(File);
        
pInfo[playerid][Score] = 0;
        
pInfo[playerid][Money] = 0;
        
pInfo[playerid][Deaths] = 0;
        
pInfo[playerid][Mitsos] = 0;
        
SendClientMessage(playeridCOLOR_BLUE"else mpike");
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new
        
INI:File INI_Open(playerPath(playerid))
    ;
    
INI_SetTag(File"statistics");
    
INI_WriteInt(File"Score"GetPlayerScore(playerid));
    
INI_WriteInt(File"Money"GetPlayerMoney(playerid));
    
INI_WriteInt(File"Deaths"pInfo[playerid][Deaths]);
    
INI_WriteInt(File"Mitsos"pInfo[playerid][Mitsos]);
    
INI_Close(File);
    return 
1;
}
CMD:sta(playeridparams[])
{
    new
        
string[128]
    ;
    
format(stringsizeof(string), "Your stats are: MIT: %d"pInfo[playerid][Mitsos]);
    
SendClientMessage(playerid, -1string);
    return 
1;
}
CMD:skata1(playeridparams[])
{
    
pInfo[playerid][Mitsos] = 1;
    return 
1;
}
CMD:naf(playeridparams[])
{
    
pInfo[playerid][Mitsos] = 0;
    return 
1;




Re: Y_ini save sys.. - BroZeus - 05.09.2014

forward loadAccount_User(playerid, name[], value[]);
public loadAccount_User(playerid, name[], value[])

change this to the following -->
forward loadAccount_statistics(playerid, name[], value[]);
public loadAccount_statistics(playerid, name[], value[])


Re: Y_ini save sys.. - JM_Millers - 05.09.2014

You must change this:
pawn Код:
format(string, sizeof(string), "Fakelos/%s.ini", pName);
on this:
pawn Код:
format(string, sizeof(string), "User/%s.ini", pName);



Re: Y_ini save sys.. - jimis - 05.09.2014

thanks guys really helped me ,problem solved!!