• my constraint wont activate D:
    6 replies, posted
OK before i start let me say that I am still a noob at .lua what i was trying to do is make an entity that will change the wheel on a car if you collide the entity with the car.I wanted to make this for my future rp server. I am using the scar addon to make this happen addon :[url]http://www.garrysmod.org/downloads/?a=view&id=107249[/url] I did made the entity but for some reason the constraints wont activate [URL=http://imageshack.us/photo/my-images/716/help1lm.jpg/][IMG]http://img716.imageshack.us/img716/7126/help1lm.jpg[/IMG][/URL] [URL=http://imageshack.us/photo/my-images/850/helpmeplease.jpg/][IMG]http://img850.imageshack.us/img850/4484/helpmeplease.jpg[/IMG][/URL] I get this message on my server console "Garry: Tried to activate constraint in physics callback! This could cause crashes! Ignoring!" this never happen to me before i also tried wrapping the weld-code with timer.Simple(0, function() -- Code here. end); but when i did that it wouldn't allowed me to spawn a car with wheels also when i sit in the car the wheels will spin if i attempt to drive the vehicle. so im guessing the entity is fine. anyways hers the code: ================================================================= AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self.Entity:SetModel( "models/props_junk/gascan001a.mdl" ) self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetUseType(SIMPLE_USE) local phys = self.Entity:GetPhysicsObject() if(phys:IsValid()) then phys:Wake() end end function ENT:PhysicsCollide( data, phys ) ent = data.HitEntity local dont = 0 if string.find( ent:GetClass( ), "sent_sakarias_carwheel" ) or string.find( ent:GetClass( ), "sent_Sakarias_carwheel_punked" ) or ent.IsDestroyed == 1 then dont = 1 end if string.find( ent:GetClass( ), "sent_sakarias_car" ) && dont == 0 then ent.Entity:ChangeWheel( "models/Splayn/cadillac_wh.mdl", "rubber" ) ent.Entity.WheelModel = "models/Splayn/cadillac_wh.mdl" ent.Entity.physMat = "rubber" self.Entity:EmitSound("carStools/wheel.wav",80,math.random(100,150)) self.Entity:Remove() end end ============================================================================= if anyone can help me fix this i will be more the happy to spam the rate button for you as helper
That looks like it's the code for something completely unrelated. Also, what's wrong with "ent:GetClass() == "sent_sakarias_car"?
? im confused i didn't see anything wrong with it the entity works it just wont weld to the car. i think thers another entity that does the weld job but it's in the addon and im not allowed to post it or els ill get banned
Ok then, if that [i]is[/i] the code for the wheels (which I doubt) then: 1) Why does it have a gas-can model? 2) Why does it refuel the car? 3) Why is there no wheel-related code there?
1) the gas can model is something completely different from my problem that pic was there to show that the wheel i put together was working 2)the wheel does not refuel the car 3)like i sad from the last reply i think theirs another entity that does the weld job and there is but i cant post it because its not mine if you want to see the code download the scars addon is under lua>entity>sent_Sakarias_CarWheel
You said this is the wheel's code: [lua] AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self.Entity:SetModel( "models/props_junk/gascan001a.mdl" ) self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetUseType(SIMPLE_USE) local phys = self.Entity:GetPhysicsObject() if(phys:IsValid()) then phys:Wake() end end function ENT:PhysicsCollide( data, phys ) ent = data.HitEntity local dont = 0 if string.find( ent:GetClass( ), "sent_sakarias_carwheel" ) or string.find( ent:GetClass( ), "sent_Sakarias_carwheel_punked" ) or ent.IsDestroyed == 1 then dont = 1 end if string.find( ent:GetClass( ), "sent_sakarias_car" ) && dont == 0 then ent.Entity:ChangeWheel( "models/Splayn/cadillac_wh.mdl", "rubber" ) ent.Entity.WheelModel = "models/Splayn/cadillac_wh.mdl" ent.Entity.physMat = "rubber" self.Entity:EmitSound("carStools/wheel.wav",80,math.random(100,150)) self.Entity:Remove() end end [/lua] It's not the wheel's code. It's the code for a gas can that refuels cars........ And I don't know anything about the scars addon, sorry.
well i thank you very much for trying immibis. does anyone els have any ideas as to why my constraints wont activate
Sorry, you need to Log In to post a reply to this thread.