ETMods.net

N!tmod, a Wolfenstein: Enemy Territory Modification!

You are not logged in.

Announcement

You can donate to help us keeping services online.

#1 19-Aug-14 20:38:46

mazak
Member
From: Poland
Registered: 11-Jun-13
Posts: 37

Please help me. Heavy weapons

Hello!
Someone can help me with script lua.?
I wanna do Block Heavy Weapons for few Maps.
Its My Script:

AUTOR = Narkotyk
MODNAME = "Heavyweapons"
MODVERSION = "1.0"

numconn = 0
function et_InitGame(leveltime, randomseed, restart)
et.RegisterModname(string.format("%s %s", AUTOR, MODNAME, MODVERSION))
end

function et_ClientUserinfoChanged(clientNum)
local numconn = 0

for i=0,et.trap_Cvar_Get("sv_maxclients") - 1 do
if (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 1) or (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 2) then
numconn = numconn + 1
end
end

if (numconn < 21) then	
et.trap_Cvar_Set("g_heavyWeaponRestriction", "0")
elseif (numconn >= 21) then	
et.trap_Cvar_Set("g_heavyWeaponRestriction", "50")
end
end

--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------MAPS--------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------

map_table = {
	{ mapname = "psknife", 		heavy = "0", },        
	{ mapname = "fragps",		        heavy = "0", },
	{ mapname = "fragmaze_fixed",	heavy = "0", },
	{ mapname = "purefrag_news",	heavy = "0", },
	{ mapname = "twc_fragzone",	        heavy = "0", },
	{ mapname = "element_b4_1",	heavy = "0", },
}


function et_InitGame(leveltime, randomseed, restart)
mapnames = et.trap_Cvar_Get( "mapname" )
	
for _, line in ipairs(map_table) do
if mapnames == line.mapname then
local heavy = line.heavy
et.trap_SendConsoleCommand( et.EXEC_APPEND, "g_heavyWeaponRestriction"..heavy.."\n" )
end
end
end

If is 21 players online Heavy weapons is OFF but if is 22 Player online Heavy weapons is ON. I Wanna do OFF all time in Map. What i do Wrong?


45868182.jpg
560x95_FFFFFF_FF9900_000000_000000.png

Offline

#2 23-Aug-14 00:37:04

ailmanki
BETA Tester
Registered: 08-Jun-12
Posts: 42
Website

Re: Please help me. Heavy weapons

mazak wrote:

Hello!
If is 21 players online Heavy weapons is OFF but if is 22 Player online Heavy weapons is ON. I Wanna do OFF all time in Map. What i do Wrong?

You don't need this script for always disabling heavy weapons regardless of player count.
Just mapconfigs and set g_heavyWeaponRestriction 0  for those maps you want it to be disabled.
Remember to use a default cfg and set the value to whatever you want.


b_350_20_692108_381007_FFFFFF_000000.pngb_350_20_692108_381007_FFFFFF_000000.png

Offline

#3 23-Aug-14 10:39:48

mazak
Member
From: Poland
Registered: 11-Jun-13
Posts: 37

Re: Please help me. Heavy weapons

I use Mapconfig configs, but when there is 22 players on server heavy weapon will turn on. So thats why i want to do bypass in lua to heavy weapon won't turn on, on selected map.


45868182.jpg
560x95_FFFFFF_FF9900_000000_000000.png

Offline

#4 23-Aug-14 12:08:50

ailmanki
BETA Tester
Registered: 08-Jun-12
Posts: 42
Website

Re: Please help me. Heavy weapons

Well not sure there what you want.
The script you posted does turn heavy weapons on at 22 players.. so I suppose its just the script which turns that on?


b_350_20_692108_381007_FFFFFF_000000.pngb_350_20_692108_381007_FFFFFF_000000.png

Offline

#5 02-Sep-14 15:37:22

mazak
Member
From: Poland
Registered: 11-Jun-13
Posts: 37

Re: Please help me. Heavy weapons

Script work in 100% but Heavy weapons no trun on in selected maps: element_b4_1, twc_fragzone... Mapconfig its not not help becouse Scirpt turn ON if be 22 players on serwer...

Somebody Can Help Me ??


45868182.jpg
560x95_FFFFFF_FF9900_000000_000000.png

Offline

#6 02-Sep-14 22:31:44

Micha
Member
From: Germany
Registered: 11-Feb-13
Posts: 38
Website

Re: Please help me. Heavy weapons

AUTHOR = "Narkotyk"		--must be in "
MODNAME = "Heavyweapons"
MODVERSION = "1.0"

heavyweapon = "50" -- heavy weapon value
playernum = 22

--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------MAPS--------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------

map_table = {
	{ mapname = "psknife", },        
	{ mapname = "fragps", },
	{ mapname = "fragmaze_fixed", },
	{ mapname = "purefrag_news", },
	{ mapname = "twc_fragzone", },
	{ mapname = "element_b4_1", },
}


function et_InitGame(leveltime, randomseed, restart)
	et.RegisterModname(MODNAME.." "..MODVERSION.." "..AUTHOR)		--do no use string.format here

	mapnames = string.lower(et.trap_Cvar_Get( "mapname" )) 	--better use string.lower or string.upper else your lua can break 
															--> checking for supply but map is SuPPly so it will think it is different
end

function et_ClientUserinfoChanged(clientNum)
local numconn = 0

for i=0,et.trap_Cvar_Get("sv_maxclients") - 1 do
	if (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 1) or (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 2) then
		numconn = numconn + 1
	end
end


if (numconn < playernum) then	
	et.trap_Cvar_Set("g_heavyWeaponRestriction", "0")
elseif (numconn >= playernum) then
	for _, line in ipairs(map_table) do
		if mapnames ~= string.lower(line.mapname) then	
			et.trap_Cvar_Set("g_heavyWeaponRestriction", heavyweapon)
			--et.trap_SendConsoleCommand( et.EXEC_APPEND, "qsay heavyweapons: on\n" )	--not used because of spam
		end
	end
end
end

Last edited by Micha (02-Sep-14 22:33:55)

Offline

#7 06-Sep-14 08:42:22

mazak
Member
From: Poland
Registered: 11-Jun-13
Posts: 37

Re: Please help me. Heavy weapons

Still heavy weapons turn on in maps:

map_table = {
    { mapname = "psknife", },        
    { mapname = "fragps", },
    { mapname = "fragmaze_fixed", },
    { mapname = "purefrag_news", },
    { mapname = "twc_fragzone", },
    { mapname = "element_b4_1", },
}

When on server playing 22 Players.


45868182.jpg
560x95_FFFFFF_FF9900_000000_000000.png

Offline

Board footer

Powered by FluxBB