Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
damo edited this page Jun 18, 2015 · 11 revisions

Global Variables, Modules and Functions

print(var) - prints the object/string/variable to the log/console


Working with Scripts

  • load(string:filename) - Loads a javascript file as a new script
  • unload(string:filename) - Unloads an existing script
  • reload(string:filename) - Unloads then loads an existing script

Include/Require

  • include(string:filename) - Includes and runs a file in the current context/script
  • require(string:filename/name) - Searches for a script in js/ by name and loads its as a module

$script

  • path - The relative path of the main script e.g. js/gamemodes/
  • filename - The filename of the main script e.g. main.js
  • fullpath - The full path of the main script e.g. js/gamemodes/main.js

$server

The $server object can set and get SA-MP server related functions and also intercepts events.

  • on(string:eventname, function:callback(...))
    $server.on("PlayerConnect", function(player){ //do stuff });
  • fire (string::eventname,arguments) - Fires a custom event
  • memory.heap() Gets the javascript heap size in MB for the current script
  • memory.current() Gets the samp-server's current memory usage in MB
  • memory.peak() Gets the samp-servers peak memory usage in MB

$players

player object

All SA-MP events which normally have a playerid will send a player object instead. This is a convenience object with many simple functions

player.id // Gets the players id
player.name // Gets the players name
player.name = "Gerald" // Sets the players name 
player.pos // Returns the players postion { x, y, z }
player.pos = {x:500,y:200,z:10} // Sets the players position

$fs

$io

$get

Main Menu
Clone this wiki locally