Lua Examples

From MyGamingTalk

Lua is a server sided scripting language allowing users to customize their servers and settings to the fullest. Here below you will be able to find many examples on how the Lua Wolf API works in silEnT while getting a general understanding of lua.

et.RegisterModname()

Example Usage

function et_InitGame( levelTime, randomSeed, restart )
   local modname = "^1MY MOD NAME"
   et.RegisterModname( modname )
end

or

function et_InitGame( levelTime, randomSeed, restart )
   et.RegisterModname( "^1MY MOD NAME" )
end


et.trap_Cvar_Get()

Example Usage

function et_InitGame( levelTime, randomSeed, restart )
   maxclients = et.trap_Cvar_Get( "sv_maxclients" )
   et.trap_SendServerCommand( -1, "chat this server has "..maxclients.." slots!" ) -- -1 represents as all clients.
end

or

function et_InitGame( levelTime, randomSeed, restart )
   local silent_anticheat = et.trap_Cvar_Get( "sv_sac" ) -- local represents that this can only be used in this function.
   if silent_anticheat == 1 then
      et.trap_SendServerCommand( -1, "chat This server has silent anticheat enabled!" ) -- -1 represents as all clients.
   else
      et.trap_SendServerCommand( -1, "chat This server has silent anticheat disabled!" ) -- -1 represents as all clients.
   end
end