Meteor 2 Scripting Functions
Network
bool isSinglePlayer()
Is game single player?
if(isSinglePlayer())
{
print("Game is single player");
}
else
{
print("Game is multiplayer");
}
Same as using !isMultiplayer()
bool isMultiplayer()
Is game multiplayer?
if(isMultiplayer())
{
print("Game is multiplayer");
}
else
{
print("Game is single player");
}
bool isServer()
Is local computer a server or single player?
if(isServer())
{
print("Local computer is server or single player");
}
else
{
print("Local computer is a multiplayer client");
}
Use to determine if the local computer has game authority.
bool isMultiplayerServer()
Is local computer a multiplayer server?
if(isMultiplayerServer())
{
print("Local computer is multiplayer server");
}
else
{
print("Local computer is not a multiplayer server");
}
Similar to isServer() except returns false in single player.
bool isClient()
Is local computer network client?
if(isClient())
{
print("Local computer is a multiplayer client");
}
else
{
print("Local computer is server or single player");
}
bool isCoop()
Is game cooperative?
if(isCoop())
{
print("Play nice");
}
else
{
print("The gloves are off");
}
bool isHeadToHead()
Is game head to head (aka deathmatch)?
if(isHeadToHead())
{
print("The gloves are off");
}
else
{
print("Play nice");
}
void syncVar(string variableName)
Syncs a variable to all players.
bool someVar = false;
void onWorldStart()
{
if(isServer())
{
someVar = true;
syncVar("someVar");
}
}
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.
void netExec(int destPlayerID, string codeString)
Execute a string of code on a remote computer.
netExec(NET_EXEC_DEST_SERVER, "print(\"Hello Server!\");");
netExec(NET_EXEC_DEST_ALL, "print(\"Hello All!\");");
netExec(NET_EXEC_DEST_ALL_REMOTE, "print(\"Hello All!\");");
netExec(NET_EXEC_DEST_ALL_CLIENTS, "print(\"Hello Clients!\");");
int destPlayerID = getServerPlayer();
netExec(destPlayerID, "print(\"Hello player ID " + destPlayerID + "!\");");
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).
bool getNetExecEnabled()
Get netExec function enabled status.
print("netExec enabled: " + getNetExecEnabled());
Always returns false in single player.
void setNetExecEnabled(bool enable)
Enable netExec function on all computers (server only).
void onWorldStart()
{
if(isMultiplayerServer())
{
setNetExecEnabled(true);
}
}
Has no effect in single player.
Index
Generated on the 23 November 2024 at 08:20:42 (UK Time)