Jump to content

[HELP] Fix The Script


Sr.black

Recommended Posts

Hello I Have problem After completing the attack on the area the area takes on the color of another gang Team Ex:

The colors  areas wars between Ballas and Grove are a good. Each team takes the color of its team if it wins

The colors  areas wars between Aztecas and Vagos are a good. Each team takes the color of its team if it wins

But When an area is attacked by a team of Vagos on Grove or Vagos on Ballas or Aztecas on Ballas or Aztecas on Grove the team gang winner  takes the area in the color of another gang Team

I hope you have understood my problem and I hope to help me Thank you! ❤️

Code:

createRadarArea(2222.30,-1840.5,330,230,0,255,0,150) 
createRadarArea(1856.90,-1339,200,300,138,43,226,150)

local spam = true
local groveAttack = true -- AttackPermission
local ballasAttack = true -- AttackPermission
local vagosAttack = true -- AttackPermission
local aztecasAttack = true -- AttackPermission
local warTime = 5-- Guerrilla time
local areaRestTime = 10 -- Time is required to attack the same area
local allowedTeams = { "Grove Street", "Ballas", "Vagos", "Aztecas" }

--المناطق--
local RadarAreas = {
  {"Grove Street", 1040, -1851, 12, 250, 270, 40, "Area1"}, --Areas1
  {"Ballas", 593.5, -655, 12, 250, 250, 50, "Area2"},
  {"Grove Street", 2308, -1379, 20, 139, 220,50, "Area3"},
  {"Ballas", 1956.2, -2161.6, 12, 150, 200,40, "Area4"},
  {"Grove Street", 2210, -105, 25, 187, 207,40, "Area5"},
  {"Ballas", 145.6, -1818, 0.5, 210, 120,40, "Area6"},
  {"Vagos", 2105, -1318, 23, 191, 285, 40, "Area7"},
  {"Aztecas", 2413, -2248, 13, 322, 208, 40, "Area8"},
  {"Vagos", 84.9287109375, -1609.8056640625, 14.62853717804, 503.0380859375, 475.2646484375, 40, "Area9"},
  {"Aztecas", 610.3544921875, -1309.8408203125, 23.825687408447, 329.345703125, 353.1630859375, 40, "Area10"}
}

function getAreaColor(AreaGang)
  local colors = {
    ["Grove Street"] = {0, 255, 0},
    ["Ballas"] = {100, 32, 240},
    ["Vagos"] = {255, 230, 0},
    ["Aztecas"] = {0, 171, 255}
  }
  return colors[AreaGang][1], colors[AreaGang][2], colors[AreaGang][3]
end

-- صناعة المناطق
for i, areaData in ipairs(RadarAreas) do
  local gangName = areaData[1]
  local R, G, B = getAreaColor(gangName)
  local x, y, z, width, height, depth, elementID = areaData[2], areaData[3], areaData[4], areaData[5], areaData[6], areaData[7], areaData[8], areaData[9], areaData[10], areaData[11]

  local radarArea = createRadarArea(x, y, width, height, R, G, B,80)
  local colCuboid = createColCuboid(x, y, z, width, height, depth)
  setElementID(colCuboid,elementID)
  setElementData(colCuboid, "radarArea", radarArea)
  setElementData(colCuboid, "areaTeam", gangName)
  setElementData(colCuboid, "areaScore",0)
end


function getPlayerTeamName(player)
  if player and getElementType(player) == "player" then
    local playerTeam = getPlayerTeam(player)
    if playerTeam then
      return getTeamName(playerTeam)
    end
  end
end


function isTeamAllowed(teamName)
    for _, allowedTeam in ipairs(allowedTeams) do
        if allowedTeam == teamName then
            return true
        end
    end
    return false
end

function getRemainingTime(area)
  local areaTimeDate = getElementData(area, "areaTimeDate") or 0
  local currentTime = getRealTime().timestamp
  local remainingTime = ((60*1000)*warTime) - (currentTime - areaTimeDate) * 1000 - 1000
  return remainingTime
end

--عندما يدخل أو يخرج اللاعب من المنطقة 
addEventHandler("onColShapeHit", resourceRoot, function(player)
  if isElement(player) and getElementType(player) == "player" and isTeamAllowed(getPlayerTeamName(player)) then
    setElementData(player, "areaIn", source)
    if isRadarAreaFlashing(getElementData(source, "radarArea")) then
      local remainingTime = getRemainingTime(source)
      exports ["Timer"]:timerGo(player,remainingTime)
    end
  end
end)

addEventHandler("onColShapeLeave", resourceRoot, function(player)
  if isElement(player) and getElementType(player) == "player" and isTeamAllowed(getPlayerTeamName(player)) then
    setElementData(player, "areaIn", false)
    if isRadarAreaFlashing(getElementData(source, "radarArea")) then
      exports ["Timer"]:timerStop(player)
    end
  end
end)


------------------------------------ When the player is attacked, the server determines whether or not -------------------

local attackPermission = {
  ["Grove Street"] = true,
  ["Ballas"] = true,
  ["Vagos"] = true,
  ["Aztecas"] = true
}

function getAttackPermission(areaTeam)
  return attackPermission[areaTeam]
end

function setAttackPermission(areaTeam, state)
  attackPermission[areaTeam] = state
end


function AreaAttack(player, commandName)
  if spam then
    spam = false
    setTimer(function() spam = true end, 1000, 1)

    local area = getElementData(player, "areaIn")
    if area then
      local areaTeam = getElementData(area, "areaTeam")
      local playerTeam = getPlayerTeam(player)
      local playerTeamName = getTeamName(playerTeam)

      if playerTeamName == areaTeam then
        exports ["info_Text"]:createInfoText(player,"You cannot attack your area",10000,225,50,50,"error_Info")
      elseif playerTeamName ~= areaTeam and (playerTeamName == "Grove Street" or playerTeamName == "Ballas" or playerTeamName == "Vagos" or playerTeamName == "Aztecas") then
        local permission = getAttackPermission(areaTeam)
        local radarArea = getElementData(area, "radarArea")
        local R, G, B, A = getRadarAreaColor(radarArea)
        
        if A >= 150 then
          exports ["info_Text"]:createInfoText(player,"Come back later, this is a new area",10000,225,50,50,"error_Info")
          return
        end
        
        if permission then
          setAttackPermission(areaTeam, false)
          setRadarAreaFlashing(radarArea, true)
          setElementData(area, "areaTimeDate", os.time())
          setTimer(setWinneTeam, (60*1000)* warTime, 1, area, areaTeam)
          exports ["info_Text"]:createInfoText(player,"بدء الهجوم",10000)
          sendRemainingTime(area)
          sendGangAlert(playerTeamName,areaTeam)
        else
          exports ["info_Text"]:createInfoText(player,"You cannot attack an area where an area is already under attack",10000,225,50,50,"error_Info")
        end
      end
    end
  end
end
addCommandHandler("attack", AreaAttack)



function setWinneTeam(Area, areaTeam) -- Determine the winner
  local playerCount = {
    ["Grove Street"] = 0,
    ["Ballas"] = 0,
    ["Vagos"] = 0,
    ["Aztecas"] = 0
  }

  local playersInArea = getElementsWithinColShape(Area, "player")
  local winningTeam

  for _, player in ipairs(playersInArea) do
    local playerTeam = getPlayerTeam(player)
    local teamName = getTeamName(playerTeam)

    if teamName == "Grove Street" then
      playerCount["Grove Street"] = playerCount["Grove Street"] + 1
      exports["Xp_Level"]:givePlayerXP(player, 100)
      givePlayerMoney(player, 3000)
    elseif teamName == "Ballas" then
      playerCount["Ballas"] = playerCount["Ballas"] + 1
      exports["Xp_Level"]:givePlayerXP(player, 100)
      givePlayerMoney(player, 3000)
    elseif teamName == "Vagos" then
      playerCount["Vagos"] = playerCount["Vagos"] + 1
      -- Add XP and money rewards for Vagos
    elseif teamName == "Aztecas" then
      playerCount["Aztecas"] = playerCount["Aztecas"] + 1
      -- Add XP and money rewards for Aztecas
    end
  end

  local score = getElementData(Area, "areaScore")
  
  if (score > 0 and areaTeam == "Grove Street" and playerCount["Ballas"] > 0) or (areaTeam == "Grove Street" and playerCount["Grove Street"] == 0) then
    winningTeam = "Ballas"
  elseif (score > 0 and areaTeam == "Ballas" and playerCount["Grove Street"] > 0) or (areaTeam == "Ballas" and playerCount["Ballas"] == 0) then
    winningTeam = "Grove Street"
  elseif (score > 0 and areaTeam == "Aztecas" and playerCount["Vagos"] > 0) or (areaTeam == "Aztecas" and playerCount["Aztecas"] == 0) then
    winningTeam = "Vagos"
  elseif (score > 0 and areaTeam == "Vagos" and playerCount["Aztecas"] > 0) or (areaTeam == "Vagos" and playerCount["Vagos"] == 0) then
    winningTeam = "Aztecas"
  elseif (score > 0 and areaTeam == "Grove Street" and playerCount["Aztecas"] > 0) or (areaTeam == "Grove Street" and playerCount["Grove Street"] == 0) then
    winningTeam = "Aztecas"
  elseif (score > 0 and areaTeam == "Aztecas" and playerCount["Grove Street"] > 0) or (areaTeam == "Aztecas" and playerCount["Aztecas"] == 0) then
    winningTeam = "Grove Street"
  elseif (score > 0 and areaTeam == "Ballas" and playerCount["Aztecas"] > 0) or (areaTeam == "Ballas" and playerCount["Ballas"] == 0) then
    winningTeam = "Aztecas"
  elseif (score > 0 and areaTeam == "Aztecas" and playerCount["Ballas"] > 0) or (areaTeam == "Aztecas" and playerCount["Aztecas"] == 0) then
    winningTeam = "Ballas"
  elseif (score > 0 and areaTeam == "Grove Street" and playerCount["Vagos"] > 0) or (areaTeam == "Grove Street" and playerCount["Grove Street"] == 0) then
    winningTeam = "Vagos"
  elseif (score > 0 and areaTeam == "Vagos" and playerCount["Grove Street"] > 0) or (areaTeam == "Vagos" and playerCount["Vagos"] == 0) then
    winningTeam = "Grove Street"
  elseif (score > 0 and areaTeam == "Ballas" and playerCount["Vagos"] > 0) or (areaTeam == "Ballas" and playerCount["Ballas"] == 0) then
    winningTeam = "Vagos"
  elseif (score > 0 and areaTeam == "Vagos" and playerCount["Ballas"] > 0) or (areaTeam == "Vagos" and playerCount["Vagos"] == 0) then
    winningTeam = "Ballas"
  else
    winningTeam = areaTeam
  end
  WarEnd(Area, areaTeam, winningTeam)
end

function WarEnd(Area ,areaTeam, winningTeam) --- The end of the battle after determining the winner and returning the area to normal
  local radarArea = getElementData(Area, "radarArea")
  local R, G, B = getAreaColor(winningTeam)
  setElementData(Area, "areaTeam", winningTeam)
  setElementData(Area, "areaScore",0)
  setAttackPermission(areaTeam,true)
  setRadarAreaColor(radarArea,R,G,B,150)
  setRadarAreaFlashing(radarArea,false)
  setTimer(setRadarAreaColor,(60*1000)* areaRestTime,1,radarArea,R,G,B,80)
end



addEventHandler("onPlayerWasted", root, function(ammo, attacker)
    local playerTeamName = getPlayerTeamName(source)
    local attackerTeamName = getPlayerTeamName(attacker)

    if playerTeamName ~= attackerTeamName and isTeamAllowed(playerTeamName) and isTeamAllowed(attackerTeamName) then
      givePlayerMoney(attacker, 100)
      exports["Xp_Level"]:givePlayerXP(attacker, 100)

      local area = getElementData(source, "areaIn")
      if area and isRadarAreaFlashing(getElementData(area, "radarArea")) then
          scoreCount(area, playerTeamName, attackerTeamName)
      end
    end
end)


function scoreCount(Area,playerTeamName,attackerTeamName)
  local areaTeam = getElementData(Area, "areaTeam")
  local areaScore = getElementData(Area, "areaScore")
  
  if areaTeam == playerTeamName then
    areaScore = areaScore + 1
  else
    areaScore = areaScore - 1
  end
  setElementData(Area, "areaScore",areaScore)
end


function sendGangAlert(attacker, defender)
    local teams = { attacker, defender }

    for _, team in ipairs(teams) do
        local allPlayers = getPlayersInTeam(getTeamFromName(team))
        local r,g,b
        local message
        if team == attacker then
            message = "Your team is attacking in the area go to help"
            r,g,b = 0,255,0
        else
            message = "Your area is under attack, go defend it"
            r,g,b = 255,0,0
        end

        for _, player in ipairs(allPlayers) do
            outputChatBox(message, player, r,g,b)
        end
    end
end


function sendRemainingTime(area)
  local playersInArea = getElementsWithinColShape(area, "player")
  local remainingTime = getRemainingTime(area)
  for _, player in ipairs(playersInArea) do
    if player and isTeamAllowed(getPlayerTeamName(player)) and isElementWithinColShape(player,area) then
      exports ["Timer"]:timerGo(player,remainingTime)
    end
  end
end

 

Edited by Sr.black
Link to comment
  • Moderators
12 hours ago, Sr.black said:

I hope you have understood my problem

I took a look at it. But I am not sure if I understand all the rules.

 

One thing that I can suggest to make it more readable:

local example = {
	["Grove Street"] = function (score, playerCount)
		-- Aztecas or Vagos
		if score > 0 and (playerCount["Aztecas"] > 0 or playerCount["Vagos"] > 0) and playerCount["Aztecas"] ~= playerCount["Vagos"] then
			if playerCount["Aztecas"] > playerCount["Vagos"] then 
				return "Aztecas"
			end
			return "Vagos"
		end
		-- or Ballas
		if score > 0 and playerCount["Ballas"] > 0 or playerCount["Grove Street"] == 0 then
			return "Ballas"
		end
		-- or Grove Street
		return "Grove Street"
	end
}

-- local winner = example[areaTeam](score, playerCount)

 

  • Like 1
Link to comment
10 hours ago, IIYAMA said:

I took a look at it. But I am not sure if I understand all the rules.

 

One thing that I can suggest to make it more readable:

local example = {
	["Grove Street"] = function (score, playerCount)
		-- Aztecas or Vagos
		if score > 0 and (playerCount["Aztecas"] > 0 or playerCount["Vagos"] > 0) and playerCount["Aztecas"] ~= playerCount["Vagos"] then
			if playerCount["Aztecas"] > playerCount["Vagos"] then 
				return "Aztecas"
			end
			return "Vagos"
		end
		-- or Ballas
		if score > 0 and playerCount["Ballas"] > 0 or playerCount["Grove Street"] == 0 then
			return "Ballas"
		end
		-- or Grove Street
		return "Grove Street"
	end
}

-- local winner = example[areaTeam](score, playerCount)

 

Unfortunately :( the problem is still not fixed anyway thank you for trying to help

Respect !

Link to comment
11 hours ago, IIYAMA said:

I took a look at it. But I am not sure if I understand all the rules.

 

One thing that I can suggest to make it more readable:

local example = {
	["Grove Street"] = function (score, playerCount)
		-- Aztecas or Vagos
		if score > 0 and (playerCount["Aztecas"] > 0 or playerCount["Vagos"] > 0) and playerCount["Aztecas"] ~= playerCount["Vagos"] then
			if playerCount["Aztecas"] > playerCount["Vagos"] then 
				return "Aztecas"
			end
			return "Vagos"
		end
		-- or Ballas
		if score > 0 and playerCount["Ballas"] > 0 or playerCount["Grove Street"] == 0 then
			return "Ballas"
		end
		-- or Grove Street
		return "Grove Street"
	end
}

-- local winner = example[areaTeam](score, playerCount)

 

Hello I came back after I fixed the problem The example you gave me helped me a lot to reconsider and rebuild it again. Thank you !!!

Respect Bro!

Link to comment
2 hours ago, Sr.black said:

Hello I came back after I fixed the problem The example you gave me helped me a lot to reconsider and rebuild it again. Thank you !!!

Respect Bro!

Unfortunately after my experience of attacking the areas of all other gangs I discovered the same problem :(

Link to comment
  • Moderators
3 hours ago, Sr.black said:

Unfortunately after my experience of attacking the areas of all other gangs I discovered the same problem :(

Something I like to do it is logging the current situation.

  • playerCount in the area (of all teams)
  • score
  • winner

And then go manually through the system with the current situation until you find the issue.

  • Like 1
Link to comment
20 hours ago, IIYAMA said:

Something I like to do it is logging the current situation.

  • playerCount in the area (of all teams)
  • score
  • winner

And then go manually through the system with the current situation until you find the issue.

Unfortunately I was not able to find the solution and I did not find the source of the solution If there is a solution you find appropriate

If you want can you change the terms of the winner of the war? the team that kills the largest number in the war zone is the winner and the color of the winning team is determined for the four gangs in the war set the winning teams color area

It may fix the problems I dont mind changing the code completely thank you

Maybe it helps the code was like this before I added the Aztecas and Vagos gang with the Ballas and Grove street gangs

createRadarArea(2222.30,-1840.5,330,230,0,255,0,150) 
createRadarArea(1856.90,-1339,200,300,138,43,226,150)

local spam = true
local groveAttack = true -- AttackPermission
local ballasAttack = true -- AttackPermission
local warTime = 5--وقت حرب العصابات
local areaRestTime = 10 
local allowedTeams = { "Grove Street", "Ballas" }


local RadarAreas = {
  {"Grove Street", 1040, -1851, 12, 250, 270, 40, "Area1"}, --Areas1
  {"Ballas", 593.5, -655, 12, 250, 250, 50, "Area2"},
  {"Grove Street", 2308, -1379, 20, 139, 220,50, "Area3"},
  {"Ballas", 1956.2, -2161.6, 12, 150, 200,40, "Area4"},
  {"Grove Street", 2210, -105, 25, 187, 207,40, "Area5"},
  {"Ballas", 145.6, -1818, 0.5, 210, 120,40, "Area6"}
}

function getAreaColor(AreaGang)
  local colors = {
    ["Grove Street"] = {0, 255, 0},
    ["Ballas"] = {100, 32, 240}
  }
  return colors[AreaGang][1], colors[AreaGang][2], colors[AreaGang][3]
end

for i, areaData in ipairs(RadarAreas) do
  local gangName = areaData[1]
  local R, G, B = getAreaColor(gangName)
  local x, y, z, width, height, depth, elementID = areaData[2], areaData[3], areaData[4], areaData[5], areaData[6], areaData[7], areaData[8]

  local radarArea = createRadarArea(x, y, width, height, R, G, B,80)
  local colCuboid = createColCuboid(x, y, z, width, height, depth)
  setElementID(colCuboid,elementID)
  setElementData(colCuboid, "radarArea", radarArea)
  setElementData(colCuboid, "areaTeam", gangName)
  setElementData(colCuboid, "areaScore",0)
end


function getPlayerTeamName(player)
  if player and getElementType(player) == "player" then
    local playerTeam = getPlayerTeam(player)
    if playerTeam then
      return getTeamName(playerTeam)
    end
  end
end


function isTeamAllowed(teamName)
    for _, allowedTeam in ipairs(allowedTeams) do
        if allowedTeam == teamName then
            return true
        end
    end
    return false
end

function getRemainingTime(area)
  local areaTimeDate = getElementData(area, "areaTimeDate") or 0
  local currentTime = getRealTime().timestamp
  local remainingTime = ((60*1000)*warTime) - (currentTime - areaTimeDate) * 1000 - 1000
  return remainingTime
end


addEventHandler("onColShapeHit", resourceRoot, function(player)
  if isElement(player) and getElementType(player) == "player" and isTeamAllowed(getPlayerTeamName(player)) then
    setElementData(player, "areaIn", source)
    if isRadarAreaFlashing(getElementData(source, "radarArea")) then
      local remainingTime = getRemainingTime(source)
      exports ["Timer"]:timerGo(player,remainingTime)
    end
  end
end)

addEventHandler("onColShapeLeave", resourceRoot, function(player)
  if isElement(player) and getElementType(player) == "player" and isTeamAllowed(getPlayerTeamName(player)) then
    setElementData(player, "areaIn", false)
    if isRadarAreaFlashing(getElementData(source, "radarArea")) then
      exports ["Timer"]:timerStop(player)
    end
  end
end)



local attackPermission = {
  ["Grove Street"] = true,
  ["Ballas"] = true
}

function getAttackPermission(areaTeam)
  return attackPermission[areaTeam]
end

function setAttackPermission(areaTeam, state)
  attackPermission[areaTeam] = state
end


function AreaAttack(player, commandName)
  if spam then
    spam = false
    setTimer(function() spam = true end, 1000, 1)

    local area = getElementData(player, "areaIn")
    if area then
      local areaTeam = getElementData(area, "areaTeam")
      local playerTeam = getPlayerTeam(player)
      local playerTeamName = getTeamName(playerTeam)

      if playerTeamName == areaTeam then
        exports ["info_Text"]:createInfoText(player,"لا يمكنك السيطرة على منطقتك",10000,225,50,50,"error_Info")
      elseif playerTeamName ~= areaTeam and (playerTeamName == "Grove Street" or playerTeamName == "Ballas") then
        local permission = getAttackPermission(areaTeam)
        local radarArea = getElementData(area, "radarArea")
        local R, G, B, A = getRadarAreaColor(radarArea)
        
        if A >= 150 then
          exports ["info_Text"]:createInfoText(player,"عد لاحقًا، هذه المنطقة جديدة",10000,225,50,50,"error_Info")
          return
        end
        
        if permission then
          setAttackPermission(areaTeam, false)
          setRadarAreaFlashing(radarArea, true)
          setElementData(area, "areaTimeDate", os.time())
          setTimer(setWinneTeam, (60*1000)* warTime, 1, area, areaTeam)
          exports ["info_Text"]:createInfoText(player,"بدء الهجوم",10000)
          sendRemainingTime(area)
          sendGangAlert(playerTeamName,areaTeam)
        else
          exports ["info_Text"]:createInfoText(player,"لا يمكنك هناك بالفعل منطقة تحت الهجوم",10000,225,50,50,"error_Info")
        end
      end
    end
  end
end
addCommandHandler("attack", AreaAttack)



function setWinneTeam(Area, areaTeam) -- تحديد الفائز
  local playerCount = {
    ["Grove Street"] = 0,
    ["Ballas"] = 0
  }

  local playersInArea = getElementsWithinColShape(Area, "player")
  local winningTeam

  for _, player in ipairs(playersInArea) do
    local playerTeam = getPlayerTeam(player)
    local teamName = getTeamName(playerTeam)

    if teamName == "Grove Street" then
      playerCount["Grove Street"] = playerCount["Grove Street"] + 1
      exports["Xp_Level"]:givePlayerXP(player, 100)
      givePlayerMoney(player,3000)
    elseif teamName == "Ballas" then
      playerCount["Ballas"] = playerCount["Ballas"] + 1
      exports["Xp_Level"]:givePlayerXP(player, 100)
      givePlayerMoney(player,3000)
    end
  end

  local score = getElementData(Area, "areaScore")
  
  if (score > 0 and  areaTeam == "Grove Street" and playerCount["Ballas"] > 0 ) or (areaTeam == "Grove Street" and playerCount["Grove Street"] == 0) then
    winningTeam = "Ballas"
  elseif (score > 0 and  areaTeam == "Ballas" and playerCount["Grove Street"] > 0) or (areaTeam == "Ballas" and playerCount["Ballas"] == 0) then
    winningTeam = "Grove Street"
  else
    winningTeam = areaTeam
  end
  WarEnd(Area ,areaTeam, winningTeam)
end


function WarEnd(Area ,areaTeam, winningTeam) 
  local radarArea = getElementData(Area, "radarArea")
  local R, G, B = getAreaColor(winningTeam)
  setElementData(Area, "areaTeam", winningTeam)
  setElementData(Area, "areaScore",0)
  setAttackPermission(areaTeam,true)
  setRadarAreaColor(radarArea,R,G,B,150)
  setRadarAreaFlashing(radarArea,false)
  setTimer(setRadarAreaColor,(60*1000)* areaRestTime,1,radarArea,R,G,B,80)
end



addEventHandler("onPlayerWasted", root, function(ammo, attacker)
    local playerTeamName = getPlayerTeamName(source)
    local attackerTeamName = getPlayerTeamName(attacker)

    if playerTeamName ~= attackerTeamName and isTeamAllowed(playerTeamName) and isTeamAllowed(attackerTeamName) then
      givePlayerMoney(attacker, 100)
      exports["Xp_Level"]:givePlayerXP(attacker, 100)

      local area = getElementData(source, "areaIn")
      if area and isRadarAreaFlashing(getElementData(area, "radarArea")) then
          scoreCount(area, playerTeamName, attackerTeamName)
      end
    end
end)


function scoreCount(Area,playerTeamName,attackerTeamName)
  local areaTeam = getElementData(Area, "areaTeam")
  local areaScore = getElementData(Area, "areaScore")
  
  if areaTeam == playerTeamName then
    areaScore = areaScore + 1
  else
    areaScore = areaScore - 1
  end
  setElementData(Area, "areaScore",areaScore)
end


function sendGangAlert(attacker, defender)
    local teams = { attacker, defender }

    for _, team in ipairs(teams) do
        local allPlayers = getPlayersInTeam(getTeamFromName(team))
        local r,g,b
        local message
        if team == attacker then
            message = "فريقك يهاجم في منطقة اذهب للمساعدة اذا تستطيع"
            r,g,b = 0,255,0
        else
            message = "منطقتك تتعرض للهجوم اذهب للدفاع عنها"
            r,g,b = 255,0,0
        end

        for _, player in ipairs(allPlayers) do
            outputChatBox(message, player, r,g,b)
        end
    end
end


function sendRemainingTime(area)
  local playersInArea = getElementsWithinColShape(area, "player")
  local remainingTime = getRemainingTime(area)
  for _, player in ipairs(playersInArea) do
    if player and isTeamAllowed(getPlayerTeamName(player)) and isElementWithinColShape(player,area) then
      exports ["Timer"]:timerGo(player,remainingTime)
    end
  end
end

 

Edited by Sr.black
Link to comment
  • Moderators
5 hours ago, Sr.black said:

If you want can you change the terms of the winner of the war? the team that kills the largest number in the war zone is the winner and the color of the winning team is determined for the four gangs in the war set the winning teams color area

Having very complex winning conditions also makes it harder for your players to understand. Maybe it is for the best to keep things simple.

  • Thanks 1
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...