SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 08/01/2011, 06:54 PM   #1
GiS
Big Clucker
 
Join Date: Jan 2011
Posts: 89
Reputation: 0
Default y_ini Reading

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?
GiS is offline  
Old 08/01/2011, 07:09 PM   #2
Mаkaveli
Big Clucker
 
Join Date: Dec 2010
Posts: 54
Reputation: 0
Default Re: y_ini Reading

http://forum.sa-mp.com/showthread.php?t=206830
__________________
Mаkaveli is offline  
Old 08/01/2011, 07:31 PM   #3
GiS
Big Clucker
 
Join Date: Jan 2011
Posts: 89
Reputation: 0
Default Re: y_ini Reading

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?
GiS is offline  
Old 08/01/2011, 08:07 PM   #4
Mаkaveli
Big Clucker
 
Join Date: Dec 2010
Posts: 54
Reputation: 0
Default Re: y_ini Reading

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;
}
}
__________________
Mаkaveli is offline  
Old 08/01/2011, 08:15 PM   #5
GiS
Big Clucker
 
Join Date: Jan 2011
Posts: 89
Reputation: 0
Default Re: y_ini Reading

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?
GiS is offline  
Old 08/01/2011, 08:27 PM   #6
Mаkaveli
Big Clucker
 
Join Date: Dec 2010
Posts: 54
Reputation: 0
Default Re: y_ini Reading

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
__________________
Mаkaveli is offline  
Old 09/01/2011, 08:46 AM   #7
GiS
Big Clucker
 
Join Date: Jan 2011
Posts: 89
Reputation: 0
Default Re: y_ini Reading

Well but now I want to read 3 different things. How can I do so?
GiS is offline  
Old 09/01/2011, 09:52 AM   #8
Mаkaveli
Big Clucker
 
Join Date: Dec 2010
Posts: 54
Reputation: 0
Default Re: y_ini Reading

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 ) );
}
__________________
Mаkaveli is offline  
Old 09/01/2011, 10:56 AM   #9
GiS
Big Clucker
 
Join Date: Jan 2011
Posts: 89
Reputation: 0
Default Re: y_ini Reading

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
GiS is offline  
Old 09/01/2011, 11:03 AM   #10
[03]Garsino
Guest
 
Posts: n/a
Default Re: y_ini Reading

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Y_INI reading help armyoftwo Help Archive 9 03/01/2011 10:50 AM
Y_Ini. Zh3r0 Help Archive 1 15/10/2010 09:00 PM


All times are GMT. The time now is 03:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.