Squirrel/Server/Functions/Scripts/CallFunc
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|CallFunc}} This function will call a function from another loaded script. == Syntax == <code>CallFunc( string scriptPath, string funcName, params )</code> == …') |
(→Example) |
||
Line 14: | Line 14: | ||
== Example == | == Example == | ||
− | This example will call a function from ''Scripts/SomeScript/main.nut'' when a player types ''/ | + | This example will call a function from ''Scripts/SomeScript/main.nut'' when a player types ''/somecmd''. |
<code lang="squirrel"> | <code lang="squirrel"> | ||
Line 30: | Line 30: | ||
The function [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] is used in in this example. More info about them in corresponding pages. | The function [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] is used in in this example. More info about them in corresponding pages. | ||
− | |||
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Scripts}} | {{Squirrel/Server/Functions/Scripts}} |
Latest revision as of 23:49, 24 November 2010
This function will call a function from another loaded script.
[edit] Syntax
CallFunc( string scriptPath, string funcName, params )
[edit] Arguments
- scriptPath - The path of the script including the folder and filename
- funcName - The function being called
- params - Any parameters which need to be passed
[edit] Example
This example will call a function from Scripts/SomeScript/main.nut when a player types /somecmd.
function onPlayerCommand( id, cmd, text ) { if ( cmd == "somecmd" ) { CallFunc( "Scripts/SomeScript/main.nut", "SomeFunction", "param1", 2 ); } return 1; }
[edit] Notes
The function onPlayerCommand is used in in this example. More info about them in corresponding pages.