Boolean: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
A ''boolean'' or ''bool'' is a datatype whose value can be either ''true'' or ''false''. These are often returned by functions to indicate whether the operation was successful or not.
A ''boolean'' or ''bool'' is a datatype whose value can be either ''true'' or ''false''. These are often returned by functions to indicate whether the operation was successful or not.
Using the lua functions tostring() and type() can help you to find out what datatype something is:
<syntaxhighlight lang="lua">
local theReturn = isPedDead(getRandomPlayer())
outputChatBox("The reurn was: "..tostring(theReturn)) -- Will say: "true" or "false"
outputChatBox("The datatype of this return was: "..type(theReturn)) -- Will say "boolean"
</syntaxhighlight>
[[Category:Scripting Concepts]]
[[Category:Scripting Concepts]]


[[ru:Boolean]]
[[ru:Boolean]]

Revision as of 09:43, 9 August 2010

A boolean or bool is a datatype whose value can be either true or false. These are often returned by functions to indicate whether the operation was successful or not.

Using the lua functions tostring() and type() can help you to find out what datatype something is:

local theReturn = isPedDead(getRandomPlayer())
outputChatBox("The reurn was: "..tostring(theReturn)) -- Will say: "true" or "false"
outputChatBox("The datatype of this return was: "..type(theReturn)) -- Will say "boolean"