Jump to content

[REL] Greenzones


Dutchman101

Recommended Posts

  • MTA Anti-Cheat Team

Announcing a nice greenzone script that's easy to operate/manage

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

Functionality:

- Everyone inside the greenzones is protected, can't be killed, can't be stealthkilled (knifed), but can still draw weapons and shoot, but not hurt anyone inside the greenzone.

- Protected players have a 'Greenzone protected' text tag above their head.

- It works good to protect spawns and prevent spawnkilling or DM in certain zones that you want to protect

- Draws a green zone on the F11 and minimap for default HUD's.

- By default all Freeroam (default play) spawn locations are listed and greenzone'd, demonstrating the format of coordinates and so it's easy to use for freeroam without editing. If you want your own protected areas, then remove the preset coordinates and put in your own.

X3LJhuq.jpg

  • Like 1
Link to comment
  • 10 months later...

I think its no use 

1 hour ago, Dealman said:

Can people inside the zone kill people that are outside the zone? If yes, I'd suggest you add a setting for that. :)

I think its makes more fun p ! Those who r protected can get a god mode but instead they vll comeout also yes there is option for not spawning weapons,vehicles at greenzones u need edit them!give weapon to false and create vehicle to false in lua! But i think we dont need this thing to destroy fun

Link to comment

 

if I want to make greenzones in anti-zombie areas, the following code corresponds?

-- By default it adds greenzone to the Freeroam/play standard spawnpoints to prevent spawnkills, you can add greenzone areas to it using the coordinate format
-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0},
local greenzones = {
	{x = 2467.42, y = -1686.06, z = 12, width = 37, depth = 36, height = 15}, -- Grove Street
	{x = 1987.69, y = 1503.08, z = 8, width = 40, depth = 70, height = 25}, -- LV Pirate ship
	{x = -727.38, y = 930.76, z = 11, width = 60, depth = 60, height = 25}, -- Wooden house thing
	{x = -2420, y = -626.2, z = 125, width = 60, depth = 60, height = 30}, -- San Fierro antenna thing
}

-- initialize all zones on resource start
local z = {}
function initGreenzones()
	if greenzones and #greenzones ~= 0 then
		for _,v in ipairs (greenzones) 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)
					local rarea = createRadarArea (v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
					setElementParent (rarea, c)
					
					setElementData (rarea, "zombieProof", true)
					
					if c then
						z[c] = true
						for _,p in ipairs (getElementsWithinColShape(c, "player")) do
							setElementData (p, "greenzone", true)
						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) == "player" then
									setElementData (h, "greenzone", true)
									outputChatBox ("* Greenzone * You have entered the greenzone", h, 0, 220, 0)
								end
							end
						)
						addEventHandler ("onColShapeLeave", c,
							function (h, d)
								if h and d and isElement(h) and getElementType (h) == "player" then
									removeElementData (h, "greenzone")
									outputChatBox ("* Greenzone * You have left the greenzone", h, 220, 220, 0)
								end
							end
						)
					end
				end
			end
		end
	end
end
addEventHandler ("onResourceStart", resourceRoot, initGreenzones)

function resetGreenzoneData()
	for _,p in ipairs (getElementsByType("player")) do
		if isElement(p) then
			removeElementData (p, "greenzone")
		end
	end
end
addEventHandler ("onResourceStop", resourceRoot, resetGreenzoneData)

 

Just now, MarcosMix99 said:

 

if I want to make greenzones in anti-zombie areas, the following code corresponds?


-- By default it adds greenzone to the Freeroam/play standard spawnpoints to prevent spawnkills, you can add greenzone areas to it using the coordinate format
-- Format is: {x = 0, y = 0, z = 0, width = 0, depth = 0, height = 0},
local greenzones = {
	{x = 2467.42, y = -1686.06, z = 12, width = 37, depth = 36, height = 15}, -- Grove Street
	{x = 1987.69, y = 1503.08, z = 8, width = 40, depth = 70, height = 25}, -- LV Pirate ship
	{x = -727.38, y = 930.76, z = 11, width = 60, depth = 60, height = 25}, -- Wooden house thing
	{x = -2420, y = -626.2, z = 125, width = 60, depth = 60, height = 30}, -- San Fierro antenna thing
}

-- initialize all zones on resource start
local z = {}
function initGreenzones()
	if greenzones and #greenzones ~= 0 then
		for _,v in ipairs (greenzones) 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)
					local rarea = createRadarArea (v.x, v.y, v.width, v.depth, 0, 255, 0, 150)
					setElementParent (rarea, c)
					
					setElementData (rarea, "zombieProof", true)
					
					if c then
						z[c] = true
						for _,p in ipairs (getElementsWithinColShape(c, "player")) do
							setElementData (p, "greenzone", true)
						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) == "player" then
									setElementData (h, "greenzone", true)
									outputChatBox ("* Greenzone * You have entered the greenzone", h, 0, 220, 0)
								end
							end
						)
						addEventHandler ("onColShapeLeave", c,
							function (h, d)
								if h and d and isElement(h) and getElementType (h) == "player" then
									removeElementData (h, "greenzone")
									outputChatBox ("* Greenzone * You have left the greenzone", h, 220, 220, 0)
								end
							end
						)
					end
				end
			end
		end
	end
end
addEventHandler ("onResourceStart", resourceRoot, initGreenzones)

function resetGreenzoneData()
	for _,p in ipairs (getElementsByType("player")) do
		if isElement(p) then
			removeElementData (p, "greenzone")
		end
	end
end
addEventHandler ("onResourceStop", resourceRoot, resetGreenzoneData)

 

line 21

Link to comment
  • 1 month later...
  • MTA Anti-Cheat Team
On 25-10-2016 at 6:54 PM, Khadeer143 said:

also yes there is option for not spawning vehicles at greenzones u need edit them! create vehicle to false in lua! 

That option isn't present in this greenzone script, but my other resource does this if you needed to (anti-vehicle zone): https://community.multitheftauto.com/index.php?p=resources&s=details&id=12240

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...