Usage
Syntax:
- return;
- return returnvalue;
Explanation
return breaks any loops (like break) and ends the current function execution, returning the focus to the previous function and optionally returning a value to the calling function.
Generally speaking, return is very heavily relied upon because of it's ability to return a value to the calling function. The return value can be anything: an object, a TRUE or FALSE value, a string, a number or an array.
Example
function isGlobalStaff()
{
return player.account in {"unixmad", "Stefan", "Skyld", "Bell", "Ibonic", "TSAdmin", "Tigairius"};
}
function getGlobalStaffText()
{
if (this.isGlobalStaff())
{
return "You are global staff";
}
else
{
return "You are not global staff";
}
}
function onCreated()
{
echo(this.getGlobalStaffText());
}Categories
CategoryLanguageConstruct