• Does anyone have an Idea for anti pirate protection? (New Flood Mod)
    10 replies, posted
I am trying to figure out a way so when someone goes on a boat thats not theirs it throws them off. How could I do such a thing? I'm guessing using "ENT:PhysicsCollide" on a player but I can't figure out how to implement that. Please help
I have to admit I was thinking of a different kind of piracy entirely.
ENT Physicscollide only works on scripted entities you have created (Or so that is what I know). You could try using the ShouldCollide hook which is used to tell the game whether two entities should collide at a time at which they are going to collide. Not sure how well that would work but it's a start [url]http://wiki.garrysmod.com/page/Hooks/Base/ShouldCollide[/url]
I tryed adding the following to shared.lua and init.lua [CODE] local function PropProtection(Ent1, Ent2) self.BaseClass:ShouldCollide(Ent1, Ent2) --cactus player vs cactus ent = false --grabber vs world or player = false --player vs player = false print( "ent1"..ent1:GetName().."ent2"..ent2:GetName() ) if Ent1:IsPlayer() then if ent1:IsPlayer() and ent2:IsPlayer() or ent1:IsPlayer() and ent2:IsBot() then return false elseif ent1:IsBot() and ent2:IsBot() then return false end end return true end hook.Add( "ShouldCollide", "PropProtection", PropProtection ) [/CODE] When I run it and try to collide with a bot I still collide and it doesn't print the ents names in the console.
I can tell this new flood mod is going to be awesome.
[QUOTE=Lebofly;38835090]I can tell this new flood mod is going to be awesome.[/QUOTE] You are correct I'm gonna add NPC Boats that you must battle against and a whole bunch of other awesome features. But gotta get the basics first.
The fun in flood mod was climbing other peoples boats and destroying everything for them
[QUOTE=kp3;38835714]The fun in flood mod was climbing other peoples boats and destroying everything for them[/QUOTE] Probably not as fun for the boatowner when 3 12 year old screaming kids jump on your boat and shout "I NEED A BOAT PLZ"
[QUOTE=Donkie;38838350]Probably not as fun for the boatowner when 3 12 year old screaming kids jump on your boat and shout "I NEED A BOAT PLZ"[/QUOTE] When i played they kept singing i'm on a boat song, and kept sinking my boat
You need to call ent:EnableCustomCollisions( true ) for ShouldCollide to work
[QUOTE=Ownage96;38827361]ENT Physicscollide only works on scripted entities you have created (Or so that is what I know). You could try using the ShouldCollide hook which is used to tell the game whether two entities should collide at a time at which they are going to collide. Not sure how well that would work but it's a start [url]http://wiki.garrysmod.com/page/Hooks/Base/ShouldCollide[/url][/QUOTE] So I got it to work [CODE] local function PropProtection( ent1, ent2 ) --cactus player vs cactus ent = false --grabber vs world or player = false --player vs player = false if TimerStatus == 3 then if ent1:IsValid() and !ent1:IsWorld() and ent2:IsValid() and !ent2:IsWorld() then if tostring(ent1:GetClass()) != "func_water_analog" and tostring(ent2:GetClass()) != "func_water_analog" then --- --- --- if tostring(ent1:GetClass()) == "prop_physics" and tostring(ent2:GetClass()) == "player" then if ent1:GetNetworkedEntity("Owner"):Nick() != ent2:GetName() then for k, v in pairs(player.GetAll()) do if v:Nick() == ent2:GetName() then v:SetVelocity(Vector(0,10,10) * 50) end end end end end end end return true end hook.Add( "ShouldCollide", "PropProtection", PropProtection ) [/CODE] I had to add [CODE]ent:SetCustomCollisionCheck( true )[/CODE] to every prop Only problem is it throws you when you shoot someones boat and when u get close to it. You dont actually have to touch it. [editline]15th December 2012[/editline] [QUOTE=CamDAX;38842671]So I got it to work [CODE] local function PropProtection( ent1, ent2 ) --cactus player vs cactus ent = false --grabber vs world or player = false --player vs player = false if TimerStatus == 3 then if ent1:IsValid() and !ent1:IsWorld() and ent2:IsValid() and !ent2:IsWorld() then if tostring(ent1:GetClass()) != "func_water_analog" and tostring(ent2:GetClass()) != "func_water_analog" then --- --- --- if tostring(ent1:GetClass()) == "prop_physics" and tostring(ent2:GetClass()) == "player" then if ent1:GetNetworkedEntity("Owner"):Nick() != ent2:GetName() then for k, v in pairs(player.GetAll()) do if v:Nick() == ent2:GetName() then v:SetVelocity(Vector(0,10,10) * 50) end end end end end end end return true end hook.Add( "ShouldCollide", "PropProtection", PropProtection ) [/CODE] I had to add [CODE]ent:SetCustomCollisionCheck( true )[/CODE] to every prop Only problem is it throws you when you shoot someones boat and when u get close to it. You dont actually have to touch it.[/QUOTE] I figured it out! [CODE] local function PropProtection( ent1, ent2 ) --cactus player vs cactus ent = false --grabber vs world or player = false --player vs player = false if TimerStatus == 3 then if ent1:IsValid() and !ent1:IsWorld() and ent2:IsValid() and !ent2:IsWorld() then if tostring(ent1:GetClass()) != "func_water_analog" and tostring(ent2:GetClass()) != "func_water_analog" then --- --- --- if tostring(ent1:GetClass()) == "prop_physics" and tostring(ent2:GetClass()) == "player" then local ent1_vector = ent1:GetPos() local ent2_vector = ent2:GetPos() --print( "distance between is: " .. ( ent1_vector:Distance(ent2_vector) ) .. " spaces") if ent1:GetNetworkedEntity("Owner"):Nick() != ent2:GetName() then if ent1_vector:Distance(ent2_vector) <= 50 then for k, v in pairs(player.GetAll()) do if v:Nick() == ent2:GetName() then v:SetVelocity(Vector(0,10,15) * 15) end end end end end end end end return true end hook.Add( "ShouldCollide", "PropProtection", PropProtection ) [/CODE] I just had to get the distance between objects! der!
Sorry, you need to Log In to post a reply to this thread.