11.03.2013, 07:46
Hello guys! I am here to share the knowledge about displaying player stats on your website.
This assumes:
1) You know a bit of PHP
2) You got it installed on your host
1) What?
PHP has an awesome function named:
Parameters:
file_name: The name of the ini file to be parsed. (With the path)
$process-sections-boolean: Ignore this, always set to false, it's about returning data in a multidimensional array.
2) How?
I am going to be using one of my INI file for this:
Now let's write the code:
(This also assumes you are doing all this in your SAMP directory (since we only are doing \scriptfiles) else specify the WHOLE PATH)
That's it!
I learnt this and shared it with you, it's easier than MySQL. (definetily easier)
For the official parse_ini_file page, click here.
Thanks,
Cheers
This assumes:
1) You know a bit of PHP
2) You got it installed on your host
1) What?
PHP has an awesome function named:
pawn Code:
parse_ini_file($file_name,$process-sections-boolean)
file_name: The name of the ini file to be parsed. (With the path)
$process-sections-boolean: Ignore this, always set to false, it's about returning data in a multidimensional array.
2) How?
I am going to be using one of my INI file for this:
Now let's write the code:
(This also assumes you are doing all this in your SAMP directory (since we only are doing \scriptfiles) else specify the WHOLE PATH)
PHP Code:
$myinifile = "scriptfiles\Rajat_Pawar.ini"; // Naming our file and assigning it to a var
if (file_exists($myinifile) && is_readable($myinifile)) /* Is our file in existence and is it readable? If not, set permissions, etc */
{
$playerstats = parse_ini_file($myinifile); // Magic LINE!
// Now you got it, use it to get indivisual files like this:
$name = $playerstats [ "username" ];
$cash = $playerstats [ "cash" ];
$password = $playerstats [ "password" ];
$text = $playerstats [ "mytext" ];
// etc ...
// Now you can use it in whatever way you want!
echo "Player: $name ";
echo "Cash: $cash ";
echo "Text: $text ";
}
else
{
die("The file specified cannot be read.");
}
I learnt this and shared it with you, it's easier than MySQL. (definetily easier)
For the official parse_ini_file page, click here.
Thanks,
Cheers