HowTo/Functions: Difference between revisions

no edit summary
No edit summary
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:


Some types inherit functionality from other types, for example, type <code>Player</code> inherits type <code>Ped</code>, meaning that type <code>Player</code> has 100% of the functionality that <code>Ped</code> has.<br>
Some types inherit functionality from other types, for example, type <code>Player</code> inherits type <code>Ped</code>, meaning that type <code>Player</code> has 100% of the functionality that <code>Ped</code> has.<br>
Visit the [[Shared/NodeRelations|node relations]] page for a full list of class inheritance.
Visit the [[Types|Types]] page for a full list of class inheritance.


==Examples==
==Examples==
Line 19: Line 19:


{{LuaCode|1=if debugMode then -- debugMode is a variable
{{LuaCode|1=if debugMode then -- debugMode is a variable
     outputChatBox('Debug mode is enabled for you!', COLOUR_GREEN)
     message('Debug mode is enabled for you!', COLOUR_GREEN)
end}}
end}}


'''Lua, Server-Side, Function:'''
'''Lua, Server-Side, Function:'''


{{LuaCode|1=outputChatBox('This message will be shown in the chat box!', COLOUR_GREEN) -- outputChatBox is a function}}
{{LuaCode|1=message('This message will be shown in the chat box!', COLOUR_GREEN) -- message is a function}}


'''Lua, Server-Side, Property:'''
'''Lua, Server-Side, Property:'''


{{LuaCode|1=addEventHandler('onPlayerJoined', function(event,client)
{{LuaCode|1=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)
     message(client.player.name .. ' has joined the server!', COLOUR_GREEN) -- name is a property of type Element (type Player inherits functionality of Element)
end)}}
end)}}


6,833

edits