y_ini Reading
#1

Hey,

I've got a .ini file and I want to read some things out of it. For example the password. How and where can I do this?
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=206830
Reply
#3

I try to get it since a few minutes but I don't understand it, someone got a little example for for example to get the password out of a file with y_ini?

EDIT: Noone knows it?
Reply
#4

INI_ParseFile(PlayerInfo[playerid][userfile], "ParsePlayerPass", false, true, playerid);

forward ParsePlayerPass(playerid, name[ ], value[ ]);
public ParsePlayerPass(playerid, name[ ], value[ ])
{
if (!strcmp(name, "Passwort" ))
{
PlayerInfo[playerid][pass] = value;
}
}
Reply
#5

Quote:
Originally Posted by Mаkaveli
View Post
INI_ParseFile(PlayerInfo[playerid][userfile], "ParsePlayerPass", false, true, playerid);

forward ParsePlayerPass(playerid, name[ ], value[ ]);
public ParsePlayerPass(playerid, name[ ], value[ ])
{
if (!strcmp(name, "Passwort" ))
{
PlayerInfo[playerid][pass] = value;
}
}
Alright, I know how to use it now, but I want to script my own things, so I need to understand what you are doing there. Can you tell me what it does - each line?
Reply
#6

INI_ParseFile(PlayerInfo[playerid][userfile], "ParsePlayerPass", false, true, playerid); //this calls function named ParsePlayerPass that we created(you can call it whatever you want) under to read whatever you want you can read other data too its makes y_ini faster to read data once not to exit and open again to read thats why PlayerInfo[playerid][pass] = value; is inside brackets { }

forward ParsePlayerPass(playerid, name[ ], value[ ]);
public ParsePlayerPass(playerid, name[ ], value[ ])
{
if (!strcmp(name, "Passwort" )) // this checks if your setted name exist
{
PlayerInfo[playerid][pass] = value; then we set in variable pass value that we get from file
}
}

sorry for bad english
Reply
#7

Well but now I want to read 3 different things. How can I do so?
Reply
#8

forward LoadUser( playerid, name[ ], value[ ] );
public LoadUser( playerid, name[ ], value[ ] )
{
if ( !strcmp(name, "REG_DATE" ) )SetPVarString( playerid, "Date", value );
if ( !strcmp(name, "MONEYS" ) )SetPVarInt( playerid, "Moneys", strval( value ) );
if ( !strcmp(name, "SCORE" ) )SetPVarInt( playerid, "Score", strval( value ) );
}
Reply
#9

I got a problem. When I now read the file out I get a totaly wrong skinid. In the file the skinid is 93, but when I connect it sets my skin to 53. I never used this number before...I can't even find a 53 in my script (in coordinates of course). Here is the code:

pawn Code:
forward LoadUserData(playerid, name[ ], value[ ]);
pawn Code:
public OnPlayerSpawn(playerid)
{
    SetPlayerSkin(playerid, PlayerInfo[playerid][userskin]);
    return 1;
}
pawn Code:
OnPlayerConnect(...)
{
if(fexist(PlayerInfo[playerid][userfile]))
{
INI_ParseFile(PlayerInfo[playerid][userfile], "LoadUserData", false, true, playerid);
}
}
pawn Code:
public LoadUserData(playerid, name[ ], value[ ])
{
    if (!strcmp(name, "Skin"))
    {
        format(PlayerInfo[playerid][userskin], 3, "%i", value);
        SetPlayerSkin(playerid, PlayerInfo[playerid][userskin]);
    }
}
The .ini File:

pawn Code:
Skin = 93
Reply
#10

pawn Code:
public LoadUserData(playerid, name[ ], value[ ])
{
    if (!strcmp(name, "Skin"))
    {
        PlayerInfo[playerid][userskin] = strval(value);
        SetPlayerSkin(playerid, PlayerInfo[playerid][userskin]);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)