Squirrel/Server/Functions/Ini/ReadIniString
From Liberty Unleashed Wiki
(Difference between revisions)
m |
(Removed 'name' from the OnPlayerJoin function) |
||
Line 16: | Line 16: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function OnPlayerJoin( player | + | function OnPlayerJoin( player ) |
{ | { | ||
− | if ( ReadIniString( "IPs.ini", "IP", | + | if ( ReadIniString( "IPs.ini", "IP", GetPlayerName( player ) ) == GetPlayerIP( player ) ) |
{ | { | ||
/* some nice autologin stuff here */ | /* some nice autologin stuff here */ |
Revision as of 15:17, 4 March 2009
This function reads a string saved to an .ini file.
Syntax
string ReadIniString( string filename, string section, string var )
Arguments
- filename This is the name of the file
- section The section that contains the value you want to read
- var The name of the variable
Example
This example will check whether the player connects from the same IP than earlier and auto-logs them in.
function OnPlayerJoin( player ) { if ( ReadIniString( "IPs.ini", "IP", GetPlayerName( player ) ) == GetPlayerIP( player ) ) { /* some nice autologin stuff here */ MessagePlayer( "You have auto-logged in successfully!", player ); } }
Notes
The functions GetPlayerIP, MessagePlayer and call OnPlayerJoin were also used in in this example. More info about them in corresponding pages.