Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507

Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507

Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507

Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507
How to use Functions - GTA Connected

How to use Functions

Revision as of 16:50, 16 August 2018 by Mex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Summary

Functionality is split up into: Variables, Functions, Properties, Methods, and Events.

Variable - A variable, that can be read and/or written to without () brackets, which is either global or in a namespace.
Function - A function, that can be called, which is either global or in a namespace.
Property - An OOP property, that can be read and/or written to without () brackets, which is used on an object.
Method - An OOP method, that can be called, which is used on an object.

Inheritance

Some types inherit functionality from other types, for example, type Player inherits type Ped, meaning that type Player has 100% of the functionality that Ped has.
Visit the node relations page for a full list of class inheritance.

Examples

Lua, Client-Side, Variable:

if debugMode then -- debugMode is a variable
    outputChatBox('Debug mode is enabled for you!', COLOUR_GREEN)
end

Lua, Server-Side, Function:

outputChatBox('This message will be shown in the chat box!', COLOUR_GREEN) -- outputChatBox is a function

Lua, Server-Side, Property:

addEventHandler('onPlayerJoined', function(event,client)
    outputChatBox(client.player.name .. ' has joined the server!', COLOUR_GREEN) -- name is a property of type Element (type Player inherits functionality of Element)
end)

Lua, Server-Side, Method:

addEventHandler('onPlayerJoined', function(event,client)
    client.player:setData('dataKey1', 'dataValue', false) -- setData is a method of type Element (type Player inherits functionality of Element)
end)