Spawning with a different crowbar model every match, TTT

Hi. I have like 5-7 different models to use for a crowbar, but I cant figure out how to have everyone spawn with a different one very time. Please help. Thanks - Tobias

http://forum.facepunch.com/showthread.php?t=1269027

Don’t mean to be rude and it’s definitely not just you but I’m kind of tired of all the threads with people asking for us to think for them. You should either be learning by thinking on your own and making good use of the wikis, other people’s code and google or bite the bullet and just hire someone from the recruitment thread.

If you have a specific question I’d be glad to help, but the endless vague “help me do everything” threads are wearing down my patience.

To give you a start on your problem:

http://gmodwiki.net/Lua/Hooks/Base/PlayerSpawn
http://gmodwiki.net/Lua/Classes/Player/Give
http://gmodwiki.net/Lua/Libraries/table/Random

In SWEP:Initialize(), do something like…

local PATHS = {“models/weapons/ttt/super/”, “models/weapons/ttt/asdfk/”}
local MODELS = {“supermodel.mdl”, “snip_asdfk.mdl”}
local i = math.Random(#PATH)
local PATH, MODEL = PATH*, MODEL*
self.WorldModel = PATH…“w_”…MODEL
self.ViewModel = PATH…“v_”…MODEL

Where the models and paths match up with actual weapon models.
I hope that ACTUALLY (mitsudigi >.>) helps!

Thanks Bobblehead!

Any other ways to do this besides Bobblehead’s way?

Bobblehead’s method will not work as i used to try it.

Im not sure of another method of the top of my head, best option is to look around the old wiki for a method.

Derp. I forgot you have to actually set the model.
[LUA]
function SWEP:Deploy()
self:SetModel(self.WorldModel)
if CLIENT then
self.Owner:GetViewModel():SetModel(self.ViewModel)
end
end
[/LUA]


In SWEP:Initialize(), do something like...

 local PATHS = {"models/weapons/ttt/super/", "models/weapons/ttt/asdfk/"}
 local MODELS = {"supermodel.mdl", "snip_asdfk.mdl"}
 local i = math.Random(#PATH)
 local PATH, MODEL = PATH*, MODEL*
 self.WorldModel = PATH.."w_"..MODEL
 self.ViewModel = PATH.."v_"..MODEL

 Where the models and paths match up with actual weapon models.
 I hope that ACTUALLY (mitsudigi >.>) helps!

There is no swep initializing