Meteor Scripting Functions
Network
bool isMultiplayer()
Is game is multiplayer?

Example
if(isMultiplayer())
{
    print("Game is multiplayer");
}
else
{
    print("Game is single player");
}

See also
isServer isClient isCoop isHeadToHead

bool isServer()
Is local computer a server or single player?

Example
if(isServer())
{
    print("Local computer is server or single player");
}
else
{
    print("Local computer is a multiplayer client");
}

Comments
Use to determine if the local computer has game authority.

See also
isMultiplayer isClient isCoop isHeadToHead

bool isClient()
Is local computer network client?

Example
if(isClient())
{
    print("Local computer is a multiplayer client");
}
else
{
    print("Local computer is server or single player");
}

See also
isMultiplayer isServer isCoop isHeadToHead

bool isCoop()
Is game cooperative?

Example
if(isCoop())
{
    print("Play nice");
}
else
{
    print("The gloves are off");
}

See also
isMultiplayer isServer isClient isHeadToHead

bool isHeadToHead()
Is game head to head (aka deathmatch)?

Example
if(isHeadToHead())
{
    print("The gloves are off");            
}
else
{
    print("Play nice");
}

See also
isMultiplayer isServer isClient isCoop

void syncVar(string variableName)
Syncs a variable to all players.

Example
// global variable outside all functions
bool someVar = false;

void onWorldStart()
{
    // if server or single player
    if(isServer())
    {
        someVar = true;
        syncVar("someVar");
    }
}

Comments
The variable must be a global variable, which is defined outside of any functions.
The variable must be a float, int, bool, string or vector2, other types cannot be synced.
Synced variables are synced to players who join mid-game.
Variables can be synced at any time by any player.
In singleplayer, the function has no effect.

See also
netExec

void netExec(int destPlayerID, string codeString)
Execute a string of code on a remote computer.

Example 1
// display message on all computers (includes local computer)
netExec(NET_EXEC_DEST_ALL, "print(\"Hello All!\");");

Example 2
// display message on clients only
netExec(NET_EXEC_DEST_ALL_CLIENTS, "print(\"Hello Clients!\");");

Example 3
// display message on server only
netExec(NET_EXEC_DEST_SERVER, "print(\"Hello Server!\");");

Example 4
// display message on a specific computer
int destPlayerID = getServerPlayer();
netExec(destPlayerID, "print(\"Hello player ID " + destPlayerID + "!\");");

Comments
The netExec function is disabled by default for security reasons, use setNetExecEnabled to enable.
netExec can be used from any computer (server or clients can exec code anywhere else).

See also
getNetExecEnabled setNetExecEnabled

bool getNetExecEnabled()
Get netExec function enabled status.

Example
print("netExec enabled: " + getNetExecEnabled());

Comments
Always returns false in single player.

See also
setNetExecEnabled netExec

void setNetExecEnabled(bool enable)
Enable netExec function on all computers (server only).

Example
void onWorldStart()
{
    if(isMultiplayerServer())
    {
        // enable netExec globally
        setNetExecEnabled(true);
    }
}

Comments
Has no effect in single player.

See also
getNetExecEnabled netExec


Index