Tron Posted March 5, 2018 Share Posted March 5, 2018 (edited) Hello out there, The problem is it doesn't adds players who joined the arena into the arena based teams. This is how it should work: when the player joins hunter arena, 3 teams named as 'Militants', 'Insurgents' and 'Invaders' are created. I want it to be like all the players who joins the hunter arena will be entered into random team from those 3 teams created on event startup. Non participators must stay in their own clan without any changes. local newTeam1 local newTeam2 local newTeam3 local originalteam -- to store the team of player before joining the arena addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end --local pX, pY, pZ = unpack(spawnarena2Positions[math.random(#spawnarena2Positions)]) local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) originalteam = getPlayerTeam (source) -- store the team of player before he joined the arena if (originalteam ) then --if he has team else originalteam = nil --if he dont have a team previously then set it as nil end newTeam1 = createTeam ( "Militants", 0, 255, 0 ) -- create a new team with the specified name newTeam2 = createTeam ( "Invaders", 100, 0, 20) newTeam3 = createTeam ( "Insurgents", 50, 100, 50) local teams = {newTeam1,newTeam2,newTeam3} for _, Jogador in ipairs(getElementsByType("player")) do -- THERE MIGHT BE A MISTAKE HERE HUH?. local randomteam = teams[math.random(#teams)] setPlayerTeam(source, randomteam) end local activeteam = getPlayerTeam (source) -- joined team if (activeteam) then if activeteam=="Militants" then setElementPosition(source, mX, mY, mZ) elseif activeteam=="Invaders" then setElementPosition(source, inX, inY, inZ) elseif activeteam=="Insurgents"then setElementPosition(source, isX, isY, isZ) else end end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) --setElementDimension(source, 2) end ) Edited March 5, 2018 by Tron Link to comment
DNL291 Posted March 5, 2018 Share Posted March 5, 2018 (edited) You're using 'source' at line 30, replace it with 'Jogador'. Edited March 5, 2018 by DNL291 Link to comment
Tron Posted March 6, 2018 Author Share Posted March 6, 2018 Still same when any player joins hunter arena he is placed in one of the teams created randomly but it adds other players(non participators) too in one of those 3 clans Link to comment
DNL291 Posted March 6, 2018 Share Posted March 6, 2018 (edited) If the loop through all players is useless then remove it. Also, your code is creating the same teams everytime the event gets called. Try this: local newTeam1 = createTeam ( "Militants", 0, 255, 0 ) local newTeam2 = createTeam ( "Invaders", 100, 0, 20) local newTeam3 = createTeam ( "Insurgents", 50, 100, 50) local originalteam -- to store the team of player before joining the arena addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end originalteam = getPlayerTeam (source) or nil local teams = {newTeam1,newTeam2,newTeam3} local randomteam = teams[math.random(#teams)] setPlayerTeam(source, randomteam) local activeteam = getPlayerTeam (source) -- joined team if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) --setElementDimension(source, 2) end ) Edited March 6, 2018 by DNL291 Link to comment
Tron Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) It works perfectly for first time when you join the arena. When you type /exitarena it removes you from arena and spawns you back in your previous clan. Till there its fine tho the problem is when you join the arena again it dont spawn and it doesn't adds you anymore in one of the 3 teams. Here's the entire code:- addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local allGreenzones = getElementsByType ("radararea") for i,v in ipairs (allGreenzones) do local r, g, b, a = getRadarAreaColor (v) if (r == 255) and (g == 0) and (b == 0) and (a == 255) then local x, y = getElementPosition (v) local sx, sy = getRadarAreaSize (v) setRadarAreaFlashing(v, true) local col = createColCuboid (x, y, -50, sx, sy, 7500) setElementID (col, "ColShapeMultiGameMode") end end end ) spawnVehPositions = { {-1292.8455810547, -364.38061523438, 15.8}, {-1350.6311035156, -258.98291015625, 14.14396572113}, {-1467.52734375, -190.3069152832, 14.1484375}, {-1620.8626708984, -51.465915679932, 3.5595684051514}, {-1620.2762451172, -590.58685302734, 14.1484375}, } spawnarena2Positionsmilitants = { {789.79999, -2120.3999, 14.1484375}, {795.5, -2228, 15.4}, {795.70001, -2218.8, 15.2}, } spawnarena2Positionsinvaders = { {649.29999, -2409.3, 83}, {623.40002, -2498.3999, 71.9}, {623.70001, -2497.8, 71.9}, } spawnarena2Positionsinsurgents = { {502.20001, -2297.2, 124.6}, {456.60001, -2256.8999, 128.3}, {450.29999, -2258.3, 128.3}, } addEventHandler("onColShapeLeave", root, function (Jogador) if (getElementData(Jogador, "MultiGM") and getElementByID("ColShapeMultiGameMode")) then if (not getElementData(Jogador, "Morreu")) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "#ffffffWarning:-You've crossed the arena boundary!") end removeElementData(Jogador, "MultiGM") end end end ) addEventHandler("onColShapeHit", root, function (Jogador) if (not getElementData(Jogador, "MultiGM")) and getElementByID("ColShapeMultiGameMode") then if ( getElementDimension(Jogador) == 1 ) then setElementData(Jogador, "MultiGM", "Hydra") elseif ( getElementDimension(Jogador) == 2) then setElementData(Jogador, "MultiGM", "Hunter") end end end ) Vehicle = {} function spawnVehMarker (Jogador) if (getElementDimension(Jogador) == 2) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(425, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hunter") elseif ( getElementDimension(Jogador) == 1 ) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(520, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hydra") end end for _, v in ipairs (spawnVehPositions) do MarkerHunter = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) MarkerHydra = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) setElementDimension(MarkerHunter, 2) setElementDimension(MarkerHydra, 1) addEventHandler("onMarkerHit", MarkerHunter, spawnVehMarker) addEventHandler("onMarkerHit", MarkerHydra, spawnVehMarker) end addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, function () if getElementData(source, "Morreu") == 1 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) removeElementData(source, "Morreu") elseif getElementData(source, "Morreu") == 2 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) removeElementData(source, "Morreu") end end ) local newTeam1 = createTeam ( "Militants", 0, 255, 0 ) local newTeam2 = createTeam ( "Invaders", 100, 0, 20) local newTeam3 = createTeam ( "Insurgents", 50, 100, 50) local originalteam -- to store the team of player before joining the arena addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end originalteam = getPlayerTeam (source) or nil local teams = {newTeam1,newTeam2,newTeam3} local randomteam = teams[math.random(#teams)] setPlayerTeam(source, randomteam) local activeteam = getPlayerTeam (source) -- joined team if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) --setElementDimension(source, 2) end ) addEvent(getResourceName(getThisResource())..": addPlayerHydra", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHydra", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hunter") then elseif (getElementData(source, "MultiGM") == "Hunter") then removeElementData(source, "MultiGM") end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Dogfight Arena. To exit just type /exitarena") local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementData(source, "MultiGM", "Hydra") setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) end ) addEventHandler("onPlayerWasted", root, function (_, attacker) if (getElementData(source, "MultiGM")) then triggerClientEvent(source, getResourceName(getThisResource())..": respawnPlayer", root) if (attacker) then if (getElementType(attacker) == "player" and getElementData(attacker, "MultiGM")) then triggerClientEvent(attacker, getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(attacker).."!") elseif (getElementType(attacker) == "vehicle" and getElementData(getVehicleOccupant(attacker), "MultiGM")) then triggerClientEvent(getVehicleOccupant(attacker), getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(getVehicleOccupant(attacker)).."!") end else triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "#ffffffYou've committed suicide!") end end end ) addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") local currentteam = getPlayerTeam (Jogador) -- gets the current players team if (currentteam ) then --checks if the player is in a team by checking if playerTeam returned true setPlayerTeam (Jogador, originalteam) -- sets the team to the one which the player had previously before joining the arena end local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) Edited March 6, 2018 by Tron Link to comment
DNL291 Posted March 6, 2018 Share Posted March 6, 2018 (edited) Try this : addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local allGreenzones = getElementsByType ("radararea") for i,v in ipairs (allGreenzones) do local r, g, b, a = getRadarAreaColor (v) if (r == 255) and (g == 0) and (b == 0) and (a == 255) then local x, y = getElementPosition (v) local sx, sy = getRadarAreaSize (v) setRadarAreaFlashing(v, true) local col = createColCuboid (x, y, -50, sx, sy, 7500) setElementID (col, "ColShapeMultiGameMode") end end end ) spawnVehPositions = { {-1292.8455810547, -364.38061523438, 15.8}, {-1350.6311035156, -258.98291015625, 14.14396572113}, {-1467.52734375, -190.3069152832, 14.1484375}, {-1620.8626708984, -51.465915679932, 3.5595684051514}, {-1620.2762451172, -590.58685302734, 14.1484375}, } spawnarena2Positionsmilitants = { {789.79999, -2120.3999, 14.1484375}, {795.5, -2228, 15.4}, {795.70001, -2218.8, 15.2}, } spawnarena2Positionsinvaders = { {649.29999, -2409.3, 83}, {623.40002, -2498.3999, 71.9}, {623.70001, -2497.8, 71.9}, } spawnarena2Positionsinsurgents = { {502.20001, -2297.2, 124.6}, {456.60001, -2256.8999, 128.3}, {450.29999, -2258.3, 128.3}, } addEventHandler("onColShapeLeave", root, function (Jogador) if (getElementData(Jogador, "MultiGM") and getElementByID("ColShapeMultiGameMode")) then if (not getElementData(Jogador, "Morreu")) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "#ffffffWarning:-You've crossed the arena boundary!") end removeElementData(Jogador, "MultiGM") end end end ) addEventHandler("onColShapeHit", root, function (Jogador) if (not getElementData(Jogador, "MultiGM")) and getElementByID("ColShapeMultiGameMode") then if ( getElementDimension(Jogador) == 1 ) then setElementData(Jogador, "MultiGM", "Hydra") elseif ( getElementDimension(Jogador) == 2) then setElementData(Jogador, "MultiGM", "Hunter") end end end ) Vehicle = {} function spawnVehMarker (Jogador) if (getElementDimension(Jogador) == 2) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(425, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hunter") elseif ( getElementDimension(Jogador) == 1 ) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(520, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hydra") end end for _, v in ipairs (spawnVehPositions) do MarkerHunter = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) MarkerHydra = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) setElementDimension(MarkerHunter, 2) setElementDimension(MarkerHydra, 1) addEventHandler("onMarkerHit", MarkerHunter, spawnVehMarker) addEventHandler("onMarkerHit", MarkerHydra, spawnVehMarker) end addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, function () if getElementData(source, "Morreu") == 1 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) removeElementData(source, "Morreu") elseif getElementData(source, "Morreu") == 2 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) removeElementData(source, "Morreu") end end ) local newTeam1 local newTeam2 local newTeam3 local originalteam -- to store the team of player before joining the arena addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end originalteam = getPlayerTeam (source) local teams = {"Militants","Invaders","Insurgents"} if not getTeamFromName(teams[1]) then newTeam1 = createTeam ( "Militants", 0, 255, 0 ) newTeam2 = createTeam ( "Invaders", 100, 0, 20) newTeam3 = createTeam ( "Insurgents", 50, 100, 50) end local randomteam = teams[math.random(#teams)] setPlayerTeam(source, getTeamFromName(randomteam)) local activeteam = getPlayerTeam (source) -- joined team if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) end ) addEvent(getResourceName(getThisResource())..": addPlayerHydra", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHydra", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hunter") then elseif (getElementData(source, "MultiGM") == "Hunter") then removeElementData(source, "MultiGM") end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Dogfight Arena. To exit just type /exitarena") local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementData(source, "MultiGM", "Hydra") setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) end ) addEventHandler("onPlayerWasted", root, function (_, attacker) if (getElementData(source, "MultiGM")) then triggerClientEvent(source, getResourceName(getThisResource())..": respawnPlayer", root) if (attacker) then if (getElementType(attacker) == "player" and getElementData(attacker, "MultiGM")) then triggerClientEvent(attacker, getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(attacker).."!") elseif (getElementType(attacker) == "vehicle" and getElementData(getVehicleOccupant(attacker), "MultiGM")) then triggerClientEvent(getVehicleOccupant(attacker), getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(getVehicleOccupant(attacker)).."!") end else triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "#ffffffYou've committed suicide!") end end end ) addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") local currentteam = getPlayerTeam (Jogador) -- gets the current players team if (currentteam ) then --checks if the player is in a team by checking if playerTeam returned true setPlayerTeam (Jogador, originalteam) -- sets the team to the one which the player had previously before joining the arena end local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) Type /debugscript 3 if it doesn't work. Edited March 6, 2018 by DNL291 Link to comment
Tron Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) Now that bug is fixed. There's another problem now, sometimes when you execute /exitarena it removes you from the arena and team but adds again into a team from those 3 teams eventhough you aren't in the arena. Sometimes its not even adding you in your previous team if you execute /exitarena and join again repeatedly. There are no errors in debugscript 3 I've updated the respawn function, also how can i set the teams so that the equality of members is approximately maintained rather than having unequal members in every team. addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local allGreenzones = getElementsByType ("radararea") for i,v in ipairs (allGreenzones) do local r, g, b, a = getRadarAreaColor (v) if (r == 255) and (g == 0) and (b == 0) and (a == 255) then local x, y = getElementPosition (v) local sx, sy = getRadarAreaSize (v) setRadarAreaFlashing(v, true) local col = createColCuboid (x, y, -50, sx, sy, 7500) setElementID (col, "ColShapeMultiGameMode") end end end ) spawnVehPositions = { {-1292.8455810547, -364.38061523438, 15.8}, {-1350.6311035156, -258.98291015625, 14.14396572113}, {-1467.52734375, -190.3069152832, 14.1484375}, {-1620.8626708984, -51.465915679932, 3.5595684051514}, {-1620.2762451172, -590.58685302734, 14.1484375}, } spawnarena2Positionsmilitants = { {789.79999, -2120.3999, 14.1484375}, {795.5, -2228, 15.4}, {795.70001, -2218.8, 15.2}, } spawnarena2Positionsinvaders = { {649.29999, -2409.3, 83}, {623.40002, -2498.3999, 71.9}, {623.70001, -2497.8, 71.9}, } spawnarena2Positionsinsurgents = { {502.20001, -2297.2, 124.6}, {456.60001, -2256.8999, 128.3}, {450.29999, -2258.3, 128.3}, } addEventHandler("onColShapeLeave", root, function (Jogador) if (getElementData(Jogador, "MultiGM") and getElementByID("ColShapeMultiGameMode")) then if (not getElementData(Jogador, "Morreu")) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "#ffffffWarning:-You've crossed the arena boundary!") end removeElementData(Jogador, "MultiGM") end end end ) addEventHandler("onColShapeHit", root, function (Jogador) if (not getElementData(Jogador, "MultiGM")) and getElementByID("ColShapeMultiGameMode") then if ( getElementDimension(Jogador) == 1 ) then setElementData(Jogador, "MultiGM", "Hydra") elseif ( getElementDimension(Jogador) == 2) then setElementData(Jogador, "MultiGM", "Hunter") end end end ) Vehicle = {} function spawnVehMarker (Jogador) if (getElementDimension(Jogador) == 2) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(425, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hunter") elseif ( getElementDimension(Jogador) == 1 ) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(520, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hydra") end end for _, v in ipairs (spawnVehPositions) do MarkerHunter = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) MarkerHydra = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) setElementDimension(MarkerHunter, 2) setElementDimension(MarkerHydra, 1) addEventHandler("onMarkerHit", MarkerHunter, spawnVehMarker) addEventHandler("onMarkerHit", MarkerHydra, spawnVehMarker) end addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, function () if getElementData(source, "Morreu") == 1 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) --setElementPosition(source, pX, pY, pZ) local activeteam = getPlayerTeam (source) if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end setElementDimension(source, 2) removeElementData(source, "Morreu") elseif getElementData(source, "Morreu") == 2 then --local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) removeElementData(source, "Morreu") end end ) local newTeam1 local newTeam2 local newTeam3 local originalteam -- to store the team of player before joining the arena addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end originalteam = getPlayerTeam (source) local teams = {"Militants","Invaders","Insurgents"} if not getTeamFromName(teams[1]) then newTeam1 = createTeam ( "Militants", 0, 255, 0 ) newTeam2 = createTeam ( "Invaders", 100, 0, 20) newTeam3 = createTeam ( "Insurgents", 50, 100, 50) end local randomteam = teams[math.random(#teams)] setPlayerTeam(source, getTeamFromName(randomteam)) local activeteam = getPlayerTeam (source) -- joined team if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) end ) addEvent(getResourceName(getThisResource())..": addPlayerHydra", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHydra", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hunter") then elseif (getElementData(source, "MultiGM") == "Hunter") then removeElementData(source, "MultiGM") end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Dogfight Arena. To exit just type /exitarena") local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementData(source, "MultiGM", "Hydra") setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) end ) addEventHandler("onPlayerWasted", root, function (_, attacker) if (getElementData(source, "MultiGM")) then triggerClientEvent(source, getResourceName(getThisResource())..": respawnPlayer", root) if (attacker) then if (getElementType(attacker) == "player" and getElementData(attacker, "MultiGM")) then triggerClientEvent(attacker, getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(attacker).."!") elseif (getElementType(attacker) == "vehicle" and getElementData(getVehicleOccupant(attacker), "MultiGM")) then triggerClientEvent(getVehicleOccupant(attacker), getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(getVehicleOccupant(attacker)).."!") end else triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "#ffffffYou've committed suicide!") end end end ) addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") local currentteam = getPlayerTeam (Jogador) -- gets the current players team if (currentteam ) then --checks if the player is in a team by checking if playerTeam returned true setPlayerTeam (Jogador, originalteam) -- sets the team to the one which the player had previously before joining the arena end local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) Edited March 6, 2018 by Tron Link to comment
DNL291 Posted March 7, 2018 Share Posted March 7, 2018 (edited) 9 hours ago, Tron said: I've updated the respawn function, also how can i set the teams so that the equality of members is approximately maintained rather than having unequal members in every team. I've edited the code and added that function you mentioned in order to keep all teams balanced, haven't tested it though. Try this: addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local allGreenzones = getElementsByType ("radararea") for i,v in ipairs (allGreenzones) do local r, g, b, a = getRadarAreaColor (v) if (r == 255) and (g == 0) and (b == 0) and (a == 255) then local x, y = getElementPosition (v) local sx, sy = getRadarAreaSize (v) setRadarAreaFlashing(v, true) local col = createColCuboid (x, y, -50, sx, sy, 7500) setElementID (col, "ColShapeMultiGameMode") end end end ) spawnVehPositions = { {-1292.8455810547, -364.38061523438, 15.8}, {-1350.6311035156, -258.98291015625, 14.14396572113}, {-1467.52734375, -190.3069152832, 14.1484375}, {-1620.8626708984, -51.465915679932, 3.5595684051514}, {-1620.2762451172, -590.58685302734, 14.1484375}, } spawnarena2Positionsmilitants = { {789.79999, -2120.3999, 14.1484375}, {795.5, -2228, 15.4}, {795.70001, -2218.8, 15.2}, } spawnarena2Positionsinvaders = { {649.29999, -2409.3, 83}, {623.40002, -2498.3999, 71.9}, {623.70001, -2497.8, 71.9}, } spawnarena2Positionsinsurgents = { {502.20001, -2297.2, 124.6}, {456.60001, -2256.8999, 128.3}, {450.29999, -2258.3, 128.3}, } addEventHandler("onColShapeLeave", root, function (Jogador) if (getElementData(Jogador, "MultiGM") and getElementByID("ColShapeMultiGameMode")) then if (not getElementData(Jogador, "Morreu")) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "#ffffffWarning:-You've crossed the arena boundary!") end removeElementData(Jogador, "MultiGM") end end end ) addEventHandler("onColShapeHit", root, function (Jogador) if (not getElementData(Jogador, "MultiGM")) and getElementByID("ColShapeMultiGameMode") then if ( getElementDimension(Jogador) == 1 ) then setElementData(Jogador, "MultiGM", "Hydra") elseif ( getElementDimension(Jogador) == 2) then setElementData(Jogador, "MultiGM", "Hunter") end end end ) Vehicle = {} function spawnVehMarker (Jogador) if (getElementDimension(Jogador) == 2) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(425, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hunter") elseif ( getElementDimension(Jogador) == 1 ) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(520, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hydra") end end for _, v in ipairs (spawnVehPositions) do MarkerHunter = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) MarkerHydra = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) setElementDimension(MarkerHunter, 2) setElementDimension(MarkerHydra, 1) addEventHandler("onMarkerHit", MarkerHunter, spawnVehMarker) addEventHandler("onMarkerHit", MarkerHydra, spawnVehMarker) end addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, function () if getElementData(source, "Morreu") == 1 then --setElementPosition(source, pX, pY, pZ) local activeteam = getPlayerTeam (source) if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end setElementDimension(source, 2) removeElementData(source, "Morreu") elseif getElementData(source, "Morreu") == 2 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) removeElementData(source, "Morreu") end end ) local newTeam1 local newTeam2 local newTeam3 local aPlayers = {} addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end aPlayers[source] = getPlayerTeam (source) local teams = {"Militants","Invaders","Insurgents"} if not getTeamFromName(teams[1]) then newTeam1 = createTeam ( teams[1], 0, 255, 0 ) end if not getTeamFromName(teams[2]) then newTeam2 = createTeam ( teams[2], 100, 0, 20) end if not getTeamFromName(teams[3]) then newTeam3 = createTeam ( teams[3], 50, 100, 50) end local playerTeam = getFewestPlayersTeam() if playerTeam then setPlayerTeam(source, playerTeam) else return end if getTeamName(playerTeam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif getTeamName(playerTeam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif getTeamName(playerTeam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) end ) addEventHandler( "onPlayerQuit", root, function() if aPlayers[source] then aPlayers[source] - nil end end ) function getFewestPlayersTeam() local teams = { newTeam1, newTeam2, newTeam3 } if not teams[1] then return end local teamElement = false local f = 99999 for i=1, 3 do local pcount = countPlayersInTeam( teams[i] ) if pcount < f then f = pcount teamElement = teams[i] end end return teamElement end addEvent(getResourceName(getThisResource())..": addPlayerHydra", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHydra", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hunter") then elseif (getElementData(source, "MultiGM") == "Hunter") then removeElementData(source, "MultiGM") end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Dogfight Arena. To exit just type /exitarena") local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementData(source, "MultiGM", "Hydra") setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) end ) addEventHandler("onPlayerWasted", root, function (_, attacker) if (getElementData(source, "MultiGM")) then triggerClientEvent(source, getResourceName(getThisResource())..": respawnPlayer", root) if (attacker) then if (getElementType(attacker) == "player" and getElementData(attacker, "MultiGM")) then triggerClientEvent(attacker, getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(attacker).."!") elseif (getElementType(attacker) == "vehicle" and getElementData(getVehicleOccupant(attacker), "MultiGM")) then triggerClientEvent(getVehicleOccupant(attacker), getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(getVehicleOccupant(attacker)).."!") end else triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "#ffffffYou've committed suicide!") end end end ) addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") local currentteam = getPlayerTeam (Jogador) -- gets the current players team if (currentteam ) then --checks if the player is in a team by checking if playerTeam returned true setPlayerTeam (Jogador, aPlayers[Jogador]) -- sets the team to the one which the player had previously before joining the arena end local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) Edited March 7, 2018 by DNL291 Link to comment
Tron Posted March 7, 2018 Author Share Posted March 7, 2018 it shows error in the debug script. https://imgur.com/a/zl0Gi Link to comment
Tron Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) nvm there was a mistake in line 172: replaced '-' with '='. ? aPlayers[source] - nil After joining the arena when you execute /exitarena it doesn't adds you back in your previous clan. Player remains clan less. Changing nick while in arena is creating some sort of bugs too, i've a script of clan tag on, if you put on the tag of the clan you will be added in the clan. I guess it would be better if changing nick while in arena is blocked for all the arenas. Player must see a msg on the chatbox something like ("You can't change your nick while in arena, please exit the arena inorder to change your nick). Edited March 7, 2018 by Tron Link to comment
DNL291 Posted March 8, 2018 Share Posted March 8, 2018 I can't see anything wrong by looking at the code, try debugging it: addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") --local currentteam = getPlayerTeam (Jogador) -- gets the current players team outputChatBox( "old team: "..tostring(aPlayers[Jogador]) ) outputChatBox( "old team name: "..tostring(getTeamName(aPlayers[Jogador])) ) setPlayerTeam (Jogador, aPlayers[Jogador]) -- sets the team to the one which the player had previously before joining the arena local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) See what outputChatBox shows. 11 hours ago, Tron said: Changing nick while in arena is creating some sort of bugs too, i've a script of clan tag on, if you put on the tag of the clan you will be added in the clan. I guess it would be better if changing nick while in arena is blocked for all the arenas. Player must see a msg on the chatbox something like ("You can't change your nick while in arena, please exit the arena inorder to change your nick). Add something like this to your Clan tag script: if getElementData(player, "MultiGM") then return outputChatBox() end Link to comment
Tron Posted March 8, 2018 Author Share Posted March 8, 2018 Here's the result: https://imgur.com/a/BVkbj Link to comment
Tron Posted March 8, 2018 Author Share Posted March 8, 2018 (edited) Now its working fine. I wanted to add the arena menu in f1(freeroam console). When you click the 'Arenas' button it must open the arena menu of the resource. The arena resource is named as '[Test]Multigamemode'. Incase if the player is already in arena and he clicks the arena button it must show something like "You are already in a arena, please use /exitarena to exit and join again". Currently /arena is used to open the arena selection menu. https://imgur.com/a/JDZ8r Edited March 8, 2018 by Tron Link to comment
DNL291 Posted March 9, 2018 Share Posted March 9, 2018 Open fr_client.lua and search for the table "wndMain", there you can create the Arena button on the "controls" sub-table. You'll need to create an exported function to be able to open the Arena menu through the freeroam. Link to comment
Tron Posted March 9, 2018 Author Share Posted March 9, 2018 (edited) I''ve exported the function commandGM and called it in freeroam client under the arena button but it shows when every player reconnects instead of showing on clicking the button. It doesn't shows anything when you click the button. Here's the codes: Arena Menu's client file: [Exported function] -------------------------------------- ---- Arena menu ---- -------------------------------------- function commandGM (_, event) if not event then if isEventAdded then showChat(true) removeEventHandler ("onClientRender", root, selectedItem) else addEventHandler ("onClientRender", root, selectedItem) end isEventAdded = not isEventAdded showCursor (isEventAdded) elseif event == "hydra" then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHydra", localPlayer) elseif event == "hunter" then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHunter", localPlayer) end end addCommandHandler("openarena", commandGM, true) addCommandHandler("arena", commandGM, true) Arena menu's meta file[Exported the function commandGM]:- <export function="commandGM" type="client"/> Freeroam's client file:- wndMain = { 'wnd', text = 'Hydra Blast Console', x = 10, y = 150, width = 280, alpha = 1.0, controls = { {'lbl', id='nmlbl', text='Name :'}, {'lbl', id='plrname', text=getPlayerName( g_Me ), width=200, height = 20}, {'br'}, {'lbl', id='Pinglbl', text='Ping :'}, {'lbl', id='plrPing', text=getPlayerPing( g_Me ), width=80, height = 20}, {'br'}, {'lbl', id='Moneylbl', text='Money :'}, {'lbl', id='plrMoney', text=getPlayerMoney( g_Me ), width=80, height = 20}, {'br'}, {'lbl', id='myPos', text='Position:', width=80, height = 20}, {'lbl', id='xpos', text='x', width=45}, {'lbl', id='ypos', text='y', width=45}, {'lbl', id='zpos', text='z', width=45}, {'br'}, {'lbl', id='linelbl1', text='====================================================', width=250, height = 20}, {'br'}, {'btn', id='Kill', onclick=killLocalPlayer, width=80, height = 20}, {'btn', id='Skin', window=wndSkin, width=80, height = 20}, {'btn', id='Anim', window=wndAnim, width=80, height = 20}, {'btn', id='Clothes', window=wndClothes, width=80, height = 20}, {'btn', id='Weapons', window=wndWeapon, width=80, height = 20}, {'btn', id='Arenas', onclick=exports[ "[Test]Multigamemode" ]:commandGM(_,event), width=80, height = 20}, {'btn', id='Stats', window=wndStats, width=80, height = 20}, {'br'}, {'chk', id='falloff', text='Fall off bike', onclick=toggleFallOffBike, width=150, height = 20}, {'chk', id='togglewarptme', text='Block warp to me', onclick=togglewarptome, width=1000, height = 20}, {'br'}, {'lbl', id='linelbl2', text='====================================================', width=250, height = 20}, {'br'}, {'btn', id='setpos', text='Map', window=wndSetPos, width=80, height = 20}, {'br'}, {'lbl', id='linelbl3', text='====================================================', width=250, height = 20}, {'br'}, {'lbl', id='vehlbl', text='Vehicle:', width=80, height = 20}, {'br'}, {'lbl', id='curlbl', text='Current:', width=80, height = 20}, {'lbl', id='curvehicle', width=80, height = 20}, {'br'}, {'btn', id='createvehicle', window=wndCreateVehicle, text='Create', width=80, height = 20}, {'btn', id='Repair', onclick=repairVehicle, width=80, height = 20}, {'btn', id='Flip', onclick=flipVehicle, width=80, height = 20}, {'btn', id='Upgrades', window=wndUpgrades, width=80, height = 20}, {'btn', id='Color', onclick=openColorPicker, width=80, height = 20}, {'btn', id='Paintjob', window=wndPaintjob, width=80, height = 20}, {'br'}, {'chk', id='lightson', text='Lights on', onclick=forceLightsOn, width=87, height = 20}, {'chk', id='lightsoff', text='Lights off', onclick=forceLightsOff, width=87, height = 20}, }, oncreate = mainWndShow, onclose = mainWndClose } Edited March 9, 2018 by Tron Link to comment
Tron Posted March 9, 2018 Author Share Posted March 9, 2018 (edited) Client.lua codes of the arena system: local sx, sy = guiGetScreenSize () local relposx = sx/2 local medX = sx/2 local ancho = -3780 local sizeX = ancho/3 local mitSize = sizeX*0.5 local botX = medX-mitSize local relposx = sy/2 local medX2 = sy/2 local ancho2 = -2160 local sizeX2 = ancho2/3 local mitSize2 = sizeX2*0.5 local botX2 = medX2-mitSize2 local TimesInRespawnText = 5 local mainFont = dxCreateFont("Arquivos/Fontes/mainFont.ttf", 10) local mainFont2 = dxCreateFont("Arquivos/Fontes/mainFont.ttf", 13) local text = "" local screenW,screenH = guiGetScreenSize() local resW,resH = 1280,720 local sW,sH = (screenW/resW), (screenH/resH) function commandGM (_, event) if not event then if isEventAdded then showChat(true) removeEventHandler ("onClientRender", root, selectedItem) else addEventHandler ("onClientRender", root, selectedItem) end isEventAdded = not isEventAdded showCursor (isEventAdded) elseif event == "hydra" then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHydra", localPlayer) elseif event == "hunter" then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHunter", localPlayer) end end addCommandHandler("openarena", commandGM, true) addCommandHandler("arena", commandGM, true) addEventHandler("onClientClick",root, function (button, state) showChat(true) if (isEventAdded) then if (button == "left" and state == "down") then if (isCursorOnElement(280*sW,370*sH,225*sW, 50*sH)) then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHunter", localPlayer) isEventAdded = false removeEventHandler ("onClientRender", root, selectedItem) showCursor (isEventAdded) elseif (isCursorOnElement(35*sW,370*sH,225*sW, 50*sH)) then triggerServerEvent(getResourceName(getThisResource())..": addPlayerHydra", localPlayer) isEventAdded = false removeEventHandler ("onClientRender", root, selectedItem) showCursor (isEventAdded) elseif (isCursorOnElement (1245*sW,1*sH,30*sW,17*sH)) then isEventAdded = false removeEventHandler ("onClientRender", root, selectedItem) showCursor (isEventAdded) end end end end ) function selectedItem () showChat(false) dxDrawImage ( 1*sW, 1*sH, 1278*sW, 718*sH, 'background.png', angle, 0, -120 ) dxDrawRectangle(1*sW, 1*sH, 1278*sW, 718*sH, tocolor(0, 0, 0, 200), true) dxDrawRectangle(1*sW, 1*sH, 1278*sW, 20*sH, tocolor(185, 122, 87, 180), true) dxDrawText("Arena Selection Menu", 539*sW, -4*sH, 911*sW, 27*sH, tocolor(255, 127, 39, 255), 1.3, 'default-bold', 'left', 'center', false, false, true, false, false) dxDrawText("X",1255*sW,26*sH, 911*sW, -2*sH, isCursorOnElement(1245*sW,1*sH,30*sW,17*sH) and tocolor(255, 255, 255, 255) or tocolor(255, 127, 39, 255), 1.4, 'default-bold', 'left', 'center', false, false, true, false, false) dxDrawText("Hydra Blast v1.0", 1109*sW, 94*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.2, 'arial', 'left', 'center', false, false, true, false, false) dxDrawImage(30*sW,34*sH, 180*sW, 60*sH, "arena.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("Select an arena to play on", 79*sW, 210*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'clear', 'left', 'center', false, false, true, false, false) dxDrawImage(35*sW,140*sH, 225*sW, 282*sH, "Img/dogfight.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(280*sW,140*sH, 225*sW, 282*sH, "Img/hunter.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(525*sW,140*sH, 225*sW, 282*sH, "Img/stunt.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(770*sW,140*sH, 225*sW, 282*sH, "Img/freeroam.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(1015*sW,140*sH, 225*sW, 282*sH, "Img/minigames.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("Dogfight Arena",87*sW,792*sH,911*sW, -2*sH, isCursorOnElement(35*sW,370*sH,225*sW, 50*sH) and tocolor(30, 170, 66, 255) or tocolor(136, 0, 21, 255), 1.4, 'default-bold', 'left', 'center', false, false, true, false, false) dxDrawText("Protect the City",340*sW,792*sH,911*sW, -2*sH, isCursorOnElement(280*sW,370*sH,225*sW, 50*sH) and tocolor(30, 170, 66, 255) or tocolor(136, 0, 21, 255), 1.4, 'default-bold', 'left', 'center', false, false, true, false, false) dxDrawImage(30*sW,450*sH, 180*sW, 60*sH, "donate.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("By donation towards our community you are supporting the future of", 79*sW, 1050*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("Hydra Blast [HB]. Our goal is to create a cozy and comfortable", 79*sW, 1090*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("atmosphere for gaming on MTA. Even a small amount of money that", 79*sW, 1130*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("you have donated will help us to keep our server alive and running.", 79*sW, 1170*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("To donate and recieve the benifits of 'Contributor' status go to our", 79*sW, 1210*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("website at: coming soon!", 79*sW, 1250*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawImage(690*sW,450*sH, 180*sW, 60*sH, "statistics.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(790*sW,520*sH, 180*sW, 60*sH, "BAR.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(1000*sW,515*sH, 60*sW, 60*sH, "BAR2.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(790*sW,600*sH, 180*sW, 60*sH, "BAR.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(1000*sW,595*sH, 60*sW, 60*sH, "BAR2.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) local count=getPlayerCount() dxDrawText("Online Players", 819*sW, 1060*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText(count, 1025*sW, 1065*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.6, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("Online Staffs", 819*sW, 1220*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.4, 'arial', 'left', 'center', false, false, true, false, false) dxDrawText("#", 1025*sW, 1225*sH, 911*sW, 27*sH, tocolor(255, 255, 255, 255), 1.6, 'arial', 'left', 'center', false, false, true, false, false) end local originalGetPlayerCount = getPlayerCount -- Store the original getPlayerCount function to a variable function getPlayerCount() -- If originalGetPlayerCount is defined, that means that this function is executed serverside. -- The next line returns the result of the original function if it's defined. If not, it counts the number of player elements (to also work clientside). return originalGetPlayerCount and originalGetPlayerCount() or #getElementsByType("player") end function textScreenDx () dxDrawText(text, botX+sizeX+380, botX2+sizeX2+600, 50, 50, tocolor(255, 255, 255, 255), 2, "default-bold", "left", "top", false, false, true, true, false) end function respawnText () dxDrawText("Respawning in: #00ff88"..TimesInRespawnText, botX+sizeX+440, botX2+sizeX2+500, 50, 50, tocolor(255, 255, 255, 255), 2, "default-bold", "left", "top", false, false, true, true) end function respawnPlayer () if (getElementData(localPlayer, "MultiGM") == "Hunter" ) and getElementDimension(localPlayer) == 2 then addEventHandler("onClientRender", root, respawnText) setElementData(localPlayer, "Morreu", 1) setTimeSeconds = setTimer ( function () TimesInRespawnText = TimesInRespawnText - 1 if TimesInRespawnText == 0 then removeEventHandler("onClientRender", root, respawnText) killTimer(setTimeSeconds) triggerServerEvent(getResourceName(getThisResource())..": respawnPlayer", localPlayer) TimesInRespawnText = 5 end end, 1000, 0) elseif (getElementData(localPlayer, "MultiGM") == "Hydra") and getElementDimension(localPlayer) == 1 then addEventHandler("onClientRender", root, respawnText) setElementData(localPlayer, "Morreu", 1) setTimeSeconds = setTimer ( function () TimesInRespawnText = TimesInRespawnText - 1 if TimesInRespawnText == 0 then setElementData(localPlayer, "Morreu", 2) removeEventHandler("onClientRender", root, respawnText) killTimer(setTimeSeconds) triggerServerEvent(getResourceName(getThisResource())..": respawnPlayer", localPlayer) TimesInRespawnText = 5 end end, 1000, 0) end end --Tron Progress Bar --local per = 0 --addEventHandler ( 'onClientRender', root, function ( ) -- dxDrawRectangle ( 0, 0, per*2, 20 ) -- if ( per < 100 ) then per = per + 1 end --end ) --local hpMin = 176 --local hpMax = 135 -- local hpRate = hpMin-hpMax -- local hp = hpMin-((getElementHealth(getLocalPlayer())*hpRate)/100) -- dxDrawCircle( 220,796,110, 15,0.01,hp,hpMin,tocolor(255,0,0,255)) addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, respawnPlayer) function textScreen (inp) text = inp addEventHandler("onClientRender", root, textScreenDx) setTimer( function () removeEventHandler("onClientRender", root, textScreenDx) end, 3000, 1) end addEvent(getResourceName(getThisResource())..": textScreen", true) addEventHandler(getResourceName(getThisResource())..": textScreen", root, textScreen) function onClientKey (press, button) if (press) then if (getElementData(localPlayer, "MultiGM") and button == "F1") then cancelEvent() end end end function isCursorOnElement(x,y,w,h) if (not isCursorShowing()) then return false; end local mx, my = getCursorPosition (); cursorx, cursory = mx*sx, my*sy; if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true; else return false; end end Server.lua codes of the arena system: Quote addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), function() local allGreenzones = getElementsByType ("radararea") for i,v in ipairs (allGreenzones) do local r, g, b, a = getRadarAreaColor (v) if (r == 255) and (g == 0) and (b == 0) and (a == 255) then local x, y = getElementPosition (v) local sx, sy = getRadarAreaSize (v) setRadarAreaFlashing(v, true) local col = createColCuboid (x, y, -50, sx, sy, 7500) setElementID (col, "ColShapeMultiGameMode") end end end ) spawnVehPositions = { {-1292.8455810547, -364.38061523438, 15.8}, {-1350.6311035156, -258.98291015625, 14.14396572113}, {-1467.52734375, -190.3069152832, 14.1484375}, {-1620.8626708984, -51.465915679932, 3.5595684051514}, {-1620.2762451172, -590.58685302734, 14.1484375}, } spawnarena2Positionsmilitants = { {789.79999, -2120.3999, 14.1484375}, {795.5, -2228, 15.4}, {795.70001, -2218.8, 15.2}, } spawnarena2Positionsinvaders = { {649.29999, -2409.3, 83}, {623.40002, -2498.3999, 71.9}, {623.70001, -2497.8, 71.9}, } spawnarena2Positionsinsurgents = { {502.20001, -2297.2, 124.6}, {456.60001, -2256.8999, 128.3}, {450.29999, -2258.3, 128.3}, } addEventHandler("onColShapeLeave", root, function (Jogador) if (getElementData(Jogador, "MultiGM") and getElementByID("ColShapeMultiGameMode")) then if (not getElementData(Jogador, "Morreu")) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "#ffffffWarning:-You've crossed the arena boundary!") end removeElementData(Jogador, "MultiGM") end end end ) addEventHandler("onColShapeHit", root, function (Jogador) if (not getElementData(Jogador, "MultiGM")) and getElementByID("ColShapeMultiGameMode") then if ( getElementDimension(Jogador) == 1 ) then setElementData(Jogador, "MultiGM", "Hydra") elseif ( getElementDimension(Jogador) == 2) then setElementData(Jogador, "MultiGM", "Hunter") end end end ) Vehicle = {} function spawnVehMarker (Jogador) if (getElementDimension(Jogador) == 2) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(425, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hunter") elseif ( getElementDimension(Jogador) == 1 ) then if (Vehicle[Jogador] and isElement(Vehicle[Jogador])) then destroyElement(Vehicle[Jogador]) end local x, y, z = getElementPosition(Jogador) Vehicle[Jogador] = createVehicle(520, x, y, z+1) --warpPedIntoVehicle(Jogador, Vehicle[Jogador]) setElementData(Jogador, "MultiGM", "Hydra") end end for _, v in ipairs (spawnVehPositions) do MarkerHunter = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) MarkerHydra = createMarker(v[1], v[2], v[3]+0.6, "checkpoint", 1, 185, 122, 87, 255 ) setElementDimension(MarkerHunter, 2) setElementDimension(MarkerHydra, 1) addEventHandler("onMarkerHit", MarkerHunter, spawnVehMarker) addEventHandler("onMarkerHit", MarkerHydra, spawnVehMarker) end addEvent(getResourceName(getThisResource())..": respawnPlayer", true) addEventHandler(getResourceName(getThisResource())..": respawnPlayer", root, function () if getElementData(source, "Morreu") == 1 then local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) --setElementPosition(source, pX, pY, pZ) local activeteam = getPlayerTeam (source) if activeteam and getTeamName(activeteam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif activeteam and getTeamName(activeteam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif activeteam and getTeamName(activeteam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end setElementDimension(source, 2) removeElementData(source, "Morreu") elseif getElementData(source, "Morreu") == 2 then --local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) removeElementData(source, "Morreu") end end ) local newTeam1 local newTeam2 local newTeam3 local aPlayers = {} addEvent(getResourceName(getThisResource())..": addPlayerHunter", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHunter", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hydra") then removeElementData(source, "MultiGM") end aPlayers[source] = getPlayerTeam (source) local teams = {"Militants","Invaders","Insurgents"} if not getTeamFromName(teams[1]) then newTeam1 = createTeam ( teams[1], 0, 255, 0 ) end if not getTeamFromName(teams[2]) then newTeam2 = createTeam ( teams[2], 100, 0, 20) end if not getTeamFromName(teams[3]) then newTeam3 = createTeam ( teams[3], 50, 100, 50) end local playerTeam = getFewestPlayersTeam() if playerTeam then setPlayerTeam(source, playerTeam) else return end if getTeamName(playerTeam)=="Militants" then local mX, mY, mZ = unpack(spawnarena2Positionsmilitants[math.random(#spawnarena2Positionsmilitants)]) setElementPosition(source, mX, mY, mZ) elseif getTeamName(playerTeam)=="Invaders" then local inX, inY, inZ = unpack(spawnarena2Positionsinvaders[math.random(#spawnarena2Positionsinvaders)]) setElementPosition(source, inX, inY, inZ) elseif getTeamName(playerTeam)=="Insurgents"then local isX, isY, isZ = unpack(spawnarena2Positionsinsurgents[math.random(#spawnarena2Positionsinsurgents)]) setElementPosition(source, isX, isY, isZ) end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Hunter Arena. To exit just type /exitarena") setElementData(source, "MultiGM", "Hunter") --setElementPosition(source, pX, pY, pZ) setElementDimension(source, 2) end ) addEventHandler( "onPlayerQuit", root, function() if aPlayers[source] then aPlayers[source] = nil end end ) function getFewestPlayersTeam() local teams = { newTeam1, newTeam2, newTeam3 } if not teams[1] then return end local teamElement = false local f = 99999 for i=1, 3 do local pcount = countPlayersInTeam( teams[i] ) if pcount < f then f = pcount teamElement = teams[i] end end return teamElement end addEvent(getResourceName(getThisResource())..": addPlayerHydra", true) addEventHandler(getResourceName(getThisResource())..": addPlayerHydra", root, function () if (getPedOccupiedVehicle(source)) then return triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "Get out of your current vehicle to get into GM!") elseif (getElementData(source, "MultiGM") == "Hunter") then elseif (getElementData(source, "MultiGM") == "Hunter") then removeElementData(source, "MultiGM") end triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You entered the Dogfight Arena. To exit just type /exitarena") local pX, pY, pZ = unpack(spawnVehPositions[math.random(#spawnVehPositions)]) setElementData(source, "MultiGM", "Hydra") setElementPosition(source, pX, pY, pZ) setElementDimension(source, 1) end ) addEventHandler("onPlayerWasted", root, function (_, attacker) if (getElementData(source, "MultiGM")) then triggerClientEvent(source, getResourceName(getThisResource())..": respawnPlayer", root) if (attacker) then if (getElementType(attacker) == "player" and getElementData(attacker, "MultiGM")) then triggerClientEvent(attacker, getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(attacker).."!") elseif (getElementType(attacker) == "vehicle" and getElementData(getVehicleOccupant(attacker), "MultiGM")) then triggerClientEvent(getVehicleOccupant(attacker), getResourceName(getThisResource())..": textScreen", root, "You've killed: "..getPlayerName(source).."!") triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "You've been killed by: "..getPlayerName(getVehicleOccupant(attacker)).."!") end else triggerClientEvent(source, getResourceName(getThisResource())..": textScreen", root, "#ffffffYou've committed suicide!") end end end ) addCommandHandler("exitarena", function (Jogador) if (getElementData(Jogador, "MultiGM")) then if Vehicle[Jogador] and isElement(Vehicle[Jogador]) then destroyElement(Vehicle[Jogador]) end removeElementData(Jogador, "MultiGM") setElementDimension(Jogador, 0) killPed(Jogador) triggerClientEvent(Jogador, getResourceName(getThisResource())..": textScreen", root, "You've left the arena successfully!") --local currentteam = getPlayerTeam (Jogador) -- gets the current players team --outputChatBox( "old team: "..tostring(aPlayers[Jogador]) ) --outputChatBox( "old team name: "..tostring(getTeamName(aPlayers[Jogador])) ) setPlayerTeam (Jogador, aPlayers[Jogador]) -- sets the team to the one which the player had previously before joining the arena local count1 = countPlayersInTeam (newTeam1) local count2 = countPlayersInTeam (newTeam2) local count3 = countPlayersInTeam (newTeam3) if count1==0 then destroyElement(newTeam1) outputChatBox ( "Miltants have been eliminated." ) end if count2==0 then destroyElement(newTeam2) outputChatBox ( "Invaders have been eliminated." ) end if count3==0 then destroyElement(newTeam3) outputChatBox ( "Insurgents have been eliminated." ) end end end ) Edited March 9, 2018 by Tron Link to comment
Tron Posted March 9, 2018 Author Share Posted March 9, 2018 Nvm fixed it already, had to pass as function instead of calling in the same line. Thanks alot for helping out buddy i'll let you know if i get more bugs with the arena script. 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now