I created a fire extinguisher swep using the swep construction kit. The only issue left is that the swep returns to the original model when dropped.. I've tried a few different things but none of it seems to be working. Any ideas?
[CODE]if (SERVER) then
util.AddNetworkString("rprint_setCSModel")
function SWEP:OnDrop()
self:SetModel("models/props/cs_office/fire_extinguisher.mdl")
net.Start("rprint_setCSModel")
net.WriteEntity(self)
net.Send(player.GetAll())
end
else
net.Receive("rprint_setCSModel", function()
local ent = net.ReadEntity()
ent:SetModel("models/props/cs_office/fire_extinguisher.mdl")
end)
end[/CODE]
The SWEP will automatically keep setting the model to the SWEP.WorldModel parameter when dropped. You can change this in the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawWorldModel]SWEP:DrawWorldModel[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawWorldModelTranslucent]SWEP:DrawWorldModelTranslucent[/url] hooks.
[QUOTE=code_gs;52623973]The SWEP will automatically keep setting the model to the SWEP.WorldModel parameter when dropped. You can change this in the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawWorldModel]SWEP:DrawWorldModel[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawWorldModelTranslucent]SWEP:DrawWorldModelTranslucent[/url] hooks.[/QUOTE]
And setting it servaide should be good enough right? Or should I set it client and server side
You can't set it serverside -- those are clientside hooks. But your earlier code's networking was useless, anyway, since SetModel is networked internally.
[editline]28th August 2017[/editline]
The downside is that the physbox will still be of the old worldmodel. You might experiment setting it in a Think hook, as well, to see if that updates the physics.
[CODE]if (CLIENT) then
function SWEP:DrawWorldModel()
self.WorldModel = "models/props/cs_office/fire_extinguisher.mdl"
end
function SWEP:DrawWorldModelTranslucent()
self.WorldModel = "models/props/cs_office/fire_extinguisher.mdl"
end
end[/CODE]
With this, it is still the original model..
You run SetModel. You should never have to change SWEP.WorldModel.
I meant to add that here as well, it didn't work either...
[CODE]if (CLIENT) then
function SWEP:DrawWorldModel()
self:SetModel("models/props/cs_office/fire_extinguisher.mdl")
end
function SWEP:DrawWorldModelTranslucent()
self:SetModel("models/props/cs_office/fire_extinguisher.mdl")
end
end[/CODE]
You still have to call self:DrawModel() after like normal.
[QUOTE=code_gs;52627599]You still have to call self:DrawModel() after like normal.[/QUOTE]
[CODE]if (CLIENT) then
function SWEP:DrawWorldModel()
self:SetModel("models/props/cs_office/fire_extinguisher.mdl")
self:DrawModel()
end
function SWEP:DrawWorldModelTranslucent()
self:SetModel("models/props/cs_office/fire_extinguisher.mdl")
self:DrawModel()
end
end[/CODE]
[url]https://gyazo.com/64117ed697ec3c32314d208024591877[/url]
Still no luck :(
I've figured out a work around, I created an extinguisher ent with the model I want, in swep:OnDrop(). I call a function that spawns this entity and I have a OnEntCreated hook that checks if the last entity created was my extinguisher ent, if it was then I remove the current ent which is the entity created by swep:OnDrop (the old model). In the extinguisher ent on use I just give the player the extinguisher swep.
[URL="https://gyazo.com/ebdb6114cd26d4df5e23c734dd2f3168"]Everything is working perfectly! :)[/URL]
Anybody have any ideas of a better way to do this? Is this the best way?
I just tested with this code in single-player, then spawning the weapon with the toolgun:
[code]SWEP.Spawnable = true
function SWEP:DrawWorldModel()
self:SetModel("models/weapons/w_smg1.mdl")
self:DrawModel()
end[/code]
Result:
[t]https://i.imgur.com/66gC1xR.jpg[/t]
Like I said, physbox is off since the model is still the prior one serverside, but it shows fine clientside.
Sorry, you need to Log In to post a reply to this thread.