Jump to content

(HELP) Turf System Big and Bad Problem


Leonard.DC

Recommended Posts

Hi, i have a turf system vinculed with a gang system, But when i start the script, The turfs doesn't appears, I pressed F11 and i didn't saw any turfing zone :( why????

The fully turf script:

sql = { Query = executeSQLQuery }; 
-- W =  Ancho        H= Alto
 
addEventHandler( 'onResourceStart', resourceRoot, function()
    sql.Query( "CREATE TABLE IF NOT EXISTS Gang_truf (\
   ID INTEGER, X REAL, Y REAL, W REAL,\
   H REAL, Gang STRING, R ,\
   G , B , sX REAL, sY REAL, sZ REAL )"
    )
    setTimer (TiempoDeTrufs, 50000, 0)
    local t = sql.Query( "SELECT * FROM Gang_truf" )
    for i = 1, #t do
        createTruf( t[i].ID, t[i].X, t[i].Y, t[i].W, t[i].H, t[i].Gang, t[i].R, t[i].G, t[i].B, t[i].sX, t[i].sY, t[i].sZ )
    end
end )
 
function setDark (src)
    if isPlayerInTeam (src, "Staff DA") then
        local t = sql.Query( "SELECT * FROM Gang_truf" )
        for i = 1, #t do
            setDarkTurf( t[i].ID, t[i].Gang)
        end
    end
end
addCommandHandler  ("resetearturf", setDark)
function setDarkTurf (ID, gang)
    if tostring(gang) ~= ""  then
        sql.Query( "UPDATE Gang_truf SET Gang = '', R = '255', G = '255', B = '255' WHERE ID = '"..tonumber(ID).."'" );
    end
end
 
function createTruf (ID, x, y, w, h, gang, r, g, b, sX, sY, sZ)
    Truf = createRadarArea (x, y, w, h, tonumber(r), tonumber(g), tonumber(b), 150)
    Cols = createColRectangle (x, y, w, h)
   
    setElementData (Cols, "GangTruf", {ID, gang, Truf})
    setElementData (Cols, "GangSpawn", {sX, sY, sZ})
    setElementData (Cols, "Probocacion", 0)
    setElementData (Cols, "EstatusT", "Nada")
    setElementData (Cols, "GangtersOn", 0)
    setElementData (Cols, "GangDefensa", 0)
    setElementData (Cols, "TurfAbandonada", 0)
   
    addEventHandler ("onColShapeHit", Cols, function (player)
        if getElementType (player) == "player" then
            local GangTruf = getElementData (source, "GangTruf")[2]
            local MyGang = getElementData (player, "Clan")
            setElementData (player, "EnTruf", getElementData(source, "GangTruf")[1])
            if MyGang ~= "" then
                if GangTruf then
                    triggerClientEvent (player, "ComprobacionPiso", player)                
                end
            else
                outputChatBox ("Debes tener un Clan para iniciar una guerra de territorios (Turf)",player,255,255,255) 
            end
        end 
    end )
    addEventHandler ("onColShapeLeave", Cols, function (player)
        if getElementType (player) == "player" then
            setElementData (player, "EnTruf", nil)
            if getElementData (player, "EnGuerra") == true then
                if getElementData (source, "Atacante") == getElementData (player, "Clan") then
                    setElementData (source, "GangtersOn", tonumber(getElementData (source, "GangtersOn"))-1)
                    setElementData (player, "EnGuerra", false)                 
                end
            end
            if getElementData (player, "EnDefensa") == true then
                if getElementData (source, "GangTruf")[2] == getElementData (player, "Clan") then
                    setElementData (source, "GangDefensa", tonumber(getElementData (source, "GangDefensa"))-1)
                    setElementData (player, "EnDefensa", false)
                end
            end
        end
    end)
end
 
function iniciarCuenta ()
    local truf = getTrufByID (getElementData (source, "EnTruf"))
    local gang = getElementData (source, "Clan")
    if truf then
           if isPlayerInTeam (source, "Criminal") or isPlayerInTeam (source, "Gangsters") then
               local GangTruf = getElementData (truf, "GangTruf")[2]
                if gang ~= GangTruf then
               
                    outputChatBox ("Actualmente este territorio es de "..GangTruf.." Quedate en la zona para iniciar una guerra de territorios",source,255,255,255)
                else
                    setElementData (source, "EnDefensa", true)
                    setElementData (truf, "GangDefensa", tonumber(getElementData(truf,"GangDefensa"))+1)
                    if getElementData (truf, "Probocacion") > 0 then
                       outputChatBox ("Este Territorio es de tu Clan pero fue atacado | Fuerza: "..getElementData(truf, "Probocacion").."/10 - ["..getElementData (truf, "Atacante").."]"..getElementData (truf, "GangtersOn").." Vs "..getElementData (truf, "GangDefensa").."["..GangTruf.."].",source,255,255,255)
                   else
                       outputChatBox ("Este Territorio pertenece a Tu Clan.",source,255,255,255)
                   end
                end
               if getElementData (truf, "EstatusT") == "Nada" then
                   if gang ~= GangTruf then
                       setElementData (truf, "EstatusT", "Iniciando")
                       setElementData (truf, "Atacante", gang)
                       setElementData (source, "EnGuerra", true)
                   end
               end
                if getElementData (truf, "EstatusT") == "Iniciando" or getElementData (truf, "EstatusT") == "Atacando" then
                   if gang == getElementData (truf, "Atacante") then
                       setElementData (truf, "GangtersOn", tonumber(getElementData (truf, "GangtersOn"))+1)
                       setElementData (source, "EnGuerra", true)
                       outputChatBox ("Tu Clan esta en Guerra Con este Terretorio | Fuerza: "..getElementData(truf, "Probocacion").."/10 - ["..getElementData (truf, "Atacante").."]"..getElementData (truf, "GangtersOn").." Vs "..getElementData (truf, "GangDefensa").."["..GangTruf.."].",source,255,255,255)
                   else
                       if gang ~= GangTruf then
                            if tonumber(getElementData(truf, "GangtersOn")) == 0 then
                                if getElementData (truf, "EstatusT") == "Iniciando" then
                                    setElementData (truf, "Atacante", gang)
                                    setElementData (source, "EnGuerra", true)
                                    setElementData (truf, "GangtersOn", tonumber(getElementData (truf, "GangtersOn"))+1)
                                else
                                    outputChatBox ("Este Territorio esta en Guerra con otra Clan",source,255,255,255)
                                end
                            else   
                                outputChatBox ("Este Territorio esta en Guerra con otra Clan",source,255,255,255)
                            end
                       end
                   end
               end
           else
              if gang == "Elite" or gang == "SWAT" or gang == "PDI" then
              outputChatBox ("Para Iniciar una Guerra nesesitas ser Criminal o Gangster",source,255,0,0)
           end
       end         
    end
end
addEvent ("SiEstaEnPiso", true)
addEventHandler ("SiEstaEnPiso", root, iniciarCuenta)
 
function TiempoDeTrufs ()
    for i, v in ipairs( getElementsByType( 'colshape', getResourceRootElement() ) ) do
        if getElementData( v, 'GangTruf' ) then
            local p = getElementsWithinColShape (v, "player")
            local id = getElementData(v, "GangTruf")[1]
            local viejoMandato = getElementData (v, "GangTruf")[2]
            local rad = getElementData(v, "GangTruf")[3]
            local ata = getElementData (v, "Atacante")
            if getElementData (v, "Probocacion") <= -1 then
                setElementData (v, "EstatusT", "Nada")
                setElementData (v, "Atacante", "")
                setElementData (v, "TurfAbandonada", 2)
            end
            if getElementData (v, "EstatusT") == "Iniciando" then
                setRadarAreaFlashing (rad, false)
                if tonumber(getElementData (v, "GangtersOn")) >= tonumber(getElementData(v, "GangDefensa")) then
                    setElementData (v, "Probocacion", tonumber(getElementData(v, "Probocacion"))+tonumber(getElementData(v, "GangtersOn")))
                    for k, players in ipairs (p) do
                        if getElementData (players, "Clan") == tostring(ata) then
                            if tonumber(getElementData(v, "Probocacion")) < 11 then
                                outputChatBox ("Tiempo para Iniciar la Guerra: "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                            elseif tonumber(getElementData(v, "Probocacion")) >= 11 then
                                outputChatBox ("Iniciaste una Guerra Por Este Territorio",players,255,255,0)
                            end
                        end
                        if getElementData (players, "Clan") == tostring(viejoMandato) then
                            outputChatBox ("Te Estan Ganando Este Territorio... Tiempo "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                        end
                    end
                    if tonumber(getElementData(v, "Probocacion")) >= 10 then
                        setElementData (v, "EstatusT", "Atacando")
                        setElementData (v, "Probocacion", 0)
                        setRadarAreaFlashing (rad, true)
                        for k, players in ipairs (getElementsByType("player")) do
                            if getElementData (players, "Clan") == tostring(viejoMandato) then
                                outputChatBox ("El Clan "..ata.." Esta Atacando uno de tus Territorios!",players,255,255,255)
                            end
                        end
                    end
                elseif tonumber(getElementData (v, "GangDefensa")) > tonumber(getElementData(v, "GangtersOn")) then
                    setElementData (v, "Probocacion", tonumber(getElementData(v, "Probocacion"))-tonumber(getElementData(v, "GangDefensa")))
                    for k, players in ipairs (p) do
                        if getElementData (players, "Clan") == tostring(viejoMandato) then
                            outputChatBox ("Estas Defendiendo bien este Territorio! Tiempo - "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                        end
                        if getElementData (players, "Clan") == tostring(ata) then
                            outputChatBox ("Tu Clan Va Perdiendo Este Territorio... Tiempo - "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                        end
                    end
                    if tonumber(getElementData(v, "Probocacion")) <= 0 then
                        setElementData (v, "EstatusT", "Nada")
                        setElementData (v, "Probocacion", 0)
                        setRadarAreaFlashing (rad, false)
                        for k, players in ipairs (p) do
                            if getElementData (players, "Clan") == tostring(ata) then
                                outputChatBox ("el Clan Dueño del Territorio Defindio Vuestro Ataque, MISION FRACASADA!",players,255,255,255)
                            end
                            if getElementData (players, "Clan") == tostring(viejoMandato) then
                                outputChatBox ("Defendiste Correctamente Este Territorio, Buen Trabajo!!",players,255,255,255)
                            end
                        end
                    end
                end
            elseif getElementData (v, "EstatusT") == "Atacando" then
                setRadarAreaFlashing (rad, true)
                if tonumber(getElementData (v, "GangtersOn")) == 0 and tonumber(getElementData(v, "GangDefensa")) == 0 then
                    setElementData (v, "TurfAbandonada", getElementData(v, "TurfAbandonada")+1)
                    if tonumber(getElementData(v, "TurfAbandonada")) == 12 then
                        setRadarAreaFlashing (rad, false)
                        setElementData (v, "EstatusT", "Nada")
                        setElementData (v, "Atacante", "")
                        setElementData (v, "TurfAbandonada", 0)
                    end
                else
                    setElementData (v, "TurfAbandonada", 0)
                end
                if tonumber(getElementData (v, "GangtersOn")) >= tonumber(getElementData(v, "GangDefensa")) then
                    setElementData (v, "Probocacion", tonumber(getElementData(v, "Probocacion"))+tonumber(getElementData(v, "GangtersOn")))
                    for k, players in ipairs (p) do
                        outputChatBox ("El Clan Atacante ("..ata..") Va Ganando Este Territorio! ("..getElementData (v, "GangtersOn").." Vs "..getElementData(v, "GangDefensa")..") - Tiempo: "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                        if getElementData (players, "Clan") == tostring(ata) then
                            if tonumber(getElementData(v, "Probocacion")) > 10 then
                                outputChatBox ("Felicidades, Habeis Ganado la Guerra del Territorio! MISION CUMPLIDA",players,255,255,0)
                                givePlayerMoney (players, 2000) --$2000
                                setElementData (players, "EnGuerra", false) 
                                setElementData (players, "EnDefensa", false)
                                setElementData (players, "display_money", "2000")
                                setElementData (players, "display_respeto", "1")
                                setPedStat (players, 64, getPedStat (players, 64)+1)
                                triggerClientEvent (players, "dx", players)
                                triggerClientEvent (players, "dxr2", players)
                            end
                        end 
                    end
                elseif tonumber(getElementData (v, "GangDefensa")) > tonumber(getElementData(v, "GangtersOn")) then
                    setElementData (v, "Probocacion", tonumber(getElementData(v, "Probocacion"))-tonumber(getElementData(v, "GangDefensa")))
                    for k, players in ipairs (p) do
                        outputChatBox ("El Clan Defensor ("..viejoMandato..") Va Ganando Este Territorio! ("..getElementData (v, "GangDefensa").." Vs "..getElementData(v, "GangtersOn")..") - Tiempo: "..getElementData(v, "Probocacion").."/10.",players,255,255,255)
                        if getElementData (players, "Clan") == tostring(viejoMandato) then
                            givePlayerMoney (players, 100)
                            if tonumber(getElementData(v, "Probocacion")) <= 0 then
                                setRadarAreaFlashing (rad, false)
                                setElementData (players, "EnGuerra", false) 
                                setElementData (players, "EnDefensa", false)
                                outputChatBox ("Felicidades, Defendisteis Vuestro Territorio Con Exito!",players,255,255,0)
                            end
                        end 
                    end
                    if tonumber(getElementData(v, "Probocacion")) == 0 then
                        setElementData (v, "EstatusT", "Nada")
                        setElementData (v, "Probocacion", 0)   
                        setElementData (v, "GangtersOn", 0)
                        setElementData (v, "GangDefensa", 0)
                    end
                end
                if tonumber(getElementData(v, "Probocacion")) > 10 then
                    for k, players in ipairs (getElementsByType("player")) do
                        if getElementData (players, "Clan") == tostring(viejoMandato) then
                           
Link to comment
This is maked by my friend that say me to post the last problem here, can you say me why it doesn't work or fix it please :)

What are you talking about?

I told you there is no positions INSERTED INTO THE DATABASE, what part you can't understand?

Link to comment
This is maked by my friend that say me to post the last problem here, can you say me why it doesn't work or fix it please :)

What are you talking about?

I told you there is no positions INSERTED INTO THE DATABASE, what part you can't understand?

:| And how to insert the data to the database?

Link to comment
  • 6 months later...
  • 1 month later...

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