LUA Help

Hello everyone, i am in creation of a war based gamemode. I have just started off with a couple things. But something is wrong here.
1st Wrong Thing : HUD’s aren’t hiding
I have coded this code in my gamemode so the ammo and health HUD don’t show. But, for some odd reason, they still show.
Here is what it looks like :

If you can’t see it fully, click this :
Here is my code :

If you can’t see it fully, click this :
2nd Wrong Thing : Spawning With Extra Weapons
Well, i coded in my gamemode to where you only have a crowbar and a pistol, but for some reason, i spawn with these weapons :
Gravity Gun
9MM Pistol

But i coded this :

If you cant see it fully click this :

Also, how do you make an ammo HUD?
Thanks in advance, Brad

For the first thing, pairs takes a table, not a bunch of arguments.

[editline]29th January 2011[/editline]

Second thing, Player:setGravity isn’t a function, it’s SetGravity. And either way, it only takes one argument. SetMaxHealth only takes one argument as well. And you’re missing a right parenthesis on PrintMessage.

[editline]29th January 2011[/editline]

SetWalkSpeed instead of SetwalkSpeed. And in PlayerInitialSpawn, ply is undefined.

Oh, I am extremely new to LUA, i used tutorials, and still don’t get it that much.
Would you mind fixing the code for me?
Also, if you are willing to, teach me LUA for real?

HUGShould is no hook. Also dont make screenshots, just copy paste it into a reply and put it inbetween

Uh, I recommend you to watch these series of tutorials, hes very blunt and straight forward. If you cant learn from it then, I don’t know…

Just look for the first tutorial and watch through them all. If these are the tutorials you say you’ve watched, then watch them again…

That’s the one i used, it doesn’t teach me much.

Wiki tutorials then boi!

That, sir, is Coding Hell.

No bro.
Which part of the hud did you want to get hidden? The normal Sandbox hud? Then put this in cl_init.lua

function hidehud(name)
for k, v in pairs{“CHudHealth”, “CHudBattery”, “CHudAmmo”, “CHudSecondaryAmmo”} do
if name == v then return false end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

Couple things to fix in that.

local hideThese = {
CHudHealth = true,
CHudBattery = true,
CHudAmmo = true,
CHudSecondaryAmmo = true

local function hidehud( name )
if hideThese[name] then return false end
hook.Add( “HUDShouldDraw”, “hidehud”, hidehud )[/lua]

Notice the function being local and table outside the function. Creating it inside a function that’s called every frame is going to create lots of garbage and eventually cause lag spikes.

Thanks, alot!
Two more things.
1st : How do i make an Ammo HUD? (Like the Health one)

2nd : How do i change the name of a pistol I made when selecting it? (It is named Scripted Weapon)
Code :

AddCSLuaFile( “shared.lua” )

SWEP.Author = “”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Instructions = “”

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_357.mdl”
SWEP.AnimPrefix = “python”

SWEP.Spawnable = false
SWEP.AdminSpawnable = false

SWEP.Primary.ClipSize = 1 // Size of a clip
SWEP.Primary.DefaultClip = 1 // Default number of bullets in a clip
SWEP.Primary.Automatic = false // Automatic/Semi Auto
SWEP.Primary.Ammo = “Pistol”

SWEP.Secondary.ClipSize = 0 // Size of a clip
SWEP.Secondary.DefaultClip = 0 // Default number of bullets in a clip
SWEP.Secondary.Automatic = false // Automatic/Semi Auto
SWEP.Secondary.Ammo = “Pistol”

function SWEP:Initialize()


function SWEP:Reload()
self:DefaultReload( ACT_VM_RELOAD );

Think does nothing
function SWEP:Think()

function SWEP:PrimaryAttack()

// Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end

// Play shoot sound

// Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 999, 1, 0.01 )

// Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )

// Punch the player's view
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )


Add this at the top.
[lua]if( CLIENT ) then
SWEP.PrintName = “Knife”;
SWEP.Slot = 3;
SWEP.SlotPos = 3;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;