Combine Hud: Metrocop: What's the error/how do I fix it?
0 replies, posted
I feel like I'm being completely ignored D: :tinfoil:
[URL="http://facepunch.com/showthread.php?p=39335855#post39335855"]luavirusfree posted:[/URL]
Lol, damn. I guess I'm missing an '=' here?
[ERROR] lua_run:1: '=' expected near '<eof>'
1. unknown - lua_run:0
Also, what tag do you put errors in to make them look like that one comment on this thread?
[lua]
if (SERVER) then return nil end -- We only draw on the client. There is no screen for the server, EVER, even if the host is the server, it's the computer, not them. True for laptops and desktops!
hud = {} -- Creates a lonely table for ONE function.
--hud.maxammo = {} -- Table to get our current weapon's max ammo.
hud.maxammo = 18 -- Max ammo for the pistol. This will change if we have the SMG1.
-- I will comment this so that anyone can understand if they want to make their own HUD. --
function MetroHud() -- Main bulk of the code, loops on.
if hidden then return end -- The player wanted to hide the HUD. Too bad D: we do nothing!
local Scrw, Scrh = ScrW(), ScrH() -- Creates two variables, screen width Scrw, and screan height Scrh. They are exactly equal to the true game resolution.
local HudBG = { -- Names the table of settings.
texture = surface.GetTextureID "CombineHud/met_comb_ovr_2048", -- What texture to use
color = Color(255,255,255,255), -- What color (this color does no change) (RED,GReeN,BLUe,Alpha)
x = 0, -- 0 is the exact start of the width (X is width)
y = 0, -- 0 is the exact start of the height (Y is height)
w = Scrw, -- Cover the entire screen. Width = w
h = Scrh -- Cover the entire screen. Height = h
} -- Ends the table.
local Client = LocalPlayer() -- The player that sees the HUD. Always him or her, never a connected player.
draw.TexturedQuad( HudBG ) -- Draws what the {table} above, HudBG, says to draw.
local HealthBackMet = surface.GetTextureID "CombineHud/met_health_bg" -- Background image for the health readout.
local HealthBarMet = surface.GetTextureID "CombineHud/met_health_bar" -- Image of the actual meter for shields.
local SuitBackMet = surface.GetTextureID "CombineHud/met_shld_lvl" -- Background image for the shield readout.
local SuitBarMet = surface.GetTextureID "CombineHud/met_shld_lvl" -- Image of the actual meter for shields.
local CommandPost = surface.GetTextureID "CombineHud/met_command" -- Not used yet!
local Criminal = surface.GetTextureID "CombineHud/met_criminal" -- Not used yet!
local Promotion = surface.GetTextureID "CombineHud/met_promo" -- Not used yet!
local MeterWidth = Scrw / 4 -- The meter's actual size is one forth of the screen's width.
local MeterWidthBarEnd = MeterWidth-(MeterWidth*math.min((Client:Health()/40),1)*0.5) -- Max health as a metro cop? 40. This sets up the bar for health.
local MeterWidthBar = MeterWidth-(MeterWidth*math.min((Client:Armor()/25),1)*0.5) -- Max shield as a metro cop? 25. This sets up the bar for shield.
local MeterHeight = MeterWidth/4 -- Since the texture resolution for width is 4x the height, we take one forth of our width for height.
surface.SetTexture( HealthBackMet ) -- This tells the game what image to draw.
surface.DrawTexturedRectRotated(Scrw/4,Scrh+MeterHeight,MeterWidth,MeterHeight,0) -- This draws an image. Format: Position <>, position ^v, Width <>, Height &v, Counter Clock Rotation
surface.SetTexture( HealthBarMet ) -- This tells the game what image to draw, and overrides the last time it was set so we don't keep drawing the same thing.
surface.DrawTexturedRectUV(Scrw/4,Scrh+MeterHeight,MeterWidthBarEnd,MeterHeight,MeterWidthBarEnd,MeterHeight) -- Draws the image. Format: Pos Wide, Pos Tall, Image Width, Image Height, How much to show texture wide, same for height.
local PosShieldsX = Scrw-MeterWidth-(Scrw/4) -- Variable. Used so that we draw on the other side of the screen mathematically.
-- local PosShldMetX = Scrw-(MeterWidth*1.5)-(Scrw/4) -- Half way further away because we didn't flip it. -- This was removed when we did flip it.
surface.SetTexture( SuitBackMet ) -- Set and replace image...
surface.DrawTexturedRectRotated(PosShieldsX,Scrh,MeterWidth,MeterHeight,0) -- This draws an image. Format: Position <>, position ^v, Width <>, Height &v, Counter Clock Rotation
surface.SetTexture( SuitBarMet ) -- Set and replace image...
surface.DrawTexturedRectUV(PosShieldsX,Scrh,MeterWidthBar,MeterHeight,MeterWidthBarEnd,MeterHeight) -- Draws the image. Format: Pos Wide, Pos Tall, Image Width, Image Height, How much to show texture wide, same for height.
if Client:GetActiveWeapon():GetPrintName() == "USP Match mod" then hud.maxammo = 18 -- The max ammo for the pistol is 18, 19 with chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "STUNSTICK" then hud.maxammo = -1 -- The Stunstick has 100% ammo, 100 Guass Energy 'rounds'.
elseif Client:GetActiveWeapon():GetPrintName() == "MP7A1 mod" then hud.maxammo = 45 -- The MP7 (SMG1) has 45 rounds, 46 with chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "SPAS-12 mod" then hud.maxammo = 6 -- The shotgun has a 6 round 'clip', with no chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "Pulse Rifle" then hud.maxammo = 30 end -- The shotgun has a 30 round 'clip', with no chamber.
end
hook.Add( "HUDPaint", "MetroHUD", MetroHud ) -- This tells the game to draw the function as the HUD. Format: What to do, A unique name (what purpose?), What function to use to do it. Called before every frame that is drawn.
function HideHUD( name ) -- Allow the combine elements, hide the regular.
if !hidden then -- If the HUD is hidden, then do this:
if name == "CHudHealth" then return false end -- Says that we don't want the DEFAULT health display.
if name == "CHudBattery" then return false end -- Says that we don't want the DEFAULT battery display.
if name == "CHudAmmo" then return false end -- Says that we don't want the DEFAULT ammo display.
if name == "CHudSecondaryAmmo" then return false end -- Says that we don't want the DEFAULT alt-fire ammo display.
if name == "CHudCrosshair" then return false end -- Says that we don't want the DEFAULT crosshair.
if name == "CHudDeathNotice" then return false end -- Says that we don't want to know who killed who, and who died.
if name == "CHudWeaponSelection" then return false end -- Says that we don't want the DEFAULT weapon selection.
if name == "CHudSquadStatus" then return false end -- Says that we don't want the squad display, for rebels.
if name == "CHudZoom" then return false end -- Says that we don't want things darker when we zoom.
if name == "CHudHistoryResource" then return false end -- Says that we don't want to know what we have picked up, ammo-wise.
end -- Closes the first "if" statement. The other ones close themselves.
return true -- Should we make "the drawing" of these things do what we say? true. Otherwise, false.
-- Format is: if name(default HUD function set) ==(is exactly) "Individual Function Name, case sensitive) then(Do this:) return(Give an answer) bool(false=no, true=yes) end(finishes it)
end -- We are done with this function, so stop it here.
hook.Add("HUDShouldDraw","HideHUD",HideHUD) -- Should we draw? Everything that the function doesn't say no to. Act, Name, Function.
local hidden = false -- Create the variable why don't we?
function hud.hideme() -- function used to hide this HUD.
if hidden == false then -- If we're not hidden, then
hidden = true --*cry* ... Hide us!
elseif hidden == true then -- If we're already hidden, then (elseif means that we add an if statement to this code block. We don't need to end the if we started with.)
hidden = false --oh now you want me back. Show us!
end -- Done. We now know what to do.
end -- Done, we have nothing else to do =P
concommand.Add("z420hud_toggle","Hide Combine Hud",hud.hideme) -- Create the console command that hides this HUD. Format: "CommandName", "Description", function to use.[/lua]
Of course, my comments make no sense since it doesn't work...
And also, how do I make a prop_combine_ball that doesn't just go through every world surface? (with the owner of the swep as the owner of the combine's ball)?
[editline]24th January 2013[/editline]
I only re posted because the last one was closed, the title was not descriptive. I tried to make this one's title descriptive. The Lua what do you want help with thread has moved on, several times, to other pages, without an answer to this.
[highlight](User was banned for this post ("Wrong section" - Gran PC))[/highlight]
Sorry, you need to Log In to post a reply to this thread.