Primary and Secondary weapons.

Problem solved

How would I go about giving a player a primary and secondary weapon, and only having one of each? I made a buy menu where you can select your primary and secondary weapon and it will set a “primary” and “secondary” Networked Int to correspond with the weapons in this table:

[lua]WeaponTable = {
[1] = {
[1] = {
name = “SMG”,
cost = 10,
entity = “cb_weapon_smg”
},
[2] = {
name = “Shotgun”,
cost = 20,
entity = “cb_weapon_shotgun”
}
},
[2] = {
[1] = {
name = “Pistol”,
cost = 5,
entity = “cb_weapon_pistol”
}
}
}[/lua]

Now I just don’t know how to make it so I can give and take the weapons from the player based on what they’ve selected. I want it to be similar to the CS:S weapon buying.

I hope I made sense.

EDIT:
screenshot of buy menu.
[img_thumb]https://dl.dropbox.com/u/3609329/buymenu.jpg[/img_thumb]

EDIT2:
meta.lua
buymenu.lua

[lua] player:Give(WeaponTable[theirchoiceinbuymenu].entity) [/lua]

Not exactly sure if this is what you need :expressionless:

I’m not sure how I would make it do that when I press “Confirm Loadout”, I guess just add it to the console command. Plus how would I remove any weapons from the same slot that they already have?

Can you please give us the code of the buymenu and the code of the buy command

meta.lua
buymenu.lua
I think that’s all the code related to this.

[lua]
for _,loadout in pairs(WeaponTable) do

for _,weapon in pairs(loadout) do

    if somePlayerVar:HasWeapon(weapon.entity) then

        somePlayerVar:GetWeapon(weapon.entity):Remove()
    end
end

end
[/lua]

Something like that before giving them the new loadout.

I got it working, thanks guys. :smile: