Special Gui

Ok, I want to know how I can make a gui that when someone becomes S.W.A.T they can pick 1 primary weapon and 1 secondary. If anyone can give me tips on how I could make it then that would be great.

The following are some of the primary weapons of FBI SWAT:
The MP5/10 Submachine gun
The M4 carbine
The M1911A1 Springfield Professional Custom Pistol (.45 ACP)
The Glock 22 and Glock 23 Pistol (.40 S&W)
The Remington 870 Shotgun
A Semi-Automatic or bolt action precision rifle (.308 cal)

Weps I want for the swat gui.

Create a DFrame (all this is clientside) with a couple buttons each saying a different gun, when the buttons are clicked (Button:DoClick() = function()) you should give the player that weapon (serverside, ply:GiveWeapon()) and close the Frame (Frame:Close()). Thats the basic rundown I think but I’m tired so who knows.

For the ply:GiveWeapon()) Do I need to put the weps I want them to choose in the ())?

GiveWeapon isn’t a valid method unless custom coded… use Player:Give() instead. Check out the documentation here and you can only pass one weapon in the function at a time.

How about the class? Do I need to enter the job name so it only pops up for when someone joins that job?

You’ll need some networking. I’d recommend setting up a shared table with primary weapons and secondary weapons. When the choice is made, send the data to the server for the server to verify. If the server can verify then it gives the weapons.

Networking example, using an entity / npc as the gateway to the vgui might be a good idea: https://dl.dropboxusercontent.com/u/26074909/tutoring/_zipped_code/acecool_npc_jointeam_example.rar


You can easily block the vgui from opening if the player isn’t on the team, but you would definitely need to do that check serverside when the weapon has been selected…

Ok, so for example. When S.W.A.T Enters pd and press the use key they will get choose the items I want to them to have?

Forgive me if im wrong as i’m still fairly new to GLua but to check the players team i’m pretty sure its as simple as this:

[lua]if ply:Team() == TEAM_SWAT then
// use usermessges or whatever here to call your derma


As i said, Im not 100% sure if the code will work as i’m still pretty new to GLua but its worth a shot eh?

Depending how you want to do it… If you want them to press E on an npc in order to select the weapons, then the player receives them when they select them you’ll need to do a few things…

The NPC On use, send a message to the client ( empty; just a flag message to open the vgui ).

net receiver; empty. Just use it to create the vgui if not already created.
The weapons selection should be done using any method you want to… drop downs, or another vgui popup to select based on a table ( the shared table )
the button for “request these weapons” should send a net message to the server containing basic info…
We need to write the ID for the shared table to access the primary weapon and secondary weapon. 2 different Writes…

Net Receiver which reads 2 values, the primary key and the secondary key. It first checks to make sure the client is on the right team, then checks the shared table to see if the keys are value and then gives the weapons.

You basically just bounce messages back and forth after getting some input.

Well couldn’t the swat guy like drop the weps over and over again if it is by npc and give peeps free weps? I also want it so they can pick only 1 wep from primary and 1 from seccondary so once they did that they can’t access it till they die. Also I don’t want them to be able to drop the weps the got from the npc.

Since it is all serverside ( the verification before giving ), add a clause that if they have received weapons they can’t get any more. Also, add a hook: PlayerDeath. Have that reset the variable you set when they get the weapons. That completes the once per life system.

You can also add values to the weapons themselves, you can also prevent the weapons from being dropped, etc… There are tons of options that can be associated / done.