Jump to content

[HELP]Turf


Best-Killer1

Recommended Posts

when player take turf he don't get stars :/ how i can make it ?? this codes :

Server-Side :

local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                    else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                        end
                    end
                   
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
            }
 
       
Link to comment

serve-side :

function giveWantedPoints ( p, amount ) 
    if ( p and isElement ( p ) and tonumber ( amount ) ) then 
        local amount = tonumber ( amount ) 
        local wl = tonumber ( getElementData ( p, "WantedPoints" ) ) 
        setElementData ( p, "WantedPoints", tonumber ( wl ) + amount )  
        return true 
    end 
    return false 
end 
  
addEventHandler ( "onPlayerDamage", root, function ( p, weap, loss ) 
    if ( isElement ( p ) and p ~= source ) then 
  
        local x, y, z = getElementPosition ( source ) 
        --if ( getZoneName ( x, y, z, true ) == "Las Venturas" ) then return end 
  
        if ( getElementData ( source, "SAEGEvents:IsPlayerInEvent" ) or getElementData ( p, "SAEGEvents:IsPlayerInEvent" ) ) then 
            return 
        end 
         
        if ( getElementType ( p ) == 'vehicle' ) then 
            if ( getVehicleOccupant ( p ) ) then 
                p = getVehicleOccupant ( p ) 
            else 
                return  
            end 
        end 
  
        local t = getPlayerTeam ( p ) 
        if t then 
            local t = tostring ( getTeamName ( t ) ) 
            if weap then 
                if ( t == "Emergency" and getElementHealth ( source ) < 100 and weap == 14 ) then 
                    if ( getElementData ( p, "Job" ) == "Medic" ) then 
                        return 
                    end 
                elseif ( exports['SAEGPlayerFunctions']:isTeamLaw ( t ) and ( weap == 3 or weap == 23 ) and getPlayerWantedLevel ( source ) > 0 ) then 
                    return 
                end 
            end 
        end 
        giveWantedPoints ( p, math.floor ( loss * 3 ) ) 
    end 
end ) 
  
local ticks = 0 
local tickChange = 50 
setTimer ( function ( ) 
    ticks = ticks + 1 
    for i, v in ipairs ( getElementsByType ( 'player' ) ) do  
        if ( not getElementData ( v, "SAEGJobs:ArrestingOfficer" ) and not getElementData ( v, "isPlayerJailed" ) ) then 
            local wl = tonumber ( getElementData ( v, "WantedPoints" ) ) or 0 
            if ( wl >= 600 ) then 
                setPlayerWantedLevel ( v, 6 ) 
            elseif ( wl >= 450 ) then 
                setPlayerWantedLevel ( v, 5 ) 
            elseif ( wl >= 320 ) then 
                setPlayerWantedLevel ( v, 4 ) 
            elseif ( wl >= 210 ) then 
                setPlayerWantedLevel ( v, 3 ) 
            elseif ( wl >= 100 ) then 
                setPlayerWantedLevel ( v, 2 ) 
            elseif ( wl > 0 ) then 
                setPlayerWantedLevel ( v, 1 ) 
            elseif ( wl <= 0 ) then  
                setPlayerWantedLevel ( v, 0 ) 
            end 
            if ( ticks >= tickChange ) then 
                setElementData ( v, "WantedPoints", wl - 1 ) 
                if ( wl - 1 < 0 ) then 
                    setElementData ( v, "WantedPoints", 0 ) 
                end 
            end 
        end 
         
        if ( getPlayerWantedLevel ( v ) > 0 ) then 
            setPlayerNametagText ( v, tostring ( getPlayerName ( v ) ).."["..tostring ( getPlayerWantedLevel ( v ) ).."]" ) 
        else 
            setPlayerNametagText ( v, tostring ( getPlayerName ( v ) ) ) 
        end 
         
        local job = getElementData ( v, "Job" ) 
        if job  then 
            local max_ = max_wanted[getJobType(job)] or 7 
            local w_l = getPlayerWantedLevel ( v ) 
            if ( w_l ~= 0 and w_l > max_ ) then 
                exports['SAEGMessages']:sendClientMessage ( "You've been resigned for having a high wanted level.", v, 255, 255, 0 ) 
                resignPlayer ( v ) 
            end 
        end 
    end 
end, 3000, 0 ) 

client_side:

function giveWantedPoints ( amount ) 
    if (tonumber ( amount ) ) then 
        local amount = tonumber ( amount ) 
        local wl = tonumber ( getElementData ( localPlayer, "WantedPoints" ) ) 
        return setElementData ( localPlayer, "WantedPoints", wl + amount )   
    end 
    return false 
end 

Link to comment
local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                    else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                        setElementData ( source, "WantedPoints",100 )  
                        end
                    end
                   
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
            }
 
Link to comment
You've to do an export for this wanted system to works correctly

like that ? :

                    else 
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1 
                        if ( turfLocs[id].attackProg == 100 ) then 
                            setTurfOwner ( id, turfLocs[id].attackers ) 
                        setElementData ( source, "WantedPoints",100 )   
            return exports.SAEGPolice:giveWantedPoints  
                        end 
                    end 
        end 

Link to comment

Logically,this will make no sence

exports.SAEGPolice:giveWantedPoints 

Try this part

           else 
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1 
                        if ( turfLocs[id].attackProg == 100 ) then 
                            setTurfOwner ( id, turfLocs[id].attackers ) 
                          exports.SAEGPolice:giveWantedPoints(source,120) 
                        end 
                    end 
        end 

Link to comment
-- Attack War 
                       else 
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1 
                        if ( turfLocs[id].attackProg == 100 ) then 
                            setTurfOwner ( id, turfLocs[id].attackers ) 
                            return exports.SAEGPolice:giveWantedPoints(source,120) 
                        end 
                    end 
                end 

error : SAEGTurf/Server.lua133:'end' expected (to close if at line 110) near else

Link to comment
Post full code..
local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                       else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                            return exports.SAEGPolice:giveWantedPoints(source,120)
                        end
                    end
                end
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
            }
 
Link to comment
local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                    else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                            exports.SAEGPolice:giveWantedPoints(source,120)
                        end
                    end
                   
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
            }
 
Link to comment
local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                    else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                            exports.SAEGPolice:giveWantedPoints(source,120)
                        end
                    end
                   
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
Link to comment
local _setElementData = setElementData 
function setElementData ( element, group, value )
    return _setElementData ( element, group, value, true )
end
 
local turfLocs = { }
function createTurf ( x, y, z, width, height, owner, forcedId )
    local owner = tostring ( owner or "server" )
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    if not r then r = 255 end
    if not g then g = 255 end
    if not b then b = 255 end
 
    if ( owner == "server" ) then
        r, g, b = 255, 255, 255
    end
 
    local rad = createRadarArea ( x, y, width, height, r, g, b, 170, getRootElement ( ) )
    local col = createColCuboid ( x, y, z-5, width, height, 35)
    if ( not forcedId or turfLocs [ id ] ) then
        id = 0
        while ( turfLocs [ id ] ) do
            id = id + 1
        end
    else
        id = forcedId
    end
 
    turfLocs[id] = { }
    turfLocs[id].col = col
    turfLocs[id].radar = rad
    turfLocs[id].owner = owner or "server"
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    turfLocs[id].prepProg = 0
    setElementData ( turfLocs[id].col, "SAEGTurf:TurfId", id )
    setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
    addEventHandler ( "onColShapeHit", turfLocs[id].col, onColShapeHit )
    addEventHandler ( "onColShapeLeave", turfLocs[id].col, onColShapeLeave )
    return turfLocs[id];
end
 
function updateTurfGroupColor ( group )
    local r, g, b = exports.saeggroups:getGroupColor ( group )
    for i, v in pairs ( turfLocs ) do
        if ( v.owner == group ) then
            setRadarAreaColor ( v.radar, r, g, b, 120 )
        end
    end
end
 
 
 
 
 
function onColShapeHit ( player )
    if ( player and isElement ( player ) and getElementType ( player ) == "player" and not isPedInVehicle ( player ) ) then
        local gang = exports.saeggroups:getPlayerGroup ( player )
       if getTeamName(getPlayerTeam(player)) ~= "Criminals" then exports['SAEGMessages']:sendClientMessage("You must be criminal.",255,0,0) return end
        triggerClientEvent ( player, "SAEGTurfs:onClientEnterTurfArea", player, turfLocs [ id ] )
        if ( not gang ) then
            return exports.SAEGMessages:sendClientMessage ( "You're not in a gang, you cannot turf.", player, 255, 255, 0 )
        end
 
        local id = tonumber ( getElementData ( source, "SAEGTurf:TurfId" ) )
        if ( turfLocs[id].owner == gang ) then
            return
        end
 
        if ( turfLocs[id].attackers and turfLocs[id].attackers ~= gang ) then
        end
 
        if ( not turfLocs[id].attackers ) then
           
            local x, y, z = getElementPosition ( source )
            setRadarAreaFlashing ( turfLocs[id].radar, true )
            turfLocs[id].attackers = gang
            turfLocs[id].attackProg = 0
            turfLocs[id].prepProg = 0
            setElementData ( turfLocs[id].col, "SAEGTurf:TurffingTable", turfLocs [ id ] )
        end
    end
end
 
function onColShapeLeave ( player )
    if ( player and getElementType ( player ) == "player" ) then
        triggerClientEvent ( player, "SAEGTurfs:onClientExitTurfArea", player, turfLocs [ getElementData ( source, "SAEGTurf:TurfId" ) ] )
    end
end
 
 
setTimer ( function ( )
    for id, data in pairs ( turfLocs ) do
        if ( data.attackers ) then
            local players = { attackers = { }, owners = { } }
            local isGangInTurf = false
            local isOwnerInTurf = false
            for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do
                local g = exports.SAEGGroups:getPlayerGroup ( v )
                if ( g == data.attackers ) then
                    isGangInTurf = true
                    table.insert ( players.attackers, v )
                elseif ( g == data.owner ) then
                    isOwnerInTurf = true
                    table.insert ( players.owners, v )
                end
            end
 
            local x, y, z = getElementPosition ( data.col )
            if ( isOwnerInTurf and isGangInTurf ) then
 
            else
                -- Add Points To Attackers
                if ( isGangInTurf ) then
                    -- Prep the war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg + 2
                        if ( turfLocs[id].prepProg >= 100 ) then
                            turfLocs[id].prepProg = 0
                            turfLocs[id].attackProg = 1
                            beginTurfWarOnTurf ( id )
                        end
                    -- Attack War
                    else
                        turfLocs[id].attackProg = turfLocs[id].attackProg + 1
                        if ( turfLocs[id].attackProg == 100 ) then
                            setTurfOwner ( id, turfLocs[id].attackers )
                            exports['SAEGPolice']:giveWantedPoints(source,120)
                        end
                    end
                   
                -- Take points from attackers
                else
                    -- Prepare war
                    if ( turfLocs[id].attackProg == 0 ) then
                        turfLocs[id].prepProg = data.prepProg - 2
                        if ( turfLocs[id].prepProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    -- Attacking war
                    else
                        turfLocs[id].attackProg = data.attackProg - 1
                        if ( turfLocs[id].attackProg <= 0 ) then
                            setTurfOwner ( id, turfLocs[id].owner )
                        end
                    end
                end
            end
            for i, v in pairs ( players ) do
                for k, p in pairs ( v ) do
                    triggerClientEvent ( p, "SAEGTurfs:upadateClientInfo", p, turfLocs [ id ] )
                end
            end
        end
    end
end, 800, 0 )
addEvent ( "SAEGTurfs:onTurfProgressChange", true )
 
--[[
addCommandHandler ( "attackprog", function ( p )
    local gangAttacks = { }
    local g = exports.SAEGGroups:getPlayerGroup ( p )
    if ( not g ) then
        return exports.SAEGMessages:sendclientMessage ( "You're not in a gang", p, 255, 255, 0)
    end
 
    for i, v in pairs ( turfLocs ) do
        if ( v.attackers and v.attackers == g ) then
            gangAttacks [ i ] = true
        end
    end
 
    if ( table.len ( gangAttacks ) == 0 ) then
        return exports.SAEGMessages:sendClientMessage ( "Your gang isn't involved in any gang wars right now.", p, 255, 255, 0 )
    end
 
    for id, _ in pairs ( gangAttacks ) do
        local x ,y, z = getElementPosition ( turfLocs[id].col )
        outputChatBox ( "----Turf War Status---", p, 255, 255, 255, false )
        outputChatBox ( "Current owner: "..turfLocs[id].owner, p, 255, 255, 255, false )
        outputChatBox ( "Attacker: "..turfLocs[id].attackers, p, 255, 255, 255, false )
        outputChatBox ( "Prep Progress: "..turfLocs[id].prepProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Attack Progress: "..turfLocs[id].attackProg.."%", p, 255, 255, 255, false )
        outputChatBox ( "Turf Location: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), p, 255, 255, 255, false )
        outputChatBox ( "Turf Server-ID: "..id, p, 255, 255, 255, false )
    end
 
end )]]
 
function table.len ( tb )
    local c = 0
    for i, v in pairs ( tb ) do
        c = c + 1
    end
    return c
end
 
function beginTurfWarOnTurf ( id )
    local d = turfLocs [ id ]
    local x, y, z = getElementPosition ( d.col )
    setRadarAreaColor ( d.radar, 255, 255, 255, 170 )
end
 
function setTurfOwner ( id, owner )
    setRadarAreaFlashing ( turfLocs[id].radar, false )
    turfLocs[id].owner = owner
    turfLocs[id].attackers = nil
    turfLocs[id].attackProg = 0
    local r, g, b = exports.SAEGGroups:getGroupColor ( owner )
    setRadarAreaColor ( turfLocs[id].radar, r, g, b, 120 )
    saveTurfs ( )
end
 
function getTurfs ( )
    return turfLocs
end
 
function saveTurfs ( )
    for id, data in pairs ( turfLocs ) do
        exports.NGSQL:db_exec ( "UPDATE turfs SET owner=? WHERE id=?", data.owner, id )
    end
    return true
end
 
addEventHandler( "onResourceStart", resourceRoot, function ( )
    exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS turfs ( id INT, owner VARCHAR(50), x FLOAT, y FLOAT, z FLOAT, width INT, height INT )" )
    local query = exports.NGSQL:db_query ( "SELECT * FROM turfs" )
    if ( #query == 0 ) then
        local data = {
            { -1867.8, -107.43, 15.1, 58, 65 },
            { -1866.5, -26.36, 15.29, 49, 200 },
            { -1811.33, 743.43, 20, 85, 85 },
            { -1991.5, 862.62, 34, 79, 42 },
            { -2799.25, -200.6, 7.19, 83, 120 },
            { -2136.84, 120.12, 30, 120, 190 },
            { -2516.52, 718.16, 27.97, 118, 80 },
            { -2516.41, 578.19, 16.62, 100, 100 },
            { -2596.49, 818.05, 49.98, 59, 80 },
            { -2453.17, 947.58, 45.43, 54, 80  },
            { -2740.6, 344.59, 4.41, 68, 61 },
            { -2696.24, 227.35, 4.33, 39.5, 50.5 },
            { -2397.31, 82.99, 35.3, 133, 160 },
            { -2095.33, -280.06, 35.32, 84, 176 },
            { -1980.58, 107.69, 27.68, 59, 62 },
            { -2129.01, 741.71, 48, 112, 57 },
            { -2243.24, 928.4, 66.65, 87, 154 },
            { -1701.62, 743.44, 10, 129, 83 },
            { -2696.23, -59.88, 4.73, 83, 89 },
            { -2541.18, -720.16, 135, 55, 125 },
 
            }
 
  • Like 1
Link to comment
omg kariim the wanted system here : SAEGJobs>Law > general > Wanted_s.lua how we can export it ?
exports.SAEGJobs:functionName  --or 
exports["SAEGJobs"]:functionName --or  
call ( getResourceFromName ( "SAEGJobs" ), "functionName" )  

and you've to declare it in the meta.xml !

function="functionName" type="server" /> 
function="functionName" type="client" /> 

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...