-- gw_ref lua script -- By GhosT:McSteve, 3.12.06, www.ghostworks.co.uk -- Thanks to Fusion for his patience during the debugging. -- Credit to im2good4u for his noweapons script. -- This lua script adds in additional commands available to refs. -- It was written in response to the ability of one or more etBots to disrupt the operation of ET admin_mod. -- INSTALLATION: save the gw_refv1.lua script in the server's etpro folder -- add the line: set lua_modules "gw_refv2.lua" to your server.cfg -- Restart your server. -- COMMANDS: !gwown, !gwdisarm, !gwresetown, !gwresetdisarm, !gwresetall -- USAGE: !gwown , !gwdisarm , !gwresetXXX commands need no slot number -- !gwown = player dies whenever they kill someone -- !gwdisarm = removes all ammo from weaponbanks, players left with knife and syringe/pliers only ----------------------------------------------------------------------------- --global vars et.MAX_WEAPONS = 50 samplerate = 2000 -- check player state every x milliseconds -- im2good4u's no weapon script weapons = { nil, --// 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 false, --WP_STEN, // 10 // silenced sten sub-machinegun true, --WP_MEDIC_SYRINGE, // 11 // JPW NERVE -- broken out from CLASS_SPECIAL per Id request false, --WP_AMMO, // 12 // JPW NERVE likewise false, --WP_ARTY, // 13 false, --WP_SILENCER, // 14 // used to be sp5 false, --WP_DYNAMITE, // 15 nil, --// 16 nil, --// 17 nil, --// 18 false, --WP_MEDKIT, // 19 false, --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 false, --WP_SATCHEL, // 27 false, --WP_SATCHEL_DET, // 28 nil, --// 29 false, --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 } -- on game initialise, get the maxclients and initialise the own_client array (holds 1 or 0 for each client) function et_InitGame( levelTime, randomSeed, restart ) --called on game initialise maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients own_client = {} disarm_client = {} for i = 0, (maxclients - 1) do own_client[i] = 0 disarm_client[i] = 0 end end -- called every server frame function et_RunFrame( levelTime ) if math.mod(levelTime, samplerate) ~= 0 then return end -- for all clients for j = 0, (maxclients - 1) do -- check to see if client is marked for disarm if disarm_client[j] == 1 then -- if yes (1) for k=1, (et.MAX_WEAPONS - 1), 1 do if not weapons[k] then et.gentity_set(j, "ps.ammoclip", k, 0) et.gentity_set(j, "ps.ammo", k, 0) --et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3runtime\"\n") end end --return 0 end end end -- called on client command function et_ClientCommand(cno, cmd) -- first off, want to ignore anything not coming from a ref if et.gentity_get(cno, "sess.referee") == 0 then return end -- if command is not say, then end if cmd ~= "say" then return end ---------------------------------------------------------------------- --DEBUG HERE WITH !test if et.trap_Argv(1) == "!test" then --command buffer contents should begin with "say !disarm", (1) and (2) --announce the values et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3COMMAND !test captured\"\n") --check the player's class (sess.playerType) --cno_class = et.gentity_get(cno, "sess.playerType") --check if the player is a ref is_ref = et.gentity_get(cno, "sess.referee") var3 = string.format("qsay \"is_ref = %s \"\n", is_ref) et.trap_SendConsoleCommand(et.EXEC_APPEND, var3) --check if the states of own_client and disarm_client own_out = own_client[cno] var4 = string.format("qsay \"own_client = %s \"\n", own_out) et.trap_SendConsoleCommand(et.EXEC_APPEND, var4) --check if the states of own_client and disarm_client disarm_out = disarm_client[cno] var5 = string.format("qsay \"disarm_client = %s \"\n", disarm_out) et.trap_SendConsoleCommand(et.EXEC_APPEND, var5) end ---------------------------------------------------------------------- -- !gwown command here if et.trap_Argv(1) == "!gwown" then --announce !own issued et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3!own command received\"\n") --if command is "say !own x", where x is the client number, then set own_client[x] x = tonumber(et.trap_Argv(2)) own_client[x] = 1 end -- !gwdisarm command here if et.trap_Argv(1) == "!gwdisarm" then --announce !own issued et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3!gwdisarm command received\"\n") --if command is "say !own x", where x is the client number, then set own_client[x] x = tonumber(et.trap_Argv(2)) disarm_client[x] = 1 end -- !gwresetown command to remove any own_client values if et.trap_Argv(1) == "!gwresetown" then --announce !gwreset_own issued et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3!gwresetown command received\"\n") --reset all own_client values to 0 for i = 0, maxclients - 1 do own_client[i] = 0 end end -- !gwresetdisarm command to remove any own_client values if et.trap_Argv(1) == "!gwresetdisarm" then --announce !reset_own issued et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3!gwresetdisarm command received\"\n") --reset all own_client values to 0 for i = 0, maxclients - 1 do disarm_client[i] = 0 end end -- !gwresetall command to remove any own_client values if et.trap_Argv(1) == "!gwresetall" then --announce !reset_own issued et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3!gwresetall command received\"\n") --reset all own_client values to 0 for i = 0, maxclients - 1 do own_client[i] = 0 disarm_client[i] = 0 end end end --on a player death, check to see if the killer is flagged up for ownage function et_Obituary( victim, killer, meansOfDeath ) -- if the killer is flagged for ownage, then own the bastard if own_client[killer] == 1 then -- explanation - et.G_Damage( target, inflictor, attacker, damage, dflags, mod ), mod 0 = unknown et.G_Damage( killer, 80, victim, 1000, 8, meansOfDeath ) -- bring the victim back to life here -- note: this doesn't work very well; victim seems to be "dead" hence another kill doesnt register -- et.gentity_set(victim, "health", 100) -- sends message via qsay, method taken from hadro's anti-sk bot msg = "%s ^7just got owned!" msg = string.format(msg, et.Info_ValueForKey(et.trap_GetUserinfo(killer), "name")) msg = string.format("qsay %s\n", msg) et.trap_SendConsoleCommand(et.EXEC_APPEND, msg) end end -- on client disconnect, empty the own_client value for that slot function et_ClientDisconnect( cno ) own_client[cno] = 0 disarm_client[cno] = 0 end