You are not logged in.
Pages: 1
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?
Offline
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.
Offline
Offline
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)
Made Hide&Seek mod: http://forums.warchest.com/showthread.p … -Seek-pack
Creator of Infected Mod: http://forums.warchest.com/showthread.p … d-Infected
Offline
Offline
Pages: 1