SA-MP Forums Archive
[Tutorial] How to display ingame player stats on your website if you have an .INI saving system. - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to display ingame player stats on your website if you have an .INI saving system. (/showthread.php?tid=421861)



How to display ingame player stats on your website if you have an .INI saving system. - RajatPawar - 11.03.2013

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:
pawn Code:
parse_ini_file($file_name,$process-sections-boolean)
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)
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.");

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


Re: How to display ingame player stats on your website if you have an .INI saving system. - iGetty - 11.03.2013

This looks alright, although I don't use ini files, I'm a MySQL fan all the way.

The only problem is, what if you don't have a VPS/Dedi? Then how are you going to access the files directly? You can't, unlike MySQL.


Re: How to display ingame player stats on your website if you have an .INI saving system. - RajatPawar - 11.03.2013

Quote:
Originally Posted by iGetty
View Post
This looks alright, although I don't use ini files, I'm a MySQL fan all the way.

The only problem is, what if you don't have a VPS/Dedi? Then how are you going to access the files directly? You can't, unlike MySQL.
Same here, I was a MySQL fan, but seeing this, I am seriously doubting it.
I also ******d around for that, couldn't find anything. Maybe in the path to the file, you'd have to insert the direct directory PATH like (myhost.com/mycp/myfiles/scriptfiles/) but obviously that would be a problem due to permissions.


Re: How to display ingame player stats on your website if you have an .INI saving system. - Djole1337 - 11.03.2013

PHP Code:
$myinifile "scriptfiles\Rajat_Pawar.ini"
Ugh ? Have you used VPS ever ?


Re: How to display ingame player stats on your website if you have an .INI saving system. - RajatPawar - 11.03.2013

Quote:
Originally Posted by Mr_DjolE
View Post
PHP Code:
$myinifile "scriptfiles\Rajat_Pawar.ini"
Ugh ? Have you used VPS ever ?
Nope, I am just showing an example, I take it for you guys to use some logic !


Re: How to display ingame player stats on your website if you have an .INI saving system. - Glad2BeHere - 11.03.2013

Code:
(This also assumes you are doing all this in your SAMP directory (since we only are doing \scriptfiles) else specify the WHOLE PATH)
If u see statement above tells u the entire path

GJ Rajat keeep it up gw


Re: How to display ingame player stats on your website if you have an .INI saving system. - caki - 11.03.2013

Sorry but i have to disagree with this tutorial. First of all anyone can read it for outside since there in no protection. I'm saying this since i work on PHP UCP that is reading INI files. I hope that no one will gonna use it like this. Reading files should be protected first by entering username and password (hash and salt possible) then session and maybe cookie depending on personal taste. Other thing placing it under server directory is a FALSE. You can reach user files with FTP function anywhere from outside the server dir.

Don't get me wrong here. Your tutorial is good but you should point out the disadvantages of using it as you created tutorial. Upgrade the tutorial or write down a warning about security issue about using this. I bet you don't want that somewone blame you later if somewone messed up his server files.


This is how you can call it from outside
PHP Code:
Gamedir  =  "ftp://user:pw @ host /" 
allow_url_include is must be set to On (On the server config where you are calling it)

EDIT: You can place the script in same server as samp one but not in samp server folder due to security


Re: How to display ingame player stats on your website if you have an .INI saving system. - RajatPawar - 12.03.2013

Thanks! Yes , I researched this and warned that you have to make it in such a way that the names of the path can't be known or guessed
Some folders with weird huge names and lots of weird named subfolders , if you save there , you should be safe !