SA-MP Forums Archive
y_ini Reading - 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 Reading (/showthread.php?tid=208534)



y_ini Reading - GiS - 08.01.2011

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?


Re: y_ini Reading - Mаkaveli - 08.01.2011

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


Re: y_ini Reading - GiS - 08.01.2011

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?


Re: y_ini Reading - Mаkaveli - 08.01.2011

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


Re: y_ini Reading - GiS - 08.01.2011

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?


Re: y_ini Reading - Mаkaveli - 08.01.2011

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


Re: y_ini Reading - GiS - 09.01.2011

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


Re: y_ini Reading - Mаkaveli - 09.01.2011

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


Re: y_ini Reading - GiS - 09.01.2011

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



Re: y_ini Reading - [03]Garsino - 09.01.2011

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