• ENT:Initialize() function won't select random model from table
    3 replies, posted
function ENT:Initialize() self:SetModel("") self:SetHealth( math.random ( 500, 400 ) ) self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_NONE) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) local phys = self:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() end NodeType = {"WoodPile", "SulfurOre", "MetalOre", "StoneOverdrive"} NodeTypeSpawn = table.Random(NodeType) if NodeTypeSpawn == nil then print("Invalid") self:Remove() end if NodeTypeSpawn == WoodPile then self:SetModel("models/props_c17/chair02a.mdl") print("woodpile") end if NodeTypeSpawn == MetalOre then self:SetModel("models/props_building_details/Storefront_Template001a_Bars.mdl") print("metal ore") end if NodeTypeSpawn == SulfurOre then self:SetModel("models/props_c17/canister_propane01a.mdl") print("sulfur ore") end if NodeTypeSpawn == StoneOverdrive then self:SetModel("models/props_c17/bench01a.mdl") print("stone") end end Don't know why but this doesn't seem to work properly. It does spawn but it just spawns an error model and doesn't do the prints. Am I doing something wrong here or am I missing something?
I think this'll fix your problem: if NodeTypeSpawn == "WoodPile" then self:SetModel("models/props_c17/chair02a.mdl") print("woodpile") end Just add in quotation marks
"WoodPile" != WoodPile
Holy shit I'm retarded lmao. Thank you for this and I'm sorry for wasting your time!
Sorry, you need to Log In to post a reply to this thread.