reading info problem
#1

hi im trying to read an information from a ini file. However, i have an error while i tried to compile...
Maybe could you help me ?

Код:
CMD:test(playerid, params[])
{
	new string[256], tmp2[256];
	format(string,sizeof(string),"/accs/%s.ini",udb_encode(params));
	INI:string[](name[], value[])
	{
		INI_Int("Lotto", tmp2);
	}
	format(string,sizeof(string),"Lotto: %d ", tmp2);
	SendClientMessage(playerid, -1, string);
	return 1;
}
Thanks
Reply
#2

Do you want load informations or set informations in an .INI file ?
If you want set informations :
PHP код:
CMD:test(playeridparams[])
{
    new 
string[256], tmp2[256];
    
format(string,sizeof(string),"/accs/%s.ini",udb_encode(params));

    new 
INI:File INI_Open(string);
    
INI_WriteInt(File"Lotto"tmp2);
    
INI_Close(File);

    
format(string,sizeof(string),"Lotto: %d "tmp2);
    
SendClientMessage(playerid, -1string);
    return 
1;

But tmp2 is empty.
Reply
#3

i would load the information/ "read" it
Reply
#4

That's not how y_ini works.
You should read this:
https://sampforum.blast.hk/showthread.php?tid=570957
Reply
#5

Alright, you need to use ParseFile. Check out this link : https://sampforum.blast.hk/showthread.php?tid=570957
Quick example :
PHP код:
public LoadUser_data(playerid,name[],value[])
{
    
INI_Int("MDP",PlayerInfo[playerid][pMDP]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdminlvl]);
    
INI_Int("Cash",PlayerInfo[playerid][pCash]);
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
    
INI_Int("Score",PlayerInfo[playerid][pScore]);
    
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
    
INI_Int("Log",PlayerInfo[playerid][pLog]);
    
INI_Int("Register",PlayerInfo[playerid][pRegister]);
    
INI_Int("VIP",PlayerInfo[playerid][pVIP]);
    
INI_Int("Kill",PlayerInfo[playerid][pKill]);
    
INI_Int("Death",PlayerInfo[playerid][pDeath]);
    
INI_Int("Kick",PlayerInfo[playerid][pKick]);
    
INI_Int("Ban",PlayerInfo[playerid][pBan]);
    
INI_String("IP",PlayerInfo[playerid][pIP], 16);
    
INI_String("LastIP",PlayerInfo[playerid][pLastIP], 16);
    
INI_Int("Banque"PlayerInfo[playerid][pBanque]);
    
INI_Float("PosX"PlayerInfo[playerid][pX]);
    
INI_Float("PosY"PlayerInfo[playerid][pY]);
    
INI_Float("PosZ"PlayerInfo[playerid][pZ]);
    return 
1;

PHP код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid); 
Reply
#6

What about when i want to get a info from a ini file where no players are connected ?
Reply
#7

DELETED MY BAD.
Reply
#8

Quote:
Originally Posted by sam29
Посмотреть сообщение
What about when i want to get a info from a ini file where no players are connected ?
If the file name isn't dynamic (player names etc..), you can use INI_Load.
Reply
#9

Quote:
Originally Posted by Stinged
Посмотреть сообщение
If the file name isn't dynamic (player names etc..), you can use INI_Load.
Could you please show me a fast example of this? Thanks
Reply
#10

Quote:
Originally Posted by Stinged
Посмотреть сообщение
If the file name isn't dynamic (player names etc..), you can use INI_Load.
I don't think is the good way to do what he wants.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)