Jump to content

Disallow Vehicles on Greenzone


xJ4ckk

Recommended Posts

I guess that script uses a colshape to limit the greenzone (i'm lazy to check)

If a vehicle enters (or gets created) inside that colshape then you can do whatever you want with that vehicle. Edit the script knowing this.

If you need further help (for example the script is compiled, uses other ways to greenzone an area, or you are not able to script) ask here :)

Link to comment
10 hours ago, LoPollo said:

I guess that script uses a colshape to limit the greenzone (i'm lazy to check)

If a vehicle enters (or gets created) inside that colshape then you can do whatever you want with that vehicle. Edit the script knowing this.

If you need further help (for example the script is compiled, uses other ways to greenzone an area, or you are not able to script) ask here :)

You could use this as well

getElementsWithinColShape

 

Link to comment

I have removed the MoneyZone line and wanted to replace it with something else, if I had not removed the MoneyZone I would have to insert the cooardinates where the players can not spawn any vehicles.
So I need your help to make it without coordinates
I want to do it when I enter the Greenzone I can not create a vehicle.

I mean without that: setElementPosition (hitElement, 2018.33, 1534.77, 12.37)

Link to comment
4 hours ago, ViRuZGamiing said:

You could use this as well


getElementsWithinColShape

 

Lol reading my reply i noticed i did not mentioned the event itself, sorry. But OnColshapeHit is better than getElementsWithinColShape since with the event you get when a vehicle enters or gets created inside it.

 

 

2 hours ago, xJ4ckk said:

I have removed the MoneyZone line and wanted to replace it with something else, if I had not removed the MoneyZone I would have to insert the cooardinates where the players can not spawn any vehicles.
So I need your help to make it without coordinates
I want to do it when I enter the Greenzone I can not create a vehicle.

I mean without that: setElementPosition (hitElement, 2018.33, 1534.77, 12.37)

What do you mean with "without setElementPosition"? I can't get what do you want with the last reply. 

Yes you deleted the MoneyZone colshape (line 57 right?)

but the colshapes are created using the "radararea" elements' positions and sizes.

I also don't get what you want to do when a vehicle enters these colshapes.

" I would have to insert the cooardinates where the players can not spawn any vehicles." what do you mean? arent's these the radarareas?

Link to comment
  • MTA Anti-Cheat Team

I made anti-vehicle zones script, it does exactly what you want and you can just replace its coordinates with your greenzones' locations.

Here: https://community.multitheftauto.com/index.php?p=resources&s=details&id=12240

You can also study its code so you learn how this can be achieved.

 

Basicly this is all: 

-- storage for the zones
-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0},
local vZones = {
	{x = 77.89, y = 1011.84, z = 12, width = 63.97, depth = 101.42, height = 32.88}, -- random example location located in Bone County
}

-- initialize all zones on resource start
local z = {}
function initvZones()
	if vZones and #vZones ~= 0 then
		for _,v in ipairs (vZones) do
			if v then
				if v.x and v.y and v.z and v.width and v.depth and v.height then
					local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height)
					if c then
						z[c] = true
						for _,v in ipairs (getElementsByType("vehicle")) do
							if isElementWithinColShape (v, c) then
								destroyElement(v)
							end
						end
						addEventHandler ("onElementDestroy", c,
							function()
								if z[source] then
									z[source] = nil
								end
							end
						)
						addEventHandler ("onColShapeHit", c,
							function (h, d)
								if h and d and isElement(h) and getElementType (h) == "vehicle" then
									destroyElement (h)
								end
							end
						)
					end
				end
			end
		end
	end
end
addEventHandler ("onResourceStart", resourceRoot, initvZones)

 

Edited by Dutchman101
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...