I thought of to give some usefull scripts to everyone since I stopped playing ET.
HideNseek pack and my infected mod will come soon.
covertinvincible.lua
--[[
This tool makes covertops invincible on death (He can't get gibbed).
Can be modified to all classes. Just remove the "if checklass(j) == 4 then" and the "end" on line 31
Made by Micha!
--]]
Modname = "covertinvincible"
Version = 0.1
samplerate = 100
et.CS_PLAYERS = 689
function et_InitGame(levelTime,randomSeed,restart)
et.G_Print(""..Modname.." Version: "..Version.." Loaded
")
et.RegisterModname(Modname .. " " .. Version)
maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
end
function et_RunFrame( levelTime )
if math.mod(levelTime, samplerate) ~= 0 then return end
for j = 0, (maxclients - 1) do
if checkclass(j) == 4 then
local hp = tonumber(et.gentity_get(j,"health"))
local body = tonumber(et.gentity_get(j, "r.contents"))
if body == 67108864 then --if hp <= 0 then --could work too
et.gentity_set(j, "ps.powerups", 1, levelTime + 9999999 ) --etpub ps.powerups 1 = spawn shield
elseif body == 33554432 and hp >= 76 then
et.gentity_set(j, "ps.powerups", 1, 0 )
end
end
end
end
--0=Soldier, 1=Medic, 2=Engineer, 3=FieldOps, 4=CovertOps
function checkclass(client)
local cs = et.trap_GetConfigstring(et.CS_PLAYERS + client)
return tonumber(et.Info_ValueForKey(cs, "c"))
end
--BOOM
rulesetpub.lua
-- Major Zeman's Rules printer
-- version 0.1 (20.7.2007)
-- changelog by Micha!
--
-- v0.2
-- modname
-- server message
-- v0.23
-- made it work on etpub
--
-- The printer can handle both unix and windows line endings (and mac, too)
-- in the input file, however as a price for this, it ignores any empty lines
-- in the input file. Therefore if you desire to print an empty line inside the
-- rules text, use a line with one space (or more of course) instead.
--
------------------------------------------ name ----------------------------------------------
Modname = "Rules"
Version = "0.23"
Text = "^wType ^1!rules ^wto see ^7Server rules"
function et_InitGame(levelTime,randomSeed,restart)
et.G_Print("[Rules] Version: "..Version.." Loaded
")
et.RegisterModname(Modname .. " " .. Version)
et.trap_SendServerCommand(-1, "chat \""..Text.." \"" )
end
function et_ClientConnect( cno, firstTime, isBot )
if firstTime == 1 then
et.trap_SendServerCommand(cno, "chat \""..Text.." \"" )
end
end
------------------------------------------ settings ----------------------------------------------
-- rules filename
RULES_FILENAME = "rules.txt"
----------------------------------------- functions ---------------------------------------------
-- print message to either client's console or (if clientID == nil) to server console
function printmsg(message, clientID)
if not message then
return
end
-- replace "s in message with 's
local dummy
message, dummy = string.gsub(message, "\"", "'")
if clientID then
et.trap_SendServerCommand(clientID, "print \"".. message .."^7
\"")
else
if lastcallerID then
et.trap_SendServerCommand(lastcallerID, "print \"".. message .."^7
\"")
else
et.G_Print(message .."^7
")
end
end
end
-- reads file and returns string array of rows (indexed from 1) and number of rows
function readFile(filename)
local fd, len
local rows = {}
fd, len = et.trap_FS_FOpenFile(filename, et.FS_READ)
if len == -1 then
return rows, 0
else
--read it all
local filestr = et.trap_FS_Read(fd, len)
local rowcount = 0
for line in string.gfind(filestr, "[^
]+") do
rowcount = rowcount + 1
rows[rowcount] = line
end
et.trap_FS_FCloseFile(fd)
return rows, rowcount
end
end
---------------------------------- client command functions ------------------------------
-- print rules to client
function printrules(clientID)
local playername = et.gentity_get(clientID, "pers.netname")
et.trap_SendServerCommand( clientID, "chat \"^1Console^7: ^2Open the console, ^7"..playername.." \"" )
rows, numrows = readFile(RULES_FILENAME)
printmsg("", clientID)
for i = 1, numrows do
printmsg(rows[i], clientID)
end
printmsg("", clientID)
end
--------------------------------------- callbacks ----------------------------------------
rules_cmd = "!rules"
function et_ClientCommand( clientNum, command )
-- lowercase
if et.trap_Argv(0) == "say" or et.trap_Argv(0) == "say_team" or et.trap_Argv(0) == "say_buddy" then
if string.find(et.trap_Argv(1), "^" .. rules_cmd .. "") then
printrules(clientNum)
return 1
end
end
return 0
end
stenwar.lua
Modname = "stenwar"
Version = "1.0"
Author = "Micha!"
Description = "^7Stenwar"
Homepage = "www.gs2175.fastdl.de"
--[[
Based on noweapon.lua
-------------------------------------------------------
Updated Feb 2011
Changelog:
1.0:
Known bugs u still get a knife
Initial release
-------------------------------------------------------
--]]
--Shrubbot min level to execute the command
min_level = 3
--Max covert ops allowed (normal gameplay)
maxcoverts = -1
--[[
Usage:
!stenwar on
!stenwar off
--]]
stenwar_cmd = "!stenwar"
--[[
Set to "true" to enable it
noreload = true
noreload = false
--]]
noreload = false
--Sound that get played if you enable stenwar
sound = "sound/chat/allies/953a.wav"
--------------------------------------------------------------------------------
--global vars
et.MAX_WEAPONS = 50
et.CS_PLAYERS = 689
samplerate = 200
STEN = 10
--
--note sme got no comments because it arent weapons
weapons = {
false, --WP_THROWABLE_KNIFE // 1
false, --WP_LUGER, // 2
false, --WP_MP40, // 3
false, --WP_GRENADE_LAUNCHER, // 4
false, --WP_PANZERFAUST, // 5
false, --WP_FLAMETHROWER, // 6
false, --WP_COLT, // 7 // equivalent american weapon to german luger
false, --WP_THOMPSON, // 8 // equivalent american weapon to german mp40
false, --WP_GRENADE_PINEAPPLE, / // 9
true, --WP_STEN, // 10 // silenced sten sub-machinegun
true, --WP_MEDIC_SYRINGE, // 11 // JPW NERVE -- broken out from CLASS_SPECIAL per Id request
true, --WP_AMMO, // 12 // JPW NERVE likewise
false, --WP_ARTY, // 13
false, --WP_SILENCER, // 14 // used to be sp5
true, --WP_DYNAMITE, // 15
nil, --// 16
nil, --// 17
nil, --// 18
true, --WP_MEDKIT, // 19
true, --WP_BINOCULARS, // 20
nil, --// 21
nil, --// 22
false, --WP_KAR98, // 23 // WolfXP weapons
false, --WP_CARBINE, // 24
false, --WP_GARAND, // 25
false, --WP_LANDMINE, // 26
true, --WP_SATCHEL, // 27
true, --WP_SATCHEL_DET, // 28
nil, --// 29
true, --WP_SMOKE_BOMB, // 30
false, --WP_MOBILE_MG42, // 31
false, --WP_K43, // 32
false, --WP_FG42, // 33
nil, --// 34
false, --WP_MORTAR, // 35
nil, --// 36
false, --WP_AKIMBO_COLT, // 37
false, --WP_AKIMBO_LUGER, // 38
nil, --// 39
nil, --// 40
false, --WP_SILENCED_COLT, // 41
false, --WP_GARAND_SCOPE, // 42
false, --WP_K43_SCOPE, // 43
false, --WP_FG42SCOPE, // 44
false, --WP_MORTAR_SET, // 45
true, --WP_MEDIC_ADRENALINE, // 46
false, --WP_AKIMBO_SILENCEDCOLT, // 47
false --WP_AKIMBO_SILENCEDLUGER, // 48
}
function et_InitGame(levelTime,randomSeed,restart)
maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients
gamestate = tonumber(et.trap_Cvar_Get( "gamestate" ))
et.G_Print("[Stenwar] Version:"..Version.." Loaded
")
et.RegisterModname(Modname .. " " .. Version)
blocker = 0
if stenwar == nil then
et.trap_Cvar_Set( "g_stenwar", "0" )
et.trap_Cvar_Set( "team_maxcovertops", maxcoverts )
end
end
-- called every server frame
function et_RunFrame( levelTime )
local stenwar = tonumber(et.trap_Cvar_Get( "g_stenwar" ))
--et.trap_SendServerCommand(-1, "cp \"^w"..stenwar.."
\"") -- Debug to get stenwar value
if math.mod(levelTime, samplerate) ~= 0 then return end
-- for all clients
for j = 0, (maxclients - 1) do
for k=1, (et.MAX_WEAPONS - 1), 1 do
if stenwar == 1 then
if not weapons[k] then
if noreload then
et.gentity_set(j, "ps.ammoclip", 10, 32)
end
et.gentity_set(j, "ps.ammoclip", k, 0)
et.gentity_set(j, "ps.ammo", k, 0)
et.gentity_set(j, "ps.ammo", 10, 1337)
et.gentity_set(j,"sess.latchPlayerType",4)
if checkclass(j) ~= 4 and blocker == 0 then
changeclass(j)
changeweapon(j)
SetHP()
blocker = 1
end
latchweapon(j)
end
end
end
end
end
function checkclass(client)
local cs = et.trap_GetConfigstring(et.CS_PLAYERS + client, 4)
return tonumber(et.Info_ValueForKey(cs, "c"))
end
function changeclass(client)
local cs = et.trap_GetConfigstring(et.CS_PLAYERS + client)
local infoclass = et.Info_SetValueForKey( cs, "c", 4 )
et.trap_SetConfigstring(689 + client, infoclass)
end
function changeweapon(client)
local cs = et.trap_GetConfigstring(et.CS_PLAYERS + client)
local infoweapon = et.Info_SetValueForKey( cs, "w", STEN )
et.trap_SetConfigstring(689 + client, infoweapon)
end
function latchweapon(slot)
local fallback -- default weapon
if team == AXIS then
fallback = STEN
else fallback = STEN
end
-- now update the client (in order for the change to be immidieate, and not wait for the server, we need to update the client's configstring)
local infostring
infostring = et.trap_GetConfigstring(689 + slot)
infostring = et.Info_SetValueForKey( infostring, "lw", fallback )
et.trap_SetConfigstring(689 + slot, infostring)
et.gentity_set(slot,"sess.latchPlayerWeapon",fallback)
end
function getlevel(client)
local lvl = et.G_shrubbot_level(client)
if lvl >= min_level then
return true
elseif lvl < min_level then
et.trap_SendServerCommand(client, "cpm \"^3Sorry, you don't have the right to execute this command
\" " )
return false
end
return nil
end
function SetHP()
for target = 0, (maxclients - 1) do
local hp = tonumber(et.gentity_get(target,"health"))
if hp < 0 then
return
else
et.gentity_set(target, "health", -200)
end
end
end
function et_ClientCommand(client, command)
local stenwar = tonumber(et.trap_Cvar_Get( "g_stenwar" ))
if getlevel(client) then
if et.trap_Argv(0) == "say" or et.trap_Argv(0) == "say_team" or et.trap_Argv(0) == "say_buddy" or et.trap_Argv(0) == "say_teamnl" then
local s, e, type = string.find(et.trap_Argv(1), "^" .. stenwar_cmd .. " ([%w%_]+)$")
if type == "on" and stenwar == 0 then
et.trap_Cvar_Set( "g_stenwar", "1" )
et.G_globalSound( sound )
et.trap_SendServerCommand(-1, "chat \"^.stenwar: ^3stenwar ^1enabled\" " )
elseif type == "off" and stenwar == 1 then
et.trap_Cvar_Set( "g_stenwar", "0" )
for j = 0, (maxclients - 1) do
et.gentity_set(j, "ps.ammo", 10, 96)
end
et.trap_SendServerCommand(-1, "chat \"^.stenwar: ^3stenwar ^1disabled\" " )
elseif type == "on" and stenwar == 1 then
et.trap_SendServerCommand(client, "cpm \"^.stenwar: ^3stenwar ^wis already ^1on\" " )
elseif type == "off" then
et.trap_SendServerCommand(client, "cpm \"^.stenwar: ^3stenwar ^wmust be ^1on ^wbefore you can disable it\" " )
end
if string.lower(et.trap_Argv(1)) == stenwar_cmd then
if string.lower(et.trap_Argv(2)) == "on" and stenwar == 0 then
et.trap_Cvar_Set( "g_stenwar", "1" )
et.trap_Cvar_Set( "team_maxcovertops", "-1" )
et.G_globalSound( sound )
et.trap_SendServerCommand(-1, "chat \"^.stenwar: ^3stenwar ^1enabled\" " )
elseif string.lower(et.trap_Argv(2)) == "off" and stenwar == 1 then
et.trap_Cvar_Set( "g_stenwar", "0" )
et.trap_Cvar_Set( "team_maxcovertops", maxcoverts )
for j = 0, (maxclients - 1) do
et.gentity_set(j, "ps.ammo", 10, 96)
end
et.trap_SendServerCommand(-1, "chat \"^.stenwar: ^3stenwar ^1disabled\" " )
elseif string.lower(et.trap_Argv(2)) == "on" and stenwar == 1 then
et.trap_SendServerCommand(client, "cpm \"^.stenwar: ^3stenwar ^wis already ^1on\" " )
elseif string.lower(et.trap_Argv(2)) == "off" then
et.trap_SendServerCommand(client, "cpm \"^.stenwar: ^3stenwar ^wmust be ^1on ^wbefore you can disable it\" " )
elseif string.lower(et.trap_Argv(2)) == "" then
et.trap_SendServerCommand(client, "cpm \"^3!stenwar ^1on/off\" " )
end
end
end
end
return 0
end
This lua fixes the mapscript bug which could appear if players vote a map with upper letters and mapscript is lower letters. (Note: mapscripts must be lower letters now)
votefix.lua
Modname = "votefix"
Version = "0.1"
Author = "Perlo_0ung?!"
function et_InitGame(levelTime,randomSeed,restart)
et.G_Print("[votefix] Version:"..Version.." Loaded
")
et.RegisterModname(Modname .. " " .. Version)
end
et.CS_VOTE_STRING = 7
function et_Print(text)
local t = ParseString(text) --Vote Passed: Change map to suppLY
if t[2] == "Passed:" and t[4] == "map" then
if string.find(t[6],"%u") == nil or t[6] ~= getCS() then return 1 end
local mapfixed = string.lower(t[6])
et.trap_SendConsoleCommand( et.EXEC_APPEND, "ref map " .. mapfixed .. "
" )
end
end
function ParseString(inputString)
local i = 1
local t = {}
for w in string.gfind(inputString, "([^%s]+)%s*") do
t[i]=w
i=i+1
end
return t
end
function getCS()
local cs = et.trap_GetConfigstring(et.CS_VOTE_STRING)
local t = ParseString(cs)
return t[4]
end
randomspawn.lua
spawndistance = 400
function et_InitGame(levelTime,randomSeed,restart)
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
mapname = et.trap_Cvar_Get( "mapname" )
local loadtable = loadfile(et.trap_Cvar_Get("fs_homepath") .. '/etpub/spawns/'..mapname..'.lua') --- load spawns table
if loadtable ~= nil then
loadtable()
else
--et.trap_SendServerCommand(-1, "chat \"^3LOADSPWANPOINTS^7: ^7No valid spawnsfile found for this map.\"" )
et.G_Print("WARNING: SPAWNPOINTS failed to load "..mapname..".lua
")
quit = 1
end
end
function dist(a ,b)
local dx = math.abs(b[1] - a[1])
local dy = math.abs(b[2] - a[2])
local dz = math.abs(b[3] - a[3])
local d = math.sqrt((dx ^ 2) + (dy ^ 2) + (dz ^ 2))
return math.floor(d / 52.4934)
end
function et_ClientSpawn(cno,revived)
execute = 1
if quit ~= 1 then
while execute == 1 do
rpos = {}
spawn = randomspawn()
for i=0, mclients-1, 1 do
if et.gentity_get(i,"pers.connected") == 2 and cno ~= i then
CurrentPos(i)
end
end
table.sort(rpos)
if rpos[1] == nil then execute = 0 break end
end
et.gentity_set(cno, "origin", spawn)
end
end
function randomspawn()
local random = SPAWN[math.random(table.getn(SPAWN))]
return random
end
function CurrentPos(cno)
local cnopos = et.gentity_get(cno,"r.currentOrigin")
distance = dist(cnopos,spawn)
if distance > spawndistance then
table.insert(rpos,distance)
end
end
randomspawn.lua:
Make a folder in your mod folder named “spawns” and put the map lua files in there.
Example for oasis:
oasis.lua
SPAWN = {}
SPAWN[1] = {27, 2038, -325}
SPAWN[2] = {2405, 1752, -577}
SPAWN[3] = {3048, 1890, -458}
SPAWN[4] = {1433, 3880, -93}
SPAWN[5] = {5206, 4585, -835}
SPAWN[6] = {3372, 5834, -207}