Making a loadout?

I’m making a simple gamemode but i was wondering how i would do a loadout.

My idea was:

Have 3 variables;
pgun
sgun
special
For the gui, clicking the button would set each variable to the gun e.g

If i click the AK47 Button then pgun = “ak47”

when they choose both guns and their special it would run a function that would execute Give(wepname)

I would have an if statement for the guns.

if pgun == “ak47” then gun1 = “fas2_ak47”

I don’t know if this even makes sense to you, and im sure there is a more efficient way to do this.

Any suggestions?

hook.Add into PlayerLoadout

Player is the first argument, check :Team( ), or whatever; then :Give( “fas2_ak47” ) or whatever for each loadout.

I’d recommend doing a direct access sort of thing. Here’s some code I wrote for a gun-game / gun-race style game-mode as a tutorial: https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/gun_race/upgrade_weapons_for_kills.lua.html

And a TTT style of system for giving out weapons based on groups and other info - two examples done on the begin-round segment, it’d go into PlayerLoadout for yours unless it is TTT: https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/give_weapons_based_on_group.lua.html

Now, for VGUI where you have a menu open and you select a load-out, it is simply a DButton or DImageButton where you override the .DoClick function, and send a net-message to the server telling the server which loadout you want. The server in a net.Receive would then dispense the same way the other scripts are used.

Here’s an MOTD to show how the DoClick stuff is done: https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/motd.lua.html

And a networking tutorial: https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua.html

For yours you may want to set up ENUMERATIONS, basically SHARED CONSTant values like LOADOUT_1 = 1, LOADOUT_2 = 2, LOADOUT_3 = 99, etc… and just WriteInt or to make it easier without counting bytes, WriteLong or Float or Double - forget which ones exist… On the other end, local _value = net.ReadXXX() and if _value == LOADOUT_1 then… elseif == LOADOUT_2 then … elseif == _3 then … else end…

Everytime you comment on my posts i just feel dumber and dumber :wink:

I will try and get something working over the next day or two. In the mean time i guess im learning the net library xD

Thanks for the help.

This is a good tutorial

+1

I’m going to start referencing wiki entries in all of the files I put out; any available tutorials on the subjects covered, in addition to links to all of the functions used.

What server are you making this for?

[editline]9th May 2014[/editline]

Because my server has the exact same kind of variables and concept of a loadout with a dmodel menu.

Can you please stop mentioning your server on everything your post. Its worse than Acecool.

We don’t give a shit if you own a server with a Battlefield gamemode which is just guns + models with a little HUD and stuff.

PS if you make a gamemode (which you didn’t a friend made it for you) you should call it Call of Duty as the gamemode you’re running is a run and gun not teamwork based like Battlefield.

Im not going to release some half assed shit BF4 TDM.

I will have a fully functional game type system etc in place for when it is done.

Most of the other servers are using darkrp.

Also Pie:

Im sure everyone has a similar concept.

Going for a menu style life this.

Pie has a server with a half assed BF4 TDM.

If you make a ingame BF4 menu it would be awesome. A little unorginial but awesome

Im not replicating, but i am taking a large amount of gameplay mechanics from it :stuck_out_tongue_winking_eye:

Considering my mode is in Early stages, have fun making your loadout look like that!

Also the gamemode which pie has is in ealry alpha. So its not released.
And if you ask how making a loadout, i dont think that you are able to do that.

There server is not using DarkRP either. I assume since you are asking for help, you cannot code the load-out you showed.
You should try and create your own ideas, not just try and make a new version of an existing gamemode.

What are youse on about? He could code that menu if he wanted, if he knows how to code and is a good designer, he could create something very identical to that, GMod is amazing in the way that you can code pretty much anything (if you don’t run into one of the Source Engines’ “features”).
Don’t want to be mean to the OP, but I don’t think he could do it, does not mean it isn’t possible.

Garry’s Mod does not use the term Sandbox lightly

http://puu.sh/8GXya2.jpg

Just the aesthetics so far.

Got the net messaging working and all that, will just need to do tables and what not.

Image not working?

Sorry, here it is

http://puu.sh/8H9er.jpg

Any improvements?

Does it work?

Change background and fix that save button, it looks out of place.

oh yours is based off DarkRP soo.

Anyway I was talking to AIX about the menu not you.

Also really sad you called your friends to rate me dumb and post things about your DarkRP edit