Server Reference

Attributes

Functions

Example:

function onPlayerTouchsMe(pl) {
      //Find all the players on the map with the same clan name as the player that has touched the object
    let arr = Server.searchPlayers({map:pl.map.name, clanname:pl.clanname});

      //A message to show the players it has found with the above criteria
    this.say("Found " + arr.length + " members of " + pl.clanname +
      " (" + pl.clanid + ")! List on console.");

      //Loop through all the players it has found and set their chat
    for (let i = 0; i < arr.length; i ++) {
        arr[i].chat = "Found"; //Make the player say 'Found' if they meet the criteria above
    }
}

Example:

function onUpdated(pl) {
    let npcs = Server.searchnpcs({
        map: this.map,
        area:{x:this.x-20, y:this.y-20, w:40, h:40}
    });
    for (let i in npcs)
        npcs[i].scheduleevent(0, "otherevent", this);
}

//Add the onOtherEvent function to the other NPCs to see them triggered.
function onOtherEvent(caller) {
    echo("called NPC: " + this.id + " from " + caller.id);
}  

Server.getconfig/getitemconfig examples:

echo("default weapon: " + Server.getconfig("main").defaultweapon);
  -> sword1
echo("config skeleton: ", Server.getconfig("monsters", "type").index["skeleton"]);
  -> { type: 'skeleton', name: 'Pirate Skeleton', ...}
echo("config item nr: " + Server.getconfig("items", "itemid", "itemtype").objects.length);
  -> 591
echo("config weapon nr: " + Server.getconfig("items", "itemid", "itemtype").categories["weapon"].length);
  -> 97
echo("config weapon nr simple: " + Server.getitemlist("weapon").length);
  -> 97
echo("config sword1: ", Server.getconfig("items", "itemid", "itemtype").index["sword1"]);
  -> { itemid: 'sword1', name: 'Standard Sword', itemtype: 'weapon', ...}  
echo("config sword1 simple: ", Server.getitemconfig("sword1"));