Squirrel/Server/Functions/Ini/ReadIniBool
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This function reads a boolean value from an .ini file. == Syntax == <code>bool ReadIniBool( string filename, string section, string var )</code> == Arguments == * '''filename...) |
IdkanYavuk (Talk | contribs) (→Example) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|ReadIniBool}} | |
+ | {{RequiresModule|lu_ini|Modules/Squirrel/lu_ini}} | ||
This function reads a boolean value from an .ini file. | This function reads a boolean value from an .ini file. | ||
Line 16: | Line 17: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerJoin( player ) |
{ | { | ||
− | if ( ReadIniBool( "Players.ini", "Frozen", | + | if ( ReadIniBool( "Players.ini", "Frozen", player.Name ) ) |
{ | { | ||
− | + | player.Frozen = true; | |
MessagePlayer( "Sorry, you have been frozen earlier! :)", player ); | MessagePlayer( "Sorry, you have been frozen earlier! :)", player ); | ||
} | } | ||
Line 28: | Line 29: | ||
=== Notes === | === Notes === | ||
− | The functions [[Squirrel/Functions/ | + | The functions [[Squirrel/Server/Functions/Players/Frozen|Player.Frozen]], [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] 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}} |
Latest revision as of 19:29, 19 December 2012
Note: This function requires the external module lu_ini.
This function reads a boolean value from an .ini file.
[edit] Syntax
bool ReadIniBool( string filename, string section, string var )
[edit] Arguments
- filename This is the name of the file
- section The section that contains the value you want read
- var The name of the variable
[edit] Example
This example will check whether the player has been frozen earlier and if so, freezes them on join.
function onPlayerJoin( player ) { if ( ReadIniBool( "Players.ini", "Frozen", player.Name ) ) { player.Frozen = true; MessagePlayer( "Sorry, you have been frozen earlier! :)", player ); } }
[edit] Notes
The functions Player.Frozen, MessagePlayer and call onPlayerJoin were also used in in this example. More info about them in the corresponding pages.
[edit] Related Functions
These functions are provided by the official module lu_ini.