Jump to content

كود بسيط


ivor

Recommended Posts

السلام عليكم

ابي كود عند الجروب لما يحتل منطقة ياخذ مال و بوينت للقروب وكذا فاهمني ؟

يعنى انا احتليت ارض اخذ 5 بوينت لكل ارض و 5000 كاش

ابيهم مشان اعدل ع الاحتلال حقي وشكرآ

وهاد الداتا او كود الاحتلال

gMoneyTime = 0 
             
setTimer(function() 
    gMoneyTime = gMoneyTime + 1 
    if gMoneyTime == 30 then 
        gMoneyTime = 0 
        for G, X in pairs(getGroupSystemTurf(50)[1]) do 
            local OnlineMember = getGroupOnlineMember(G) 
            local Point = math.floor((5*X)/#OnlineMember) 
            local MoneyPerOnlineMember = math.floor((5000*X)/#OnlineMember) 
            for i, player in ipairs(OnlineMember) do 
                if getElementZoneName(player, true) == "Las Venturas" then 
                    exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00You have earn $ + xp "..MoneyPerOnlineMember.." from your turf.", 0, 255, 0) 
                    setElementData(player, "Point", (getElementData(player, "Point") or 0) + MoneyPerOnlineMember) 
                    setElementData(player, "Money", (getElementData(player, "Money") or 0) + MoneyPerOnlineMember) 
                    triggerClientEvent(player, "gTurfSound", player) 
                end 
            end 
        end 
    end 

Link to comment

سوي بوتين يوم يضغط يفتح له لوحه وفيها قريد ليست

ويمسح كل ال في القريد ليست و يضيف كل القروبات بالنقاط , + استخدم للنقاط داتا

و يرتب الجدول و تسوي لوب و تحطهم في الجدول

وكل لما تحتل خلي يجيك نقاط

عالا حسب العدد

وبس :fadein:

Link to comment

function increaseGroupTurfPoint(groupName) 
    if groupName then 
        dbExec(db, "UPDATE groups SET total_turf = total_turf + 1 WHERE group_name = ?", groupName) 
        setElementData(groupName, "Points", getElementData(groupName, "Points") or 0 + 1) 
    end 
end 
addEvent("onGroupTurf", true) 
addEventHandler("onGroupTurf", root, increaseGroupTurfPoint) 

روح للجروب سيستم و بدل الأيفنت

onGroupTurf

بليسويتو لك الحين

Link to comment
function increaseGroupTurfPoint(groupName) 
    if groupName then 
        dbExec(db, "UPDATE groups SET total_turf = total_turf + 1 WHERE group_name = ?", groupName) 
        setElementData(groupName, "Points", getElementData(groupName, "Points") or 0 + 1) 
    end 
end 
addEvent("onGroupTurf", true) 
addEventHandler("onGroupTurf", root, increaseGroupTurfPoint) 

روح للجروب سيستم و بدل الأيفنت

onGroupTurf

بليسويتو لك الحين

القروبات جداول

من وين جبت الالمنت؟؟؟ :roll:

Link to comment

تفضل

local RadarAreasTurf = {} 
local RadarAreaColTurf = {}
 
local AreaPosition = {
    {aPosX = 1382, aPosY = 903, aSizeX = 115, aSizeY = 220, spawn = {1435, 974, 10.8, 0}},
    {aPosX = 1577.7, aPosY = 883, aSizeX = 180, aSizeY = 240, spawn = {1632, 972, 10.8, 270}},
    {aPosX = 1873, aPosY = 939, aSizeX = 160, aSizeY = 149, spawn = {2022, 1008, 10.8, 270}},
    {aPosX = 1837, aPosY = 1103, aSizeX = 195, aSizeY = 160, spawn = {2012, 1167, 10.8, 270}},
    {aPosX = 2090, aPosY = 882, aSizeX = 60, aSizeY = 85, spawn = {2118, 953, 10.8, 270}},
    {aPosX = 2077, aPosY = 982, aSizeX = 260, aSizeY = 205, spawn = {2183, 1115, 12.6, 60}},
    {aPosX = 2082, aPosY = 1203, aSizeX = 335, aSizeY = 160, spawn = {2233, 1285, 10.8, 90}},
    {aPosX = 971, aPosY = 983, aSizeX = 207, aSizeY = 170, spawn = {1044, 1013, 11, 320}},
    {aPosX = 1018, aPosY = 1203, aSizeX = 159, aSizeY = 160, spawn = {1061, 1259, 10.8, 270}},
    {aPosX = 1017, aPosY = 1383, aSizeX = 160, aSizeY = 321, spawn = {1098, 1604, 12.5, 0}},
    {aPosX = 918, aPosY = 1622, aSizeX = 79.5, aSizeY = 221.3, spawn = {941, 1733, 10.8, 270}},
    {aPosX = 917, aPosY = 1963.3, aSizeX = 81, aSizeY = 221.3, spawn = {971, 2133, 10.8, 270}},
    {aPosX = 1017.7, aPosY = 1837, aSizeX = 160, aSizeY = 207, spawn = {1072, 1915, 10.8, 0}},
    {aPosX = 1018, aPosY = 2064, aSizeX = 160, aSizeY = 219, spawn = {1050, 2122, 10.8, 90}},
    {aPosX = 1287, aPosY = 2066, aSizeX = 186, aSizeY = 180, spawn = {1383, 2187, 11, 180}},
    {aPosX = 1398, aPosY = 2323, aSizeX = 161, aSizeY = 61, spawn = {1500, 2366, 10.8, 0}},
    {aPosX = 1577, aPosY = 2282.5, aSizeX = 180, aSizeY = 130, spawn = {1680, 2321, 10.8, 270}},
    {aPosX = 1250, aPosY = 2516, aSizeX = 350, aSizeY = 115, spawn = {1385, 2523, 10.6, 0}},
    {aPosX = 1698, aPosY = 2720, aSizeX = 220, aSizeY = 165, spawn = {1765, 2860, 10.8, 180}},
    {aPosX = 1778, aPosY = 2564, aSizeX = 200, aSizeY = 120, spawn = {1850, 2583, 10.8, 0}},
    {aPosX = 1833, aPosY = 2282, aSizeX = 95, aSizeY = 190, spawn = {1882, 2339, 11, 270}},
    {aPosX = 1717, aPosY = 2063, aSizeX = 200, aSizeY = 100, spawn = {1764, 2078, 10.8, 180}},
    {aPosX = 2036, aPosY = 2348, aSizeX = 180, aSizeY = 102, spawn = {2127, 2375, 10.8, 180}},
    {aPosX = 2237, aPosY = 2419, aSizeX = 125, aSizeY = 88, spawn = {2341, 2455, 15, 180}},
    {aPosX = 2296, aPosY = 2240, aSizeX = 125, aSizeY = 165, spawn = {2379, 2310, 8.1, 0}},
    {aPosX = 2558.8, aPosY = 2239, aSizeX = 125, aSizeY = 215, spawn = {2631, 2346, 10.7, 210}},
    {aPosX = 2354, aPosY = 903, aSizeX = 185, aSizeY = 168, spawn = {2475, 1022, 10.8, 180}},
    {aPosX = 2436, aPosY = 1080, aSizeX = 165, aSizeY = 285, spawn = {2534, 1125, 10.8, 90}},
    {aPosX = 1837, aPosY = 1284, aSizeX = 195, aSizeY = 163, spawn = {1933, 1342, 10, 270}},
    {aPosX = 1840, aPosY = 1464, aSizeX = 195, aSizeY = 240, spawn = {1969, 1623, 13, 270}},
    {aPosX = 1840, aPosY = 1722, aSizeX = 222, aSizeY = 310, spawn = {1903, 1809, 12.8, 0}},
    {aPosX = 2086, aPosY = 1383, aSizeX = 152, aSizeY = 140, spawn = {2148, 1485, 10.8, 90}},
    {aPosX = 2255, aPosY = 1383, aSizeX = 105, aSizeY = 140, spawn = {2301, 1455, 10.8, 270}},
    {aPosX = 2088, aPosY = 1543, aSizeX = 229, aSizeY = 220, spawn = {2194, 1677, 12.4, 90}},
    {aPosX = 2438, aPosY = 1483, aSizeX = 159, aSizeY = 120, spawn = {2556, 1562, 10.8, 90}},
    {aPosX = 2337.2, aPosY = 1624, aSizeX = 199, aSizeY = 79.5, spawn = {2435, 1673, 10.8, 0}},
    {aPosX = 2558, aPosY = 1624, aSizeX = 119.5, aSizeY = 319, spawn = {2597, 1895, 11, 180}},
    {aPosX = 2517, aPosY = 1962, aSizeX = 160, aSizeY = 260, spawn = {2613, 2169, 10.8, 0}},
    {aPosX = 2436, aPosY = 2240, aSizeX = 85, aSizeY = 167, spawn = {2484, 2357, 10.8, 180}},
    {aPosX = 2135, aPosY = 1784, aSizeX = 270, aSizeY = 99, spawn = {2220, 1838, 10.8, 90}},
    {aPosX = 2160, aPosY = 1904, aSizeX = 170, aSizeY = 110, spawn = {2323, 1991, 5.35, 180}},
    {aPosX = 2160, aPosY = 2033, aSizeX = 170, aSizeY = 95, spawn = {2275, 2039, 10.8, 270}},
    {aPosX = 1285, aPosY = 1217, aSizeX = 80, aSizeY = 90, spawn = {1319, 1252, 10.8, 0}},
   
    -- Lands --
   
    {aPosX = 4285, aPosY = 300, aSizeX = 200, aSizeY = 150, spawn = {4388, 376, 12.1, 0}},
    {aPosX = 3940, aPosY = 914, aSizeX = 165, aSizeY = 218, spawn = {4010, 1004, 14.5, 0}},
    {aPosX = 4495, aPosY = 1217, aSizeX = 165, aSizeY = 130, spawn = {4571, 1279, 12, 0}},
    {aPosX = 3353, aPosY = 1212, aSizeX = 130, aSizeY = 130, spawn = {3404, 1273, 10.8, 0}},
    {aPosX = 3763, aPosY = 1645, aSizeX = 330, aSizeY = 200, spawn = {3944, 1757, 4, 0}},
    {aPosX = 4453, aPosY = 2030, aSizeX = 150, aSizeY = 115, spawn = {4536, 2075, 12.4, 0}},
    {aPosX = 3729, aPosY = 2617, aSizeX = 100, aSizeY = 115, spawn = {3773, 2674, 11, 0}},
}
 
for i, M in ipairs(AreaPosition) do
    local TurfArea = createRadarArea(M["aPosX"], M["aPosY"], M["aSizeX"], M["aSizeY"], 255, 255, 255, 175)
    local TurfAreaCol = createColRectangle(M["aPosX"], M["aPosY"], M["aSizeX"], M["aSizeY"])
    RadarAreasTurf[TurfArea] = {["Loyalty"] = {{"", 0, {255, 255, 255}}, {"", 0, {255, 255, 255}}}, ["WRNNING"] = {}, ["Spawn"] = {false, {M["spawn"][1], M["spawn"][2], M["spawn"][3], M["spawn"][4]}} }
    RadarAreaColTurf[TurfAreaCol] = TurfArea
    addEventHandler("onColShapeHit", TurfAreaCol,
    function(player)
        if getElementType(player) == "player" then
            local Area = RadarAreaColTurf[source]
            local Group = getElementData(player, "GroupSystemystem")
            local oA = RadarAreasTurf[Area]["Loyalty"][1][1]
            local LA = RadarAreasTurf[Area]["Loyalty"][1][2]
            local r1, g1, b1 = RadarAreasTurf[Area]["Loyalty"][1][3][1], RadarAreasTurf[Area]["Loyalty"][1][3][2], RadarAreasTurf[Area]["Loyalty"][1][3][3]
            local oB = RadarAreasTurf[Area]["Loyalty"][2][1]
            local LB = RadarAreasTurf[Area]["Loyalty"][2][2]
            local r2, g2, b2 = RadarAreasTurf[Area]["Loyalty"][2][3][1], RadarAreasTurf[Area]["Loyalty"][2][3][2], RadarAreasTurf[Area]["Loyalty"][2][3][3]
            if oA ~= "" and LA > 0 then setElementData(player, "TurfStat1", {oA..": "..LA.."%", {r1, g1, b1}}) else setElementData(player, "TurfStat1", false) end
            if oB ~= "" and LB > 0 then setElementData(player, "TurfStat2", {oB..": "..LB.."%", {r2, g2, b2}}) else setElementData(player, "TurfStat2", false) end
        end
    end)
    addEventHandler("onColShapeLeave", TurfAreaCol,
    function(player)
        if getElementType(player) == "player" then
            setElementData(player, "TurfStat1", false)
            setElementData(player, "TurfStat2", false)
        end
    end)
end
 
function getGroupSystemTurf(L)
    local Table = {}
    local sTable = {}
    for Col, Area in pairs(RadarAreaColTurf) do
        if RadarAreasTurf[Area]["Loyalty"][1][2] >= L then
            if L == 50 then
                table.insert(Table, {RadarAreasTurf[Area]["Loyalty"][1][1]})
            else
                if RadarAreasTurf[Area]["Spawn"][1] == true then
                    table.insert(sTable, {RadarAreasTurf[Area]["Spawn"][2][1], RadarAreasTurf[Area]["Spawn"][2][2], RadarAreasTurf[Area]["Spawn"][2][3], RadarAreasTurf[Area]["Spawn"][2][4], RadarAreasTurf[Area]["Loyalty"][1][1]})
                end
            end
        elseif RadarAreasTurf[Area]["Loyalty"][2][2] >= L then
            if L == 50 then
                table.insert(Table, {RadarAreasTurf[Area]["Loyalty"][2][1]})
            else
                if RadarAreasTurf[Area]["Spawn"][1] == true then
                    table.insert(sTable, {RadarAreasTurf[Area]["Spawn"][2][1], RadarAreasTurf[Area]["Spawn"][2][2], RadarAreasTurf[Area]["Spawn"][2][3], RadarAreasTurf[Area]["Spawn"][2][4], RadarAreasTurf[Area]["Loyalty"][2][1]})
                end
            end
        end
    end
    local tTable = {}
    for i, M in pairs(Table) do
        if not tTable[M[1]] then
            tTable[M[1]] = 1
        else
            tTable[M[1]] = tTable[M[1]] + 1
        end
    end 
    return {tTable, sTable}
end
 
function getGroupOnlineMember(group)
    local Table = {}
    for i, player in ipairs(getElementsByType("player")) do
        if getElementData(player, "Group") == group then
            table.insert(Table, player)
        end
    end
    return Table
end
 
addEventHandler("onPlayerSpawn", root,
function()
    local Table = {}
    if getElementData(source, "Stats") ~= 0 then return end
    if getElementData(source, "LastTown") ~= "Las Venturas" then return end
    if getPlayerTeam(source) == getTeamFromName("Police") then return end
    local Group = getElementData(source, "Group")
    local Pos = getElementData(source, "LastPosition")
    local x, y, z = Pos[1], Pos[2], Pos[3]
    local Areas = getGroupSystemTurf(90)[2]
    table.insert(Table, {1607.5, 1825.7, 10.8, 0, getDistanceBetweenPoints3D(x, y, z, math.random(1600, 1615), 1825.7, 10.-- s8) -->, "T A P L"})
    for G, X in pairs(Areas) do
        local dist = getDistanceBetweenPoints3D(x, y, z, X[1], X[2], X[3])
        table.insert(Table, {X[1], X[2], X[3], X[4], dist, X[5]})
    end
    if #Table == 0 then return end
    table.sort(Table, function(a,b) return a[5] < b[5] end)
    for i = 1, #Table do
        if Table[i][6] == Group or Table[i][6] == "T A P L" then
            setElementPosition(source, Table[i][1], Table[i][2], Table[i][3])
            setPedRotation(source, Table[i][4])
            setTimer(function(source) setCameraTarget(source) end, 50, 1, source)
            exports["guimessages"]:outputServer(source, "#FF9600[Turf System] #74B3FFYou have been spawned to the closest place of the turf.", 255, 255, 255)
            break
        end
    end
end)
 
addEventHandler("onPlayerWasted", root,
function()
    local x, y, z = getElementPosition(source)
    setElementData(source, "LastPosition", {x, y, z}, false)
    setElementData(source, "LastTown", getElementZoneName(source, true), false)
end)
   
gMoneyTime = 0
           
setTimer(function()
    gMoneyTime = gMoneyTime + 1
    if gMoneyTime == 30 then
        gMoneyTime = 0
        for G, X in pairs(getGroupSystemTurf(50)[1]) do
            local OnlineMember = getGroupOnlineMember(G)
            local Points = math.floor((5*X)/#OnlineMember)
            local MoneyPerOnlineMember = math.floor((5000*X)/#OnlineMember)
            for i, player in ipairs(OnlineMember) do
                if getElementZoneName(player, true) == "Las Venturas" then
                    exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00You have earn $ + xp "..MoneyPerOnlineMember.." from your turf.", 0, 255, 0)
                    setElementData(player, "Points", (getElementData(player, "Points") or 0) + MoneyPerOnlineMember)
                    setElementData(player, "Money", (getElementData(player, "Money") or 0) + MoneyPerOnlineMember)
                    triggerClientEvent(player, "gTurfSound", player)
                end
            end
        end
    end
    for Col, Area in pairs(RadarAreaColTurf) do
        for i, player in ipairs(getElementsWithinColShape(Col, "player")) do
            if isPedDead(player) == false and getElementDimension(player) == 0 and getElementInterior(player) == 0 and getPlayerTeam(player) ~= getTeamFromName("Police") then
                local Group = getElementData(player, "Group")
                if Group then
                    if not isPedInVehicle(player) then
                        local x, y, z = getElementPosition(player)
                            if z < 150 and z >= 1 and not doesPedHaveJetPack(player) then
                            local oA = RadarAreasTurf[Area]["Loyalty"][1][1]
                            local LA = RadarAreasTurf[Area]["Loyalty"][1][2]
                            local r1, g1, b1 = RadarAreasTurf[Area]["Loyalty"][1][3][1], RadarAreasTurf[Area]["Loyalty"][1][3][2], RadarAreasTurf[Area]["Loyalty"][1][3][3]
                            local oB = RadarAreasTurf[Area]["Loyalty"][2][1]
                            local LB = RadarAreasTurf[Area]["Loyalty"][2][2]
                            local r2, g2, b2 = RadarAreasTurf[Area]["Loyalty"][2][3][1], RadarAreasTurf[Area]["Loyalty"][2][3][2], RadarAreasTurf[Area]["Loyalty"][2][3][3]
                            if LA < 75 and LB < 75 then
                                setRadarAreaFlashing(Area, true)
                            else
                                if isRadarAreaFlashing(Area) then
                                    setRadarAreaFlashing(Area, false)
                                    RadarAreasTurf[Area]["WRNNING"] = {}
                                end
                            end
                            if RadarAreasTurf[Area]["WRNNING"][Group] == nil then
                                if oA ~= Group and LA > 50 and LA < 75 then
                                    RadarAreasTurf[Area]["WRNNING"][Group] = true
                                    for i, p in ipairs(getGroupOnlineMember(oA)) do
                                        exports["guimessages"]:outputServer(p, "#FF9600[Turf System] #FF0000Warning: #FF9100one of your turf is under attack from "..Group..".", 25, 255, 100)
                                    end
                                elseif oB ~= Group and LB > 50 and LB < 75 then
                                    RadarAreasTurf[Area]["WRNNING"][Group] = true
                                    for i, p in ipairs(getGroupOnlineMember(oB)) do
                                        exports["guimessages"]:outputServer(p, "#FF9600[Turf System] #FF0000Warning: #FF9100one of your turf is under attack from "..Group..".", 25, 255, 100)
                                    end
                                end
                            end
                            if LA < 90 and LB < 90 then
                                RadarAreasTurf[Area]["Spawn"][1] = false
                            end
                            if LA >= 51 and oA == Group then
                                if LA == 51 then
                                    for i, player in ipairs(getGroupOnlineMember(Group)) do
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FFFFCongratulations, your gang now controls the turf!", 25, 255, 100)
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00Online gang members will earn $5000 (divided) every 5 minutes.", 25, 255, 50)
                                        playSoundFrontEnd(player, 101)
                                    end
                                elseif LA == 100 and not RadarAreasTurf[Area]["Spawn"][1] then
                                    RadarAreasTurf[Area]["Spawn"][1] = true
                                end
                                setRadarAreaColor(Area, r1, g1, b1, 175)
                            elseif LB >= 51 and oB == Group then
                                if LB == 51 then
                                    for i, player in ipairs(getGroupOnlineMember(Group)) do
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FFFFCongratulations, your gang now controls the turf!", 25, 255, 100)
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00Online gang members will earn $5000 (divided) every 5 minutes.", 25, 255, 50)
                                        playSoundFrontEnd(player, 101)
                                    end
                                elseif LB == 100 and not RadarAreasTurf[Area]["Spawn"][1] then
                                    RadarAreasTurf[Area]["Spawn"][1] = true
                                end
                                setRadarAreaColor(Area, r2, g2, b2, 175)
                            end
                            if oA == "" and oB == "" then
                                RadarAreasTurf[Area]["Loyalty"][1][1] = Group
                                RadarAreasTurf[Area]["Loyalty"][1][2] = RadarAreasTurf[Area]["Loyalty"][1][2] + 1
                               
Link to comment
تفضل
local RadarAreasTurf = {} 
local RadarAreaColTurf = {}
 
local AreaPosition = {
    {aPosX = 1382, aPosY = 903, aSizeX = 115, aSizeY = 220, spawn = {1435, 974, 10.8, 0}},
    {aPosX = 1577.7, aPosY = 883, aSizeX = 180, aSizeY = 240, spawn = {1632, 972, 10.8, 270}},
    {aPosX = 1873, aPosY = 939, aSizeX = 160, aSizeY = 149, spawn = {2022, 1008, 10.8, 270}},
    {aPosX = 1837, aPosY = 1103, aSizeX = 195, aSizeY = 160, spawn = {2012, 1167, 10.8, 270}},
    {aPosX = 2090, aPosY = 882, aSizeX = 60, aSizeY = 85, spawn = {2118, 953, 10.8, 270}},
    {aPosX = 2077, aPosY = 982, aSizeX = 260, aSizeY = 205, spawn = {2183, 1115, 12.6, 60}},
    {aPosX = 2082, aPosY = 1203, aSizeX = 335, aSizeY = 160, spawn = {2233, 1285, 10.8, 90}},
    {aPosX = 971, aPosY = 983, aSizeX = 207, aSizeY = 170, spawn = {1044, 1013, 11, 320}},
    {aPosX = 1018, aPosY = 1203, aSizeX = 159, aSizeY = 160, spawn = {1061, 1259, 10.8, 270}},
    {aPosX = 1017, aPosY = 1383, aSizeX = 160, aSizeY = 321, spawn = {1098, 1604, 12.5, 0}},
    {aPosX = 918, aPosY = 1622, aSizeX = 79.5, aSizeY = 221.3, spawn = {941, 1733, 10.8, 270}},
    {aPosX = 917, aPosY = 1963.3, aSizeX = 81, aSizeY = 221.3, spawn = {971, 2133, 10.8, 270}},
    {aPosX = 1017.7, aPosY = 1837, aSizeX = 160, aSizeY = 207, spawn = {1072, 1915, 10.8, 0}},
    {aPosX = 1018, aPosY = 2064, aSizeX = 160, aSizeY = 219, spawn = {1050, 2122, 10.8, 90}},
    {aPosX = 1287, aPosY = 2066, aSizeX = 186, aSizeY = 180, spawn = {1383, 2187, 11, 180}},
    {aPosX = 1398, aPosY = 2323, aSizeX = 161, aSizeY = 61, spawn = {1500, 2366, 10.8, 0}},
    {aPosX = 1577, aPosY = 2282.5, aSizeX = 180, aSizeY = 130, spawn = {1680, 2321, 10.8, 270}},
    {aPosX = 1250, aPosY = 2516, aSizeX = 350, aSizeY = 115, spawn = {1385, 2523, 10.6, 0}},
    {aPosX = 1698, aPosY = 2720, aSizeX = 220, aSizeY = 165, spawn = {1765, 2860, 10.8, 180}},
    {aPosX = 1778, aPosY = 2564, aSizeX = 200, aSizeY = 120, spawn = {1850, 2583, 10.8, 0}},
    {aPosX = 1833, aPosY = 2282, aSizeX = 95, aSizeY = 190, spawn = {1882, 2339, 11, 270}},
    {aPosX = 1717, aPosY = 2063, aSizeX = 200, aSizeY = 100, spawn = {1764, 2078, 10.8, 180}},
    {aPosX = 2036, aPosY = 2348, aSizeX = 180, aSizeY = 102, spawn = {2127, 2375, 10.8, 180}},
    {aPosX = 2237, aPosY = 2419, aSizeX = 125, aSizeY = 88, spawn = {2341, 2455, 15, 180}},
    {aPosX = 2296, aPosY = 2240, aSizeX = 125, aSizeY = 165, spawn = {2379, 2310, 8.1, 0}},
    {aPosX = 2558.8, aPosY = 2239, aSizeX = 125, aSizeY = 215, spawn = {2631, 2346, 10.7, 210}},
    {aPosX = 2354, aPosY = 903, aSizeX = 185, aSizeY = 168, spawn = {2475, 1022, 10.8, 180}},
    {aPosX = 2436, aPosY = 1080, aSizeX = 165, aSizeY = 285, spawn = {2534, 1125, 10.8, 90}},
    {aPosX = 1837, aPosY = 1284, aSizeX = 195, aSizeY = 163, spawn = {1933, 1342, 10, 270}},
    {aPosX = 1840, aPosY = 1464, aSizeX = 195, aSizeY = 240, spawn = {1969, 1623, 13, 270}},
    {aPosX = 1840, aPosY = 1722, aSizeX = 222, aSizeY = 310, spawn = {1903, 1809, 12.8, 0}},
    {aPosX = 2086, aPosY = 1383, aSizeX = 152, aSizeY = 140, spawn = {2148, 1485, 10.8, 90}},
    {aPosX = 2255, aPosY = 1383, aSizeX = 105, aSizeY = 140, spawn = {2301, 1455, 10.8, 270}},
    {aPosX = 2088, aPosY = 1543, aSizeX = 229, aSizeY = 220, spawn = {2194, 1677, 12.4, 90}},
    {aPosX = 2438, aPosY = 1483, aSizeX = 159, aSizeY = 120, spawn = {2556, 1562, 10.8, 90}},
    {aPosX = 2337.2, aPosY = 1624, aSizeX = 199, aSizeY = 79.5, spawn = {2435, 1673, 10.8, 0}},
    {aPosX = 2558, aPosY = 1624, aSizeX = 119.5, aSizeY = 319, spawn = {2597, 1895, 11, 180}},
    {aPosX = 2517, aPosY = 1962, aSizeX = 160, aSizeY = 260, spawn = {2613, 2169, 10.8, 0}},
    {aPosX = 2436, aPosY = 2240, aSizeX = 85, aSizeY = 167, spawn = {2484, 2357, 10.8, 180}},
    {aPosX = 2135, aPosY = 1784, aSizeX = 270, aSizeY = 99, spawn = {2220, 1838, 10.8, 90}},
    {aPosX = 2160, aPosY = 1904, aSizeX = 170, aSizeY = 110, spawn = {2323, 1991, 5.35, 180}},
    {aPosX = 2160, aPosY = 2033, aSizeX = 170, aSizeY = 95, spawn = {2275, 2039, 10.8, 270}},
    {aPosX = 1285, aPosY = 1217, aSizeX = 80, aSizeY = 90, spawn = {1319, 1252, 10.8, 0}},
   
    -- Lands --
   
    {aPosX = 4285, aPosY = 300, aSizeX = 200, aSizeY = 150, spawn = {4388, 376, 12.1, 0}},
    {aPosX = 3940, aPosY = 914, aSizeX = 165, aSizeY = 218, spawn = {4010, 1004, 14.5, 0}},
    {aPosX = 4495, aPosY = 1217, aSizeX = 165, aSizeY = 130, spawn = {4571, 1279, 12, 0}},
    {aPosX = 3353, aPosY = 1212, aSizeX = 130, aSizeY = 130, spawn = {3404, 1273, 10.8, 0}},
    {aPosX = 3763, aPosY = 1645, aSizeX = 330, aSizeY = 200, spawn = {3944, 1757, 4, 0}},
    {aPosX = 4453, aPosY = 2030, aSizeX = 150, aSizeY = 115, spawn = {4536, 2075, 12.4, 0}},
    {aPosX = 3729, aPosY = 2617, aSizeX = 100, aSizeY = 115, spawn = {3773, 2674, 11, 0}},
}
 
for i, M in ipairs(AreaPosition) do
    local TurfArea = createRadarArea(M["aPosX"], M["aPosY"], M["aSizeX"], M["aSizeY"], 255, 255, 255, 175)
    local TurfAreaCol = createColRectangle(M["aPosX"], M["aPosY"], M["aSizeX"], M["aSizeY"])
    RadarAreasTurf[TurfArea] = {["Loyalty"] = {{"", 0, {255, 255, 255}}, {"", 0, {255, 255, 255}}}, ["WRNNING"] = {}, ["Spawn"] = {false, {M["spawn"][1], M["spawn"][2], M["spawn"][3], M["spawn"][4]}} }
    RadarAreaColTurf[TurfAreaCol] = TurfArea
    addEventHandler("onColShapeHit", TurfAreaCol,
    function(player)
        if getElementType(player) == "player" then
            local Area = RadarAreaColTurf[source]
            local Group = getElementData(player, "GroupSystemystem")
            local oA = RadarAreasTurf[Area]["Loyalty"][1][1]
            local LA = RadarAreasTurf[Area]["Loyalty"][1][2]
            local r1, g1, b1 = RadarAreasTurf[Area]["Loyalty"][1][3][1], RadarAreasTurf[Area]["Loyalty"][1][3][2], RadarAreasTurf[Area]["Loyalty"][1][3][3]
            local oB = RadarAreasTurf[Area]["Loyalty"][2][1]
            local LB = RadarAreasTurf[Area]["Loyalty"][2][2]
            local r2, g2, b2 = RadarAreasTurf[Area]["Loyalty"][2][3][1], RadarAreasTurf[Area]["Loyalty"][2][3][2], RadarAreasTurf[Area]["Loyalty"][2][3][3]
            if oA ~= "" and LA > 0 then setElementData(player, "TurfStat1", {oA..": "..LA.."%", {r1, g1, b1}}) else setElementData(player, "TurfStat1", false) end
            if oB ~= "" and LB > 0 then setElementData(player, "TurfStat2", {oB..": "..LB.."%", {r2, g2, b2}}) else setElementData(player, "TurfStat2", false) end
        end
    end)
    addEventHandler("onColShapeLeave", TurfAreaCol,
    function(player)
        if getElementType(player) == "player" then
            setElementData(player, "TurfStat1", false)
            setElementData(player, "TurfStat2", false)
        end
    end)
end
 
function getGroupSystemTurf(L)
    local Table = {}
    local sTable = {}
    for Col, Area in pairs(RadarAreaColTurf) do
        if RadarAreasTurf[Area]["Loyalty"][1][2] >= L then
            if L == 50 then
                table.insert(Table, {RadarAreasTurf[Area]["Loyalty"][1][1]})
            else
                if RadarAreasTurf[Area]["Spawn"][1] == true then
                    table.insert(sTable, {RadarAreasTurf[Area]["Spawn"][2][1], RadarAreasTurf[Area]["Spawn"][2][2], RadarAreasTurf[Area]["Spawn"][2][3], RadarAreasTurf[Area]["Spawn"][2][4], RadarAreasTurf[Area]["Loyalty"][1][1]})
                end
            end
        elseif RadarAreasTurf[Area]["Loyalty"][2][2] >= L then
            if L == 50 then
                table.insert(Table, {RadarAreasTurf[Area]["Loyalty"][2][1]})
            else
                if RadarAreasTurf[Area]["Spawn"][1] == true then
                    table.insert(sTable, {RadarAreasTurf[Area]["Spawn"][2][1], RadarAreasTurf[Area]["Spawn"][2][2], RadarAreasTurf[Area]["Spawn"][2][3], RadarAreasTurf[Area]["Spawn"][2][4], RadarAreasTurf[Area]["Loyalty"][2][1]})
                end
            end
        end
    end
    local tTable = {}
    for i, M in pairs(Table) do
        if not tTable[M[1]] then
            tTable[M[1]] = 1
        else
            tTable[M[1]] = tTable[M[1]] + 1
        end
    end 
    return {tTable, sTable}
end
 
function getGroupOnlineMember(group)
    local Table = {}
    for i, player in ipairs(getElementsByType("player")) do
        if getElementData(player, "Group") == group then
            table.insert(Table, player)
        end
    end
    return Table
end
 
addEventHandler("onPlayerSpawn", root,
function()
    local Table = {}
    if getElementData(source, "Stats") ~= 0 then return end
    if getElementData(source, "LastTown") ~= "Las Venturas" then return end
    if getPlayerTeam(source) == getTeamFromName("Police") then return end
    local Group = getElementData(source, "Group")
    local Pos = getElementData(source, "LastPosition")
    local x, y, z = Pos[1], Pos[2], Pos[3]
    local Areas = getGroupSystemTurf(90)[2]
    table.insert(Table, {1607.5, 1825.7, 10.8, 0, getDistanceBetweenPoints3D(x, y, z, math.random(1600, 1615), 1825.7, 10.-- s8) -->, "T A P L"})
    for G, X in pairs(Areas) do
        local dist = getDistanceBetweenPoints3D(x, y, z, X[1], X[2], X[3])
        table.insert(Table, {X[1], X[2], X[3], X[4], dist, X[5]})
    end
    if #Table == 0 then return end
    table.sort(Table, function(a,b) return a[5] < b[5] end)
    for i = 1, #Table do
        if Table[i][6] == Group or Table[i][6] == "T A P L" then
            setElementPosition(source, Table[i][1], Table[i][2], Table[i][3])
            setPedRotation(source, Table[i][4])
            setTimer(function(source) setCameraTarget(source) end, 50, 1, source)
            exports["guimessages"]:outputServer(source, "#FF9600[Turf System] #74B3FFYou have been spawned to the closest place of the turf.", 255, 255, 255)
            break
        end
    end
end)
 
addEventHandler("onPlayerWasted", root,
function()
    local x, y, z = getElementPosition(source)
    setElementData(source, "LastPosition", {x, y, z}, false)
    setElementData(source, "LastTown", getElementZoneName(source, true), false)
end)
   
gMoneyTime = 0
           
setTimer(function()
    gMoneyTime = gMoneyTime + 1
    if gMoneyTime == 30 then
        gMoneyTime = 0
        for G, X in pairs(getGroupSystemTurf(50)[1]) do
            local OnlineMember = getGroupOnlineMember(G)
            local Points = math.floor((5*X)/#OnlineMember)
            local MoneyPerOnlineMember = math.floor((5000*X)/#OnlineMember)
            for i, player in ipairs(OnlineMember) do
                if getElementZoneName(player, true) == "Las Venturas" then
                    exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00You have earn $ + xp "..MoneyPerOnlineMember.." from your turf.", 0, 255, 0)
                    setElementData(player, "Points", (getElementData(player, "Points") or 0) + MoneyPerOnlineMember)
                    setElementData(player, "Money", (getElementData(player, "Money") or 0) + MoneyPerOnlineMember)
                    triggerClientEvent(player, "gTurfSound", player)
                end
            end
        end
    end
    for Col, Area in pairs(RadarAreaColTurf) do
        for i, player in ipairs(getElementsWithinColShape(Col, "player")) do
            if isPedDead(player) == false and getElementDimension(player) == 0 and getElementInterior(player) == 0 and getPlayerTeam(player) ~= getTeamFromName("Police") then
                local Group = getElementData(player, "Group")
                if Group then
                    if not isPedInVehicle(player) then
                        local x, y, z = getElementPosition(player)
                            if z < 150 and z >= 1 and not doesPedHaveJetPack(player) then
                            local oA = RadarAreasTurf[Area]["Loyalty"][1][1]
                            local LA = RadarAreasTurf[Area]["Loyalty"][1][2]
                            local r1, g1, b1 = RadarAreasTurf[Area]["Loyalty"][1][3][1], RadarAreasTurf[Area]["Loyalty"][1][3][2], RadarAreasTurf[Area]["Loyalty"][1][3][3]
                            local oB = RadarAreasTurf[Area]["Loyalty"][2][1]
                            local LB = RadarAreasTurf[Area]["Loyalty"][2][2]
                            local r2, g2, b2 = RadarAreasTurf[Area]["Loyalty"][2][3][1], RadarAreasTurf[Area]["Loyalty"][2][3][2], RadarAreasTurf[Area]["Loyalty"][2][3][3]
                            if LA < 75 and LB < 75 then
                                setRadarAreaFlashing(Area, true)
                            else
                                if isRadarAreaFlashing(Area) then
                                    setRadarAreaFlashing(Area, false)
                                    RadarAreasTurf[Area]["WRNNING"] = {}
                                end
                            end
                            if RadarAreasTurf[Area]["WRNNING"][Group] == nil then
                                if oA ~= Group and LA > 50 and LA < 75 then
                                    RadarAreasTurf[Area]["WRNNING"][Group] = true
                                    for i, p in ipairs(getGroupOnlineMember(oA)) do
                                        exports["guimessages"]:outputServer(p, "#FF9600[Turf System] #FF0000Warning: #FF9100one of your turf is under attack from "..Group..".", 25, 255, 100)
                                    end
                                elseif oB ~= Group and LB > 50 and LB < 75 then
                                    RadarAreasTurf[Area]["WRNNING"][Group] = true
                                    for i, p in ipairs(getGroupOnlineMember(oB)) do
                                        exports["guimessages"]:outputServer(p, "#FF9600[Turf System] #FF0000Warning: #FF9100one of your turf is under attack from "..Group..".", 25, 255, 100)
                                    end
                                end
                            end
                            if LA < 90 and LB < 90 then
                                RadarAreasTurf[Area]["Spawn"][1] = false
                            end
                            if LA >= 51 and oA == Group then
                                if LA == 51 then
                                    for i, player in ipairs(getGroupOnlineMember(Group)) do
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FFFFCongratulations, your gang now controls the turf!", 25, 255, 100)
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00Online gang members will earn $5000 (divided) every 5 minutes.", 25, 255, 50)
                                        playSoundFrontEnd(player, 101)
                                    end
                                elseif LA == 100 and not RadarAreasTurf[Area]["Spawn"][1] then
                                    RadarAreasTurf[Area]["Spawn"][1] = true
                                end
                                setRadarAreaColor(Area, r1, g1, b1, 175)
                            elseif LB >= 51 and oB == Group then
                                if LB == 51 then
                                    for i, player in ipairs(getGroupOnlineMember(Group)) do
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FFFFCongratulations, your gang now controls the turf!", 25, 255, 100)
                                        exports["guimessages"]:outputServer(player, "#FF9600[Turf System] #00FF00Online gang members will earn $5000 (divided) every 5 minutes.", 25, 255, 50)
                                        playSoundFrontEnd(player, 101)
                                    end
                                elseif LB == 100 and not RadarAreasTurf[Area]["Spawn"][1] then
                                    RadarAreasTurf[Area]["Spawn"][1] = true
                                end
                                setRadarAreaColor(Area, r2, g2, b2, 175)
                            end
                            if oA == "" and oB == "" then
                                RadarAreasTurf[Area]["Loyalty"][1][1] = Group
                                RadarAreasTurf
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...