Jump to content

[Help]Turf System Bug


Recommended Posts

When someone enters the area, it flashes without interruption

addEventHandler ( "onResourceStart", resourceRoot,
function (   )
	for i, v in ipairs(TufrsPos) do
		local ColShape = createColRectangle(v[1], v[2], v[3], v[4])
		local Team = getTeamFromName(v[5])
		local TeamName = "N/A"
		local R, G, B = 255, 255, 255
		if Team then
			R, G, B = getTeamColor(Team) TeamName = getTeamName(Team)
		end
		Tufrs[ColShape] = { 
		Radar = createRadarArea(v[1], v[2], v[3], v[4] , R, G, B, 180) , 
		TeamName = TeamName , 
		occupier = 100 ,
		Money = v[6] ,
		}
	end 
end )

addEventHandler("onMouseEnter",root,
function(mouse)
if source == BTN.Open then
guiSetAlpha(BTN.Open,0.80)
end
end
)

addEventHandler("onMouseLeave",root,
function(Leave)
if source == BTN.Open then
guiSetAlpha(BTN.Open,1)
end
end
)


function getColPlayerTeam (Col, Team)
	for i, pla in pairs(getElementsWithinColShape(Col, "player")) do
		if getPlayerTeam(pla) and getPlayerTeam(pla) ~= getTeamFromName("Criminals") and getTeamName(getPlayerTeam(pla)) == getTeamName(Team) then
			return true
		else
			exports.guimessages:sendClientMessage( "~Warning : You must kill the other team members in the zone~",pla ,232 ,0 ,0 )
			return false
		end
	end
	return false
end

function getTeamTufrs(Team)
	local Tufr = {  }
	for Col, v in pairs(Tufrs) do
		if v.TeamName == getTeamName(Team) then
			table.insert( Tufr, Col )
		end
	end
	return Tufr
end

addEventHandler("onColShapeHit",root,
function(pla)
	local Rader = Tufrs[source]
	if ( Rader ) then
		setElementData(pla, "TeamTufrs",Rader )
	end
end)

addEventHandler("onColShapeLeave",root,
function(pla)
	setElementData(pla, "TeamTufrs",false )
end)


setTimer (function ( )
	for Col, v in pairs(Tufrs) do
		for i, pla in pairs(getElementsWithinColShape(Col, "player")) do
			local Team = getPlayerTeam ( pla )
			if Team and getColPlayerTeam (Col, Team) then
				if getTeamName(Team) ~= Tufrs[Col].TeamName then
					if Tufrs[ Col ].occupier > 1 then
						Tufrs[ Col ].occupier = Tufrs[ Col ].occupier - 1
						setRadarAreaFlashing ( Tufrs[ Col ].Radar, true )
					elseif Tufrs[ Col ].occupier == 1  then
						local r, g, b = getTeamColor ( getPlayerTeam ( pla ) )
						setRadarAreaFlashing ( Tufrs[ Col ].Radar, false )
						setRadarAreaColor ( Tufrs[ Col ].Radar, r, g, b, 150 )
						Tufrs[ Col ].TeamName = getTeamName(Team)
						Tufrs[ Col ].occupier =  100
						exports.guimessages:sendClientMessage( "~Your Team now controls the turf~",pla ,0 ,255 ,0 )
						for i, player in ipairs(getPlayersInTeam( Team )) do
							local Money = Tufrs[ Col ].Money
							exports.guimessages:sendClientMessage("You won ~$~"..Money, player, 0, 255, 0)
							setElementData(player, "Money", getElementData(player, "Money") + Money)
						end
					end
					else
					if Tufrs[ Col ].occupier < 99 then
						Tufrs[ Col ].occupier = Tufrs[ Col ].occupier + 1 
					elseif Tufrs[ Col ].occupier == 99  then
						local r, g, b = getTeamColor ( getPlayerTeam ( pla ) )
						setRadarAreaFlashing ( Tufrs[ Col ].Radar, false )
						setRadarAreaColor ( Tufrs[ Col ].Radar, r, g, b, 150 )
						Tufrs[ Col ].TeamName = getTeamName(Team)
						Tufrs[ Col ].occupier =  100
					end
				end
			end
			setElementData(pla, "TeamTufrs",Tufrs[Col] )
		end
	end
end,5000, 0)

 

 

 

Link to comment
  • Moderators

Check these conditions in to your script:

  • What should happen if all players left the turf?
  • What should happen if the player his team has been removed?

 

And debug your code pls, then you should know:

 

  • Like 1
Link to comment
  • Moderators

That nobody is going to help you is obvious, especially when it isn't your code that has to be fixed.

Unfortunately I am a scripter that only helps people who are trying to script. That's how I make sure people will learn from my help, else it would be a waste of my time. So I am a bit useless to you.

 

But there are some options left:

- Find an idiotic scripter who does it for free. (yes they do exist) They are people that post code for topic creators that didn't started with code. You can try contact those idiots with a pm.

- Find a paidscripter. You might be able to fix it for €~3,5,- Which is nothing...

- Try out another truf resource, there must be a few of those on the community.

 

You are definitely not out of options.

 

 

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