GameMonkey ScriptMod Command Reference

What kind of functions come with GMScriptMod?

-ServerCommands:

rslap <clientNumber> <Z Vector(height)>
example: rslap 2 700
that will slap the player with clientnumber 2, 700 up, and his sideward, and forward motion will be randomly increased.

slap <clientNumber> <Z Vector(height)>
example: slap 2 700
that will slap the player with clientnumber 2, 700 up

-ClientCommands:

hjump
example: /hjump
This will push the player into the sky, as a 'high jump'. The height is defined by a scriptfunction called 'GET_VELOCITY_Z_IMPACT'
So you can change the ammount of units the players goes up in the air.

Why are some script functions in upper case?

The upper case script functions are all called by GMSM.

What gmScriptMod functions can i use?

Here is a short list with (nearly) all available Script functions. We offer you some C++ written functions, which you can use inside your script.


index:

GAMINGGONE
GamingGoNe::sscanf
GamingGoNe::search
GamingGoNe::strip
GamingGoNe::Exec
GamingGoNe::say
GamingGoNe::echo
GamingGoNe::set
GamingGoNe::cp
GamingGoNe::cpm
GamingGoNe::cprint
GamingGoNe::GetValueForKey
GamingGoNe::GetUserInfo
GamingGoNe::getStringCvar
GamingGoNe::getIntCvar
GamingGoNe::strlen
GamingGoNe::logWrite
GamingGoNe::playsound
GamingGoNe::include
GamingGoNe::getConfigString
GamingGoNe::registerCvar
GamingGoNe::setCvar
GamingGoNe::atoi

GM
gm::debug
gm::gmVersion
gm::typeId
gm::typeName
gm::typeRegisterOperator
gm::typeRegisterVariable
gm::sysCollectGarbage
gm::sysGetMemoryUsage
gm::sysSetDesiredMemoryUsageHard
gm::sysSetDesiredMemoryUsageSoft
gm::sysGetDesiredMemoryUsageHard
gm::sysGetDesiredMemoryUsageSoft
gm::sysSetDesiredMemoryUsageAuto
gm::sysGetStatsGCNumFullCollects
gm::sysGetStatsGCNumIncCollects
gm::sysGetStatsGCNumWarnings
gm::sysIsGCRunning
gm::sysTime
gm::doString
gm::globals
gm::threadTime
gm::threadId
gm::threadAllIds
gm::threadKill
gm::threadKillAll
gm::thread
gm::yield
gm::exit
gm::assert
gm::sleep
gm::signal
gm::block
gm::stateSet
gm::stateSetOnThread
gm::stateGet
gm::stateGetLast
gm::stateSetExitFunction
gm::tableCount
gm::tableDuplicate
gm::print
gm::format


sscanf

Brief: Allows you to have a ssanf like function
Param: char string
Param: char searchPattern
Param: int varType
Return: char scannedVar

search

Brief: Allows you to search a string in a string
Param: char searchIn
Param: char searchString
Return: char match

strip

Brief: removes the color code from a player/string
Param: char string
Return: char stripped_string

Exec

Brief: Exec will execute a system command
Param: string params will be concatinated together with a single space to form the final system command string
Return: integer value returned from system exec call, -1 on error

say

Brief: say will send a console say message
Param: char string
Return: null

echo

Brief: echo will echo a string to the serverconsole output
Param: char string
Return: null

set

Brief: set param will be concatinated and piped to the gameserver using EXEC_APPEND
Param: string
Return: null

cp

Brief: this function will send string as a Center Print message to 'clientnum'
Param: int clientNum
Param: char string
Return: null

cpm

Brief: this function will send string to clientnum in CPM mode
Param: int clientNum
Param: char string
Return: null

cprint

Brief: this function will send string to clientnum in print mode(console)
Param: int clientNum
Param: char string
Return: null

GetValueForKey

Brief: this function will get a certain value from the userinfo string, eg 'GetValueForKey(UserInfoString,"ip")'
Param: char userinfostring
Param: char value
Return: char value

GetUserInfo

Brief: this function will return a userinfostring
Param: char string
Return: char userinfostring

getStringCvar

Brief: this function will return the string of the cvar 'var_name'
Param: char string
Return: char cvar_value

getIntCvar

Brief: this function will return the integer of the cvar 'var_name'
Param: char string
Return: integer cvar_value

strlen

Brief: this function will return the length of the string
Param: char string
Return: int length

logWrite

Brief: this function will write 'string' in the game logfile
Param: char string
Return: null

playsound

Brief: this function will play the sound 'string' using the clientcommand mu_play
Param: char pathToSound
Return: null

include

Brief: This function will include a file with 'string' as the filename
Param: char fileName
Return: null

getConfigString

Brief: This function gets the config string of a client (CS_PLAYERS + clientNum)
Param: int clientNum
Return: null

registerCvar

Brief: This function registers a server Cvar
Param: char cvarName
Return: null

setCvar

Brief: This function sets a server Cvar
Param: char cvarName
Param: char Value
Return: null

atoi

Brief: This function converts a string to an integer
Param: char string
Return: integer

gm



Brief: functions in the gm lib are all global scope

debug

Brief: debug will cause a the debugger to break at this point while running.


gmVersion

Brief: gmVersion will return the gmMachine version string. version string is major type . minor type as a string and was added at version 1.1
Return: string

typeId

Brief: typeId will return the type id of the passed var
Param: var
Return: integer type

typeName

Brief: typeName will return the type name of the passed var
Param: var
Return: string

typeRegisterOperator

Brief: typeRegisterOperator will register an operator for a type
Param: int typeid
Param: string operator name is one of "getdot", "setdot", "getind", "setind", "add", "sub", "mul", "div", "mod", "inc", "dec", "bitor", "bitxor", "bitand", "shiftleft", "shiftright", "bitinv", "lt", "gt", "lte", "gte", "eq", "neq", "neg", "pos", "not"
Param: function
Return: 1 on success, otherwise 0

typeRegisterVariable

Brief: typeRegisterVariable will register a variable with a type such that (type).varname will return the variable
Param: int typeid
Param: string var name
Param: var
Return: 1 on success, otherwise 0

sysCollectGarbage

Brief: sysCollectGarbage will run the garbage collector iff the current mem used is over the desired mem used
Param: forceFullCollect (false) Optionally perform full garbage collection immediately if garbage collection is not disabled.
Return: 1 if the gc was run, 0 otherwise

sysGetMemoryUsage

Brief: sysGetMemoryUsage will return the current memory used in bytes
Return: int memory usage

sysSetDesiredMemoryUsageHard

Brief: sysSetDesiredMemoryUsageHard will set the desired memory useage in bytes. when this is exceeded the garbage collector will be run.
Param: int desired mem usage in bytes

sysSetDesiredMemoryUsageSoft

Brief: sysSetDesiredMemoryUsageSoft will set the desired memory useage in bytes. when this is exceeded the garbage collector will be run.
Param: int desired mem usage in bytes

sysGetDesiredMemoryUsageHard

Brief: sysGetDesiredMemoryUsageHard will get the desired memory useage in bytes. Note that this value is used to start garbage collection, it is not a strict limit.
Return: int Desired memory usage in bytes.

sysGetDesiredMemoryUsageSoft

Brief: sysGetDesiredMemoryUsageSoft will get the desired memory useage in bytes. Note that this value is used to start garbage collection, it is not a strict limit.
Return: int Desired memory usage in bytes.

sysSetDesiredMemoryUsageAuto

Brief: sysSetDesiredMemoryUsageAuto will enable auto adjustment of the memory limit(s) for subsequent garbage collections.
Param: int enable or disable flag

sysGetStatsGCNumFullCollects

Brief: sysGetStatsGCNumFullCollects Return the number of times full garbage collection has occured.
Return: int Number of times full collect has occured.

sysGetStatsGCNumIncCollects

Brief: sysGetStatsGCNumIncCollects Return the number of times incremental garbage collection has occured. This number may increase in twos as the GC has multiple phases which appear as restarts.
Return: int Number of times incremental collect has occured.

sysGetStatsGCNumWarnings

Brief: sysGetStatsGCNumWarnings Return the number of warnings because the GC or VM thought the GC was poorly configured. If this number is large and growing rapidly, the GC soft and hard limits need to be configured better. Do not be concerned if this number grows slowly.
Return: int Number of warnings garbage collect has generated.

sysIsGCRunning

Brief: Returns true if GC is running a cycle.

sysTime

Brief: sysTime will return the machine time in milli seconds
Return: int

doString

Brief: doString will execute the passed gm script
Param: string script
Param: int optional (1) set as true and the string will execute before returning to this thread
Param: ref optional (null) set 'this'
Return: int thread id of thread created for string execution

globals

Brief: globals will return the globals table
Return: table containing all global variables

threadTime

Brief: threadTime will return the thread execution time in milliseconds
Return: int

threadId

Brief: threadId will return the thread id of the current executing script
Return: int

threadAllIds

Brief: threadIds returns a table of thread Ids
Return: table of thread Ids

threadKill

Brief: threadKill will kill the thread with the given id
Param: int threadId optional (0) will kill this thread

threadKillAll

Brief: threadKillAll will kill all the threads except the current one
Param: bool optional (false) will kill this thread if true

thread

Brief: thread will start a new thread
Param: function entry point of the thread
Param: ... parameters to pass to the entry function
Return: int threadid

yield

Brief: yield will hand execution control to the next thread

exit

Brief: exit will kill this thread

assert

Brief: assert
Param: int expression if true, will do nothing, if false, will cause an exception

sleep

Brief: sleep will sleep this thread for the given number of seconds
Param: int\float seconds

signal

Brief: signal will signal the given variable, this will unblock dest threads that are blocked on the same variable.
Param: var
Param: int destThreadId optional (0) 0 will signal all threads

block

Brief: block will block on all passed vars, execution will halt until another thread signals one of the block variables. Will yield on null and return null.
Param: ... vars
Return: the unblocking var

stateSet

Brief: stateSet will collapse the stack to nothing, and push the passed functions.
Param: function new state function to execute
Param: ... params for new state function

stateSetOnThread

Brief: stateSetOnThread will collapse the stack of the given thread id to nothing, and push the passed functions.
Param: int thread id
Param: function new state function to execute
Param: ... params for new state function

stateGet

Brief: stateGet will return the function on the bottom of this threads execution stack iff it was pushed using stateSet
Param: a_threadId Optional Id of thread to get state on. \reutrn function \ null

stateGetLast

Brief: stateGetLast will return the last state function of this thread
Param: a_threadId Optional Id of thread to get last state on. \reutrn function \ null

stateSetExitFunction

Brief: stateSetExitFunction will set an exit function for this state, that will be called with no parameters if this thread switches state
Param: function

tableCount

Brief: tableCount will return the number of elements in a table object
Param: table
Return: int

tableDuplicate

Brief: tableDuplicate will duplicate the passed table object
Param: table
Return: table

print

Brief: print will print the given vars to the print handler. passed strings are concatinated together with a seperating space.
Param: ... strings

format

Brief: format (like sprintf, but returns a string) %d, %s, %f, %c, %b, %x, %e
Param: string