Does anyone have an Idea for anti pirate protection? (New Flood Mod)

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

I tryed adding the following to shared.lua and init.lua



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 )


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.

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

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”

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

So I got it to work



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 )


I had to add


ent:SetCustomCollisionCheck( true )

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]

I figured it out!



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 )


I just had to get the distance between objects! der!