Hi, I'm making a build to kill gamemode and there's a few things I can't figure out.
First, I don't know how to change part of the HUD when a variable changes. I have this:
[CODE]function hud()
local health = LocalPlayer():Health()
draw.RoundedBox(0, 505, ScrH() - 15 - 35, 200, 40, Color(0,255,0,255))
draw.RoundedBox(0, 535, ScrH() - 15 - 5, 170, 8, Color(255,0,0,255))
draw.SimpleText(LocalPlayer().btghudText, "default", 535, ScrH() - 15 - 30, Color(255,255,255,255))
end
hook.Add("HUDPaint", "MyHudName", hud)
[/CODE]
and var btghudText is changed in init.lua on respawns and when they take out a certain weapon.
However, all that's coming up is nil as the text. How do I change it when the variable changes, to the string on the variable? Also, how would I do this with the colors?
My next problem is, I want people to have god mode when they spawn, but have it taken away when they take out said weapon. They get god when they spawn, but when they tak eout the weapon they still have it. Here's my script for when they take out the weapon:
[CODE]hook.Add("PlayerSwitchWeapon", "Grabbin.Peelz", function(ply, oldWeapon, newWeapon)
local btknewWep = newWeapon:GetClass()
ply:PrintMessage(3, "Picked Uap: "..newWeapon:GetClass())
if btknewWep == "fas2_ak47" then
ply.btkProtected = false
ply.btkBgcolor = 505
ply.btkhudText = "Building protection: OFF"
ply:GodDisable()
if ply:Team() == 1 then
ply:SetColor( Color( 250, 255, 0, 185 ) );
elseif ply:Team() == 2 then
ply:SetColor( Color(0, 0, 255, 185 ) );
else
ply:SetColor( Color(255, 0, 0, 185 ) );
end
end
end)[/CODE]
Am I doing something wrong?
Thanks!
Sorry, you need to Log In to post a reply to this thread.