Squirrel/Server/Functions/Ini/WriteIniString
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This function writes a string value to an .ini file. If the file does not exist, the function will create it. == Syntax == <code>bool WriteIniString( string filename, string se...) |
m (id -> pointer) |
||
Line 17: | Line 17: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function OnPlayerJoin( | + | function OnPlayerJoin( player, name ) |
{ | { | ||
− | WriteIniString( "IPs.ini", "IP", GetPlayerName( | + | WriteIniString( "IPs.ini", "IP", GetPlayerName( player ), GetPlayerIP( player ) ); |
} | } | ||
</code> | </code> | ||
Line 25: | Line 25: | ||
=== Notes === | === Notes === | ||
− | The call [[Squirrel/Events/Player/OnPlayerJoin|OnPlayerJoin]] | + | The functions [[Squirrel/Functions/Player/GetPlayerName|GetPlayerName]], [[Squirrel/Functions/Player/GetPlayerIP|GetPlayerIP]] and call [[Squirrel/Events/Player/OnPlayerJoin|OnPlayerJoin]] were also used in in this example. More info about them in the corresponding pages. |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Functions/Ini}} | {{Squirrel/Functions/Ini}} |
Revision as of 00:34, 4 March 2009
This function writes a string value to an .ini file. If the file does not exist, the function will create it.
Syntax
bool WriteIniString( string filename, string section, string var, string value )
Arguments
- filename This is the name of the file
- section The section that contains the value you want to create/edit
- var The name of the variable
- value The string value
Example
This example will save player's IP to file 'IPs.ini' when they join.
function OnPlayerJoin( player, name ) { WriteIniString( "IPs.ini", "IP", GetPlayerName( player ), GetPlayerIP( player ) ); }
Notes
The functions GetPlayerName, GetPlayerIP and call OnPlayerJoin were also used in in this example. More info about them in the corresponding pages.