I assumed this would work to toggle showing +5 on the screen (it is just a test at the moment.)
[lua]On_Off = false
function Show_Toggle()
if !(On_Off) then
hook.Add( "HUDPaint", "points", function()
draw.SimpleText( "+5", "DefaultSmall", 500, 500, Color(255,0,0,150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
print("hello???????")
end )
else
hook.Remove( "HUDPaint", "points")
end
On_Off = !(On_Off)
end
concommand.Add("Toggle_Show",On_Off) [/lua]
But I just get nothing, but it the code to show the +5 does work as if I put it outside of the function it shows perfectly fine, so I guess my question is it possible to call a hook like this?
[QUOTE=iRzilla;18008526][lua]
On_Off = true
function Show_Toggle()
if On_Off then
hook.Add( "HUDPaint", "points", function()
draw.SimpleText( "+5", "DefaultSmall", 500, 500, Color(255,0,0,150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
print("hello???????")
end )
else
hook.Remove( "HUDPaint", "points")
end
On_Off = !On_Off
end
concommand.Add("Toggle_Show",On_Off)
[/lua][/QUOTE]The problem is the concommand name.
Try this
[lua]local toggle;
local function hudfunc()
draw.SimpleText( "+5", "DefaultSmall", 500, 500, Color(255,0,0,150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
print("hello???????")
end
concommand.Add("Toggle_Show",function()
toggle = not toggle;
if toggle then
hook.Add( "HUDPaint", "Points", hudfunc );
else
hook.Remove( "HUDPaint", "Points" );
end
end);[/lua]
toggle is blocked in concommands.
[lua]ON = true;
function ccShowToggle( ply, cmd, args )
if( ON ) then
hook.Add( "HUDPaint", "points", function()
draw.SimpleText( "+5", "DefaultSmall", 500, 500, Color(255,0,0,150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER );
end );
else
hook.Remove( "HUDPaint", "points" );
end
ON = !ON;
end
concommand.Add( "ShowPoints", ccShowToggle )[/lua]
Thank you so very much! :D
Sorry, you need to Log In to post a reply to this thread.