• Lua Error (Been stuck on it for days)
    5 replies, posted
Ok, so here's the deal, I am trying to make a HUD for Garry's mod but I get the following Error: [ERROR] gamemodes/sci-fi rp/gamemode/cl_hud.lua:9: ')' expected near '0' 1. unknown - gamemodes/sci-fi rp/gamemode/cl_hud.lua:0 the code for hiding the old HUD is: local NoShow = { 'CHudHealth', 'CHudBattery' } hook.Add( 'HUDShouldDraw', 'DeleteBadStuff', function( element ) for _, v in pairs( NoShow ) do if ( element == v ) then return false end end end ) and the code for my new HUD is: function CMyHUD() local ply = LocalPlayer() local HP = ply:Health() local Armor = ply:Armor() draw.RoundedBox( 4, 130, ScrH() - 100, 200, 40, Color( 40, 40, 40, 120 ) ) draw.RoundedBox( 4, 130, ScrH() - 100, math.Clamp( HP 0, 200)*2, 40, Color( 220, 20, 60, 255) ) draw.RoundedBox( 4, 130, ScrH() - 100, math.Clamp( HP 0, 200)*2, 15, Color( 255, 255, 255, 40) ) end hook.Add( "HUDShouldDraw", "CoolHUD", MyHUD ) I've been looking through this code all Weekend just pondering on the subject and i just cant get it to work, so I have come to the aid of other Lua coders and This is why I ask you, Whyyyyyyyyyyyyyy!!!!?????
Goto line 9, remove 5 lines above and below and manually retype everything. There's a symbol that corrupted the file but I don't know exactly what causes it.
[QUOTE=Robotboy655;42905304]Goto line 9, remove 5 lines above and below and manually retype everything. There's a symbol that corrupted the file but I don't know exactly what causes it.[/QUOTE] k ill try that [editline]18th November 2013[/editline] [QUOTE=Robotboy655;42905304]Goto line 9, remove 5 lines above and below and manually retype everything. There's a symbol that corrupted the file but I don't know exactly what causes it.[/QUOTE] I just tried that But Im still getting the same error Any other ideas?
[CODE]surface.CreateFont( "ScoreboardText", { font = "Arial", size = 13, 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 myhud() local client = LocalPlayer() if !client:Alive() then return end if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end draw.RoundedBox(50, 6, 500, 200, 100, Color(255, 0, 0, 255)) draw.SimpleText(client:Health() .. "%", "ScoreboardText", 100, 550, Color(255, 255, 255, 255), 0, 0) local mag_left = client:GetActiveWeapon():Clip1() local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()) local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType()) end hook.Add("HUDPaint", "myhud", myhud) local tohide = { ["CHudHealth"] = true, ["CHudBattery"] = true, ["CHudAmmo"] = true, ["CHudSecondaryAmmo"] = true } local function HUDShouldDraw(name) if (tohide[name]) then return false; end end hook.Add("HUDShouldDraw", "How to: HUD Example HUD hider", HUDShouldDraw)[/CODE] Try using this
[QUOTE=crazymankills;42905636][CODE]surface.CreateFont( "ScoreboardText", { font = "Arial", size = 13, 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 myhud() local client = LocalPlayer() if !client:Alive() then return end if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end draw.RoundedBox(50, 6, 500, 200, 100, Color(255, 0, 0, 255)) draw.SimpleText(client:Health() .. "%", "ScoreboardText", 100, 550, Color(255, 255, 255, 255), 0, 0) local mag_left = client:GetActiveWeapon():Clip1() local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()) local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType()) end hook.Add("HUDPaint", "myhud", myhud) local tohide = { ["CHudHealth"] = true, ["CHudBattery"] = true, ["CHudAmmo"] = true, ["CHudSecondaryAmmo"] = true } local function HUDShouldDraw(name) if (tohide[name]) then return false; end end hook.Add("HUDShouldDraw", "How to: HUD Example HUD hider", HUDShouldDraw)[/CODE] Try using this[/QUOTE] Thanks for this, will be using this for now but since I'm learning lua I would rather understand the code much more, but thx anyway
[code]math.Clamp( HP 0, 200)[/code] You are missing a comma after HP in both calls to math.Clamp
Sorry, you need to Log In to post a reply to this thread.