Syntax: TGraalVar.join(class);


Joining a class provides its functions to whatever script that joined it.

Although you can think of join as "copying and pasting" the class into your script, it does more than that. It will
  1. keep track of your joined classes (see joinedclasses and isinclass);
  2. allow you to get rid of joined classes (see leave); and
  3. allow you to call a function in a specific joined class (see ::).
It is generally considered good practice to always use the scope operator.

Separating reusable code into another class and then joining it often helps reduce duplicate code on the server, and because of that, makes it easier to maintain scripts.

Join Types

Serverside Join
A serverside join is run on the server -- so if the join is put in the onCreated block, it will run when the weapon/npc is created/updated. If joined serverside, the script can access all serverside functions of that class on the server, and all clientside functions on the client.

Clientside Join
A clientside join is run on the client. There can sometimes be a significant delay between when join is called and when the script has access to the functions in the joined class. If joined clientside, the script can access the clientside functions of that class on the client.

It is recommended to join serverside because the lag created by a clientside join is often troublesome, as the calling function will keep running and may except certain functions to exist, even though they do not yet (see isclassloaded).


function example_function() {

Example Weapon
function onCreated() {

... would echo "Hello!" on the server RC when the weapon is updated.

Joins On TGraalVars

Joins in their basic form are used only on weapons and NPCs to provide access to more functions; however, you can use join on any variable. This means that the functions in the class, instead of being on this, will be on the variable.


function example_function() {
  this.something = 5;

Example Weapon
function onCreated() {
  temp.myVar = new TStaticVar();

... would echo "5" on the server RC when the weapon is updated.



There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki