Lua Examples: Difference between revisions

From MyGamingTalk
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
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.
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() ===
= et.RegisterModname() =




Line 18: Line 18:




=== et.trap_Cvar_Get() ===
= et.trap_Cvar_Get() =





Latest revision as of 01:11, 3 April 2015

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