Im not sure if this is the place to post this but im new to lua but have experience in other languages. Im making an addon for my server that when an admin types a command, it will make a gui display on all the clients, any idea on how to do this, i have made the gui but i dont know how i would send a command to the client to add the hook, then another to remove it. Heres my code so far
[CODE]function showLU()
hook.Add("HUDShouldDraw","TestHUD",drawHUD)
end
function hideLU()
hook.Remove("HUDShouldDraw","TestHUD")
end
surface.CreateFont( "LUF", {
font = "Default",
size = ScreenScale(40),
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "MSGF", {
font = "Default",
size = ScreenScale(20),
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
function drawHUD()
MSG="Message to display"
local x = ScrW()
local y = ScrH()
draw.RoundedBox(3, 0, y/6, 2444, ScreenScale(100), Color(0,0,0,120))
draw.SimpleText("LISTEN UP!", "LUF", x/2, y/6+ScreenScale(25), Color(255,255,255),1, 1)
draw.SimpleText(MSG, "MSGF", x/2, y/6+ScreenScale(65), Color(200,200,200),1, 1)
end[/CODE]
Use HUDPaint instead HUDShouldDraw
[QUOTE=gonzalolog;45606316]Use HUDPaint instead HUDShouldDraw[/QUOTE]
Thanks, but how would i make it so that this will only show for all clients on the server if i type in a server command
Server side add this.
[code]
hook.Add( "PlayerSay", "Swag", function( ply, text, team )
if ( string.lower(string.sub( text, 1, 5 )) == "/show" and ply:IsAdmin() ) then
BroadcastLua( "showLu()" )
return ""
end
end )
[/code]
[QUOTE=AnonTakesOver;45606390]Server side add this.
[code]
hook.Add( "PlayerSay", "Swag", function( ply, text, team )
if ( string.lower(string.sub( text, 1, 5 )) == "/show" and ply:IsAdmin() ) then
BroadcastLua( "showLu()" )
return ""
end
end )
[/code][/QUOTE]
I Think I Understand it, but what does BroadcastLu() Do?
EDIT : Nevermind, Thanks. Lets hope it works
[QUOTE=0V3RR1D3;45606433]I Think I Understand it, but what does BroadcastLu() Do?[/QUOTE]
Executes the command on all clients.
You guys are life savers, Sorry for such a dumb question and thanks!
[editline]6th August 2014[/editline]
Also one more thing, is it possible to update lua on my server without having to do a sever restart each time to test? Like a way to reload all the lua scripts?
[QUOTE=0V3RR1D3;45606455]You guys are life savers, Sorry for such a dumb question and thanks!
[editline]6th August 2014[/editline]
Also one more thing, is it possible to update lua on my server without having to do a sever restart each time to test? Like a way to reload all the lua scripts?[/QUOTE]
If the server is on Windows, auto-refresh should work.
[QUOTE=code_gs;45606486]If the server is on Windows, auto-refresh should work.[/QUOTE]
It is, im using nitrous networks to host it, Also its in lua/autorun
[editline]6th August 2014[/editline]
Also I Knwo im pushing my luck now but i have a variable called MSG, How could I set that , Like say i did /slu Myu message to display here aka set the msg variable to this xD
[editline]6th August 2014[/editline]
Bump
[editline]6th August 2014[/editline]
Bump
[editline]6th August 2014[/editline]
Dont worry, fixed it, Thanks for all the help. Best forum ever!
[CODE] if ( string.lower(string.sub( text, 1, 5 )) == "/slu=" and ply:IsAdmin() ) then
textMSG = string.Split(text,"=")
BroadcastLua("showLU('"..textMSG[2].."')")
return ""
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.