I am trying to have table.random choose a random weapon but I also want to have a model for that weapon assigned to it.
dropguns ={
"m9k_fal",
"m9k_m4a1",
"m9k_ak47"
}
local Weapon = table.Random(dropguns)
I have that too choose the weapon class to create the weapon but I'm not sure how i can assign a model to each weapon class. I tried to use
dropguns ={
"m9k_fal models/weapons/w_fn_fal.mdl",
"m9k_m4a1 models/weapons/w_m4a1_iron.mdl",
"m9k_ak47 models/weapons/w_ak47_m9k.mdl"
}
local Weapon = table.Random(dropguns)
local WepModel = string.Replace( Weapon, "m9k_", "" )
local WepClass = string.Replace( Weapon, "models/weapons/", "" )
but it would only replace the first part and I'm not sure how to get rid of the entire part of the string that I don't want for each part of the code
Omg i never even thought of that thank you
local weapons = {
{
name = "m9k_fal",
model = "models/weapons/w_fn_fal.mdl"
},
{
name = "m9k_m4a1",
model = "models/weapons/w_m4a1_iron.mdl"
},
{
name = "m9k_ak47",
model = "models/weapons/w_ak47_m9k.mdl"
}
}
local random_weapon = table.Random(weapons)
-- to access the name
random_weapon.name
-- to access the model
random_weapon.model
Sorry, you need to Log In to post a reply to this thread.