Has Function

From HEWIKI
(Redirected from HasFunction)
Jump to: navigation, search

Contents

hasFunction

hasFunction(script as scriptref, function as string) as boolean

Arguments

<scriptref> 
A script reference variable referring to the function being checked
<function> 
A string representing the name of the shared function to check for

Description

This is a built-in function, usable on both client and server, which checks a script to see if it has a shared function of a certain name. If it finds it, it returns a value of TRUE. Otherwise it returns a value of FALSE. It will not find functions which are private or public -- only shared functions.

For more information, please see the section on Functions.

Example

If something in the game is about to cause damage to a character, it might be desired to first check to see if the character already has a damage handler function in the script on the character, even if the calling script does not initially know the name of that script. This could be done with the following code:

  if hasFunction(playerScript, "DamageHandler") 
    // the function exists
  .
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox