Squirrel/Server/Functions/Ini/WriteIniBool

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Updated example)
Line 17: Line 17:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerCommand( player, command, text )
+
function onPlayerCommand( player, command, text )
 
{
 
{
 
     if ( command = "freezeme" )
 
     if ( command = "freezeme" )
 
     {
 
     {
           SetPlayerFrozen( player, true );
+
           player.IsFrozen = true;
           WriteIniBool( "Players.ini", "Frozen", GetPlayerName( player ), true );
+
           WriteIniBool( "Players.ini", "Frozen", player.Name, true );
  
 
           MessagePlayer( "Buhaha! You can't move anymore!", player );
 
           MessagePlayer( "Buhaha! You can't move anymore!", player );
Line 31: Line 31:
 
=== Notes ===
 
=== Notes ===
  
The functions [[Squirrel/Functions/Player/SetPlayerFrozen|SetPlayerFrozen]], [[Squirrel/Functions/Player/GetPlayerName|GetPlayerName]], [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Events/Player/OnPlayerCommand|OnPlayerCommand]] were also used in in this example. More info about them in the corresponding pages.
+
The functions [[Squirrel/Server/Functions/Players/IsFrozen|Player.IsFrozen]], [[Squirrel/Server/Functions/Players/Name|Player.Name]], [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] 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:58, 27 November 2009

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

Syntax

  1. bool WriteIniBool( string filename, string section, string var, bool 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 boolean true/false

Example

This example will freeze a player and store the control state to an ini file when they type '/freezeme'.

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command = "freezeme" )
  5. {
  6. player.IsFrozen = true;
  7. WriteIniBool( "Players.ini", "Frozen", player.Name, true );
  8.  
  9. MessagePlayer( "Buhaha! You can't move anymore!", player );
  10. }
  11. }
  12.  

Notes

The functions Player.IsFrozen, Player.Name, MessagePlayer and call onPlayerCommand 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