Resource:CallingFunctions
Jump to navigation
Jump to search
This template is no longer in use as it results in poor readability.
This resource was made off of the functions: CallClientFunction and CallServerFunction
Calling Functions
Click to collapse [-]
callSFvoid exports.callingFunctions:callSF( string funcname, [ var arg1, ... ] )
Required
- funcname: The name of the function that should be called serverside. May also be a function in a table, e.g. "math.round".
Optional
- agr1-argn: The arguments that should be passed to the function.
Example
This example removes the player from his team.
-- get the local player element local _local = getLocalPlayer() -- define the leaveTeam command handler function function cmdLeaveTeam() -- set the player's team to nil callServerFunction("setPlayerTeam", _local) end -- add the command handler addCommandHandler("leaveTeam", cmdLeaveTeam, false)
Click to collapse [-]
callCFvoid exports.callingFunctions:callCF( client Client, string funcname, [ var arg1, ... ] )
Required
- Client: The element of the player who should be affected.
- funcname: The name of the function that should be called serverside. May also be a function in a table, e.g. "math.round".
Optional
- agr1-argn: The arguments that should be passed to the function.
Example
This example sets the player's minute duration.
-- define the onPlayerJoin handler function function onPlayerJoin() -- set the minute duration callClientFunction(source, "setMinuteDuration", 10000) end -- add the event handler addEventHandler("onPlayerJoin", root, onPlayerJoin)
I give all thanks to Neon Black for making these functions.