• game.GetWorld() not working
    11 replies, posted
Im makeing something so if someone welds or puts a slider on a ragdoll to the world it deletes the constraint but for some reason game.GetWorld() is not working. [CODE]function RagdollFix() local entnum = ents.GetAll() local players = player.GetAll() for _, ent in pairs(entnum) do if ent:GetClass() == "prop_ragdoll" then if constraint.FindConstraint( ent , "Weld" ) or constraint.FindConstraint( ent , "Slider" ) then for ali, All in pairs( constraint.GetAllConstrainedEntities( ent ) ) do if All == game.GetWorld() then for pl, ply in pairs(players) do local spawn = ply:Nick() local id = tostring(ply:SteamID()) local color = ply:Team() umsg.Start( "player_ragchat") umsg.String(spawn) umsg.String(id) umsg.Short(color) umsg.End() end constraint.RemoveConstraints( ent , "Weld" ) constraint.RemoveConstraints( ent , "Slider" ) end end end end end end hook.Add( "Think", "RagdollFix", RagdollFix) [/CODE]
If you would've printed the variable All, you'd have known that it is never equals to world. game.GetWorld() works perfectly.
[QUOTE=Robotboy655;44789143]If you would've printed the variable All, you'd have known that it is never equals to world. game.GetWorld() works perfectly.[/QUOTE] Then how would i make this work.
Edit the tool on your server?
[QUOTE=Robotboy655;44789143]If you would've printed the variable All, you'd have known that it is never equals to world. game.GetWorld() works perfectly.[/QUOTE] Actually it doesn't work clientside.
What do you mean edit the slider and weld tool because this is a script?
[QUOTE=bigdogmat;44789251]What do you mean edit the slider and weld tool because this is a script?[/QUOTE] Yes. They are located in gamemodes/sandbox/weapons/gmod_tool/stools/ Or you could try using CanTool hook, but it would be tricky. [editline]12th May 2014[/editline] [QUOTE=OzymandiasJ;44789250]Actually it doesn't work clientside.[/QUOTE] I beg to differ. [img]http://i.imgur.com/TEpdzDq.png[/img] And besides, this is a serverside script.
[QUOTE=Robotboy655;44789262]Yes. They are located in gamemodes/sandbox/weapons/gmod_tool/stools/ Or you could try using CanTool hook, but it would be tricky. [editline]12th May 2014[/editline] I beg to differ. [img]http://i.imgur.com/TEpdzDq.png[/img] And besides, this is a serverside script.[/QUOTE] Is there a way to do this with out editing the tools and fix the script
[code] function RagdollFix( ply, tr, tool ) if ( (tool != "weld" && tool != "slider") || !ply.GetWeapon || !IsValid( ply:GetWeapon( "gmod_tool" ) ) ) then return end local e1 = ply:GetWeapon( "gmod_tool" ):GetToolObject():GetEnt( 1 ) local e2 = tr.Entity if ( IsValid( e1 ) && e1:GetClass() == "prop_ragdoll" && e2 == game.GetWorld() ) then if ( SERVER ) then ply:ChatPrint( "No crashing, kthx" ) end // Give him a warning return false // Prevent the user from firing toolgun end if ( IsValid( e2 ) && e2:GetClass() == "prop_ragdoll" && e1 == game.GetWorld() ) then if ( SERVER ) then ply:ChatPrint( "No crashing, kthx" ) end return false end end hook.Add( "CanTool", "RagdollFix", RagdollFix)[/code] I didn't feel like lazy, so here you go.
[QUOTE=Robotboy655;44789319][code] function RagdollFix( ply, tr, tool ) if ( (tool != "weld" && tool != "slider") || !ply.GetWeapon || !IsValid( ply:GetWeapon( "gmod_tool" ) ) ) then return end local e1 = ply:GetWeapon( "gmod_tool" ):GetToolObject():GetEnt( 1 ) local e2 = tr.Entity if ( IsValid( e1 ) && e1:GetClass() == "prop_ragdoll" && e2 == game.GetWorld() ) then if ( SERVER ) then ply:ChatPrint( "No crashing, kthx" ) end // Give him a warning return false // Prevent the user from firing toolgun end if ( IsValid( e2 ) && e2:GetClass() == "prop_ragdoll" && e1 == game.GetWorld() ) then if ( SERVER ) then ply:ChatPrint( "No crashing, kthx" ) end return false end end hook.Add( "CanTool", "RagdollFix", RagdollFix)[/code] I didn't feel like lazy, so here you go.[/QUOTE] Thanks a lot :)
[QUOTE=Robotboy655;44789262]Yes. They are located in gamemodes/sandbox/weapons/gmod_tool/stools/ Or you could try using CanTool hook, but it would be tricky. [editline]12th May 2014[/editline] I beg to differ. [img]http://i.imgur.com/TEpdzDq.png[/img] And besides, this is a serverside script.[/QUOTE] [url]https://github.com/Facepunch/garrysmod-issues/issues/973[/url] doops
The right click function on the slider still works [editline]12th May 2014[/editline] This there any way to make it so you can't right click aswell
Sorry, you need to Log In to post a reply to this thread.