• Entity:SetModel bug
    9 replies, posted
[CODE]function SWEP:ShootProp(model_name) self:EmitSound( ShootSound ) if ( CLIENT ) then return end local ent = ents.Create( "prop_physics" ) if ( !IsValid( ent ) ) then return end ent:SetModel( model_name ) ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 16 ) ) ent:SetAngles( self.Owner:EyeAngles() ) ent:Spawn() local phys = ent:GetPhysicsObject() if ( !IsValid( phys ) ) then ent:Remove() return end local velocity = self.Owner:GetAimVector() velocity = velocity * 100000 phys:ApplyForceCenter( velocity ) cleanup.Add( self.Owner, "props", ent ) undo.Create( "Shot prop" ) undo.AddEntity( ent ) undo.SetPlayer( self.Owner ) undo.Finish() end[/CODE] Then I change model_name the prop spawns with the default model_name I have set "models/props_junk/watermelon01.mdl"
It's not a bug with Entity:SetModel, but a bug with your coding.
Well you could atleast try to explain me that's wrong or how to fix it
[QUOTE=MFanatik;44028147]Well you could atleast try to explain me that's wrong or how to fix it[/QUOTE] Post more code. Especially the part which actually calls ShootProp, and how you are "changing" model_name.
this one calls [CODE]function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 ) self:ThrowChair( prop ) if ( SERVER ) then return end chat.AddText("You shot ",prop) --I check if I really changed the directory end[/CODE] this one changes [CODE]local PropEntry = vgui.Create( "DTextEntry", Menu2 ) PropEntry:SetPos( 10, 47 ) PropEntry:SetSize( 300, 20 ) PropEntry:SetText( prop ) PropEntry.OnEnter = function( self ) prop=self:GetValue() end[/CODE]
You must send the model name from that panel to your SWEP via net message. What you tried to do is to set a variable on client and then you expect it to magically change on the server as well.
So how do I set a variable on the server please explain it to me I'm a total noob
[url]http://facepunch.com/showthread.php?t=1367953[/url]
[QUOTE=Internet1001;44030072][url]http://facepunch.com/showthread.php?t=1367953[/url][/QUOTE] I fixed it myself but now I have another problem how do I execute something serverside in a menu
[QUOTE=MFanatik;44030344]I fixed it myself but now I have another problem how do I execute something serverside in a menu[/QUOTE] The same exact way you send a variable.
Sorry, you need to Log In to post a reply to this thread.