Help me ! Random model for a TTT weapon.

The weapon will be a “fake traitor weapon” , when you press E to obtain it, it will explode.
But the problem is that I want to add all the TTT traitor weapons models in ONE script and I don’t know how to do, please help !

I think that I’ve got to add something at that line:

ENT.Model = Model(“models/weapons/w_c4.mdl”)

Please, help…

Post all the weapon code, then we can help you.

[lua]—Fake Weapon

if SERVER then AddCSLuaFile(“shared.lua”) end

if CLIENT then
– this entity can be DNA-sampled so we need some display info
ENT.Icon = “VGUI/ttt/icon_deagle”
ENT.PrintName = “Fake Weapon”
end

ENT.Type = “anim”
ENT.Model = Model(“models/weapons/w_c4.mdl”)
ENT.CanHavePrints = true

function ENT:Initialize()
self.Entity:SetModel(self.Model)
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
if SERVER then
local phys = self.Entity:GetPhysicsObject()
if IsValid(phys) then
phys:SetMass(20)
end
end
util.PrecacheSound(“siege/big_explosion.wav”)
end

ENT.CanUseKey = true

function ENT:UseOverride(activator)
local ent = ents.Create( “env_explosion” )
ent:SetPos( self.Entity:GetPos() )
ent:SetOwner( self.Entity )
ent:Spawn()
ent:SetKeyValue( “iMagnitude”, “50” )
ent:Fire( “Explode”, 0, 0 )
ent:EmitSound( “siege/big_explosion.wav”, 500, 500 )

	self.Entity:Remove()

	for k, v in pairs( player.GetAll( ) ) do
	  v:ConCommand( "play siege/big_explosion.wav

" )
end

end[/lua]

No one knows how to do that ?
The script just spawn a prop, and I want that the prop can be a C4, or a Silent Pistol, randomly…

Use [noparse][lua]code[/lua][/noparse]

I’m a stupid man.

It was a genuine suggestion, most people will say it and it helps to improve readability of code, but its your choice.

You don’t sound worth helping if that’s the way you’re going to reply to people who are trying to help you get helped.

[editline]25th January 2011[/editline]

And yes, it does make reading the code easier, as does proper tabbing.

Sorry, I’m a an idiot, and a noob. I thought he said “add it to your weapon script” >.>
Really sorrry.

[lua]—Fake Weapon

if SERVER then AddCSLuaFile(“shared.lua”) end

if CLIENT then
– this entity can be DNA-sampled so we need some display info
ENT.Icon = “VGUI/ttt/icon_deagle”
ENT.PrintName = “Fake Weapon”
end

ENT.Type = “anim”
ENT.Models = {
“models/weapons/w_c4.mdl”,
“models/weapons/w_knife.mdl”,
etc etc
}
ENT.CanHavePrints = true

function ENT:Initialize()
self.Entity:SetModel(table.Random(self.Models))
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
if SERVER then
local phys = self.Entity:GetPhysicsObject()
if IsValid(phys) then
phys:SetMass(20)
end
end
util.PrecacheSound(“siege/big_explosion.wav”)
end

ENT.CanUseKey = true

function ENT:UseOverride(activator)
local ent = ents.Create( “env_explosion” )
ent:SetPos( self.Entity:GetPos() )
ent:SetOwner( self.Entity )
ent:Spawn()
ent:SetKeyValue( “iMagnitude”, “50” )
ent:Fire( “Explode”, 0, 0 )
ent:EmitSound( “siege/big_explosion.wav”, 500, 500 )

	self.Entity:Remove()

	for k, v in pairs( player.GetAll( ) ) do
	  v:ConCommand( "play siege/big_explosion.wav

" )
end

end[/lua]