Jump to content

setElementVisibleTo From createRadarArea help !!


dewek

Recommended Posts

Hello, sorry for my bad english

i have turf war script, please how to display radar to the team?.

local turf = {}
local timer = {}
local turfCount = {}
local turfName = {}
local isSomebodyInTurf = {}
local capture = {}
local radar = {}
local turfOwner = {}

function createTurfs()
    for index, ent in pairs(theTurfs) do
        local area = createColRectangle(ent[1], ent[2], ent[3], ent[4])
        local r = createRadarArea(ent[1], ent[2], ent[3], ent[4], 255, 255, 255, 170)
        radar[area] = r
        turf[area] = ent[5]
        turfName[area] = ent[5]
    end
end
addEventHandler("onResourceStart", resourceRoot, createTurfs)


function checkPlayersInTeam()
	for _, player in ipairs(exports.pool:getPoolElementsByType("player")) do
		if getElementData(player, "loggedin") then
			local Team = getPlayerTeam(player)
			local factionType = getElementData(Team, "type") or 99
			if (factionType==0) then
				setElementVisibleTo(radar[source], player, true) -- i want to show the area to player who factiontype is 0 (when i change player with root it works show the area)
			else
				setElementVisibleTo(radar[source], player, false) -- i want to hide the area to player who factiontype is not 0 (when i change player with root it works hide the area)
			end
		end
	end
end



function turfhide()
setTimer(checkPlayersInTeam, 5000, 0)    
end
addCommandHandler("hideturf", turfhide, false, false)

 

Edited by dewek
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...