• GetPrimaryAmmoType (nil value) when player has no weapons
    2 replies, posted
My players are given a menu to select their loadout on initial spawn. But, my HUD doesn't seem to like it (at all) when the player has no weapon equipped. It says GetPrimaryAmmoType is a nil value of course because there is no weapons equipped. [lua]if IsValid( LocalPlayer() ) && LocalPlayer():Alive() then draw.SimpleTextOutlined( LocalPlayer():GetAmmoCount(ammo:GetPrimaryAmmoType()), "shadowshifter", ScrW() - 172, ScrH() - 127, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black ) draw.SimpleTextOutlined( ammo:Clip1(), "shadowshifter2", ScrW() - 286, ScrH() - 127, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black ) end [/lua] What could I add to this to detect if a player has a valid weapon out?
[url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url] and either check if the weapon IsValid or the ammotype is. :)
Thanks
Sorry, you need to Log In to post a reply to this thread.