Why YSI\y_ini wont create a player file in scriptfiles?
#1

i try to solve this problem with 3 hours but i cant solve it.
got someone know how to fix it
pls teach me.
PHP код:
#include <a_samp>
#include <YSI\y_ini>
new c4[MAX_PLAYERS];
stock user_ini_file(playerid)
{
    new 
string128 ],user_nameMAX_PLAYER_NAME ];
    
GetPlayerNameplayeriduser_nameMAX_PLAYER_NAME );
    
formatstringsizeof ( string ), "/C4/%s.ini"user_name );
    return 
string;
}
forward @load_user_c4playeridname[], value[] );
@
load_user_c4playeridname[], value[] )
{
    
INI_Int"c4"c4playerid ] );
    return ( 
);
}
public 
OnPlayerConnectplayerid )
{
 new 
INI:File INI_Openuser_ini_fileplayerid ) );
     
INI_WriteIntFile"c4"c4[playerid] );
    
INI_ParseFileuser_ini_fileplayerid ), "load_user_%s", .bExtra true, .extra playerid );
    return ( 
);
}
public 
OnPlayerDisconnectplayeridreason )
{
    new 
INI:File INI_Openuser_ini_fileplayerid ) );
    
INI_WriteIntFile"c4"c4[playerid] );
    
INI_CloseFile );
    return ( 
);

Reply
#2

either you dont have the directory ".../scriptfiles/C4"

or this syntax
pawn Код:
format( string, sizeof ( string ), "/C4/%s.ini", user_name );
//change it to
    format( string, sizeof ( string ), "C4\%s.ini", user_name ); or     format( string, sizeof ( string ), "\C4\%s.ini", user_name );
Reply
#3

can't works
Reply
#4

oh i fix it but after i restart the server my stats wont load.
Quote:

enum pInfo
{
c4
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("c4",PlayerInfo[playerid][c4]);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
return 1;
}
else if(!fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"c4",0);
INI_Close(File);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"c4",PlayerInfo[playerid][c4]);
INI_Close(File);
return 1;
}

Reply
#5

try this Path:
pawn Код:
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
because in this line :
pawn Код:
GetPlayerName(playerid,playername,sizeof(playernam e));
you have a space between m & e
if not worked tell me.
Reply
#6

Quote:
Originally Posted by M4D
Посмотреть сообщение
because in this line :
pawn Код:
GetPlayerName(playerid,playername,sizeof(playernam e));
you have a space between m & e
Good spotting.
Reply
#7

Not works
Reply
#8

show me you " PATH " Define.
and are you setting "PlayerInfo[playerid][c4]" Variable to save and load again ?
maybe server create playerfile and set C4 value to 0
and you leave the server
when you join again it will load 0 !
check it
Reply
#9

PHP код:
#define PATH "/c4/%s.ini" 
Reply
#10

try this:

pawn Код:
enum pInfo
{
pC4
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("C4",PlayerInfo[playerid][pC4]);
return 1;
}

stock UserPath(playerid)
{
    new string[35], playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string,sizeof(string),"c4/%s.ini",playername);
    return string;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else if(!fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"C4",0);
INI_Close(File);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"C4",PlayerInfo[playerid][pC4]);
INI_Close(File);
}
return 1;
}
if not worked try updating you YSI library
https://sampforum.blast.hk/showthread.php?tid=321092
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)