Squirrel/Server/Functions/Ini/WriteIniString

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Updated example)
Line 17: Line 17:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerJoin( player )
+
function onPlayerJoin( player )
 
{
 
{
     WriteIniString( "IPs.ini", "IP", GetPlayerName( player ), GetPlayerIP( player ) );
+
     WriteIniString( "IPs.ini", "IP", player.Name, player.IP );
 
}
 
}
 
</code>
 
</code>
Line 25: Line 25:
 
=== Notes ===
 
=== Notes ===
  
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.
+
The functions [[Squirrel/Server/Functions/Player/Name|Player.Name]], [[Squirrel/Server/Functions/Player/IP|Player.IP]] and call [[Squirrel/Server/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/Server/Functions/Ini}}

Revision as of 00:47, 27 November 2009

This function writes a string value to an .ini file. If the file does not exist, the function will create it.

Syntax

  1. 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.

  1.  
  2. function onPlayerJoin( player )
  3. {
  4. WriteIniString( "IPs.ini", "IP", player.Name, player.IP );
  5. }
  6.  

Notes

The functions Player.Name, Player.IP and call onPlayerJoin were also used in in this example. More info about them in the corresponding pages.

Related Functions

These functions are provided by the official module lu_ini.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox