I’m new to LUA scripting. I’m trying this, but I cant get it to run.
So this is how it is;
This is for a flood server. (in case you dont know the gamemode…) There are 4 phases in the mode, Build(TimerStatus 1), Flood(TimerStatus 2, Fight(TimerStatus 3), RoundRestart(TimerStatus 4).
I want to make it so when a map change occurs, if its on TimerStatus 3, it sets it to 4, then removes all the props, refunds them, then after 15 seconds it changes the map. I think I successfully written the function for it (see below, and please check if its correct).
Flood mod has a customized cl_menu, thus it has its own admin interface including things like kick, ban and slay. I changed this interface to map changer, leaving kick and ban to assmod. I want my admins to change map via this admin interface (not via assmod).
This is the function I’ve written, its on init.lua (I dont even know if its in the right section)
function ChangeIt(maptc) RunConsoleCommand("changelevel " .. maptc .. " ") end function MapChg(pl, args) if pl:IsAdmin() or pl:IsSuperAdmin() then local maptc = args if TimerStatus == 3 then TimerStatus = 4 RefundProps() // a flood mod func that removes and refunds props SaveProfile() // a flood mod func that saves cash ReflectTime = RV // a flood mod var that is needed to switch to timerstatus 4 timer.Create( "Mapchg", 15, 1, ChangeIt, maptc ) for k, v in pairs(player.GetAll()) do v:PrintMessage(HUD_PRINTTALK, "Map change to " .. maptc .. " in 15 seconds") end else RefundProps() // a flood mod func that removes and refunds props SaveProfile() // a flood mod func that saves cash timer.Create( "Mapchg", 15, 1, ChangeIt, maptc ) for k, v in pairs(player.GetAll()) do v:PrintMessage(HUD_PRINTTALK, "Map change to " .. maptc .. " in 15 seconds") end end else return false end end concommand.Add("FLMapChange", MapChg)
With my limited knowledge of lua and bit of a search on google; I’ve set this to a button in admin interface:
But it doesnt work, says this in clients console when clicked on the button:
Flood\gamemode\cl_Menu.lua:359: attempt to call global 'FLMapChange' (a nil value)
How can I call this function from init.lua to cl_menu.lua?
Or is there another way to do it?
Thanks in advance,