Jump to content

[ Contagem de Kill ] - MYSQL


Anderson Fabris
 Share

Recommended Posts

20 horas atrás, tierrilopes disse:

 

Tentei, e infelizmente não tive sucesso. ( Estava tudo certo )

 

( Eu também estou com dificuldade no sistema de voucher, que também adicionaria na tabela. )
Alguém saberia me dizer o que estaria dando problema?

Alguém teria uma solução pra adicionar a kill pela source?

Edited by Anderson Fabris
Link to comment
Share on other sites

  • 1 month later...

Adicione o seguinte código no final em questlib.lua

 

Citar

-- MySQL
function string:split(delimiter)
    local result = {}
    local from = 1
    local delim_from, delim_to = string.find(self, delimiter, from)

    while delim_from do
        table.insert(result, string.sub(self, from , delim_from-1))
        from = delim_to + 1
        delim_from, delim_to = string.find(self, delimiter, from)
    end
    table.insert(result, string.sub(self, from))
    return result
end

function split(str, delim, maxNb)
    if str == nil then return str end
    if string.find(str, delim) == nil then return { str } end
    if maxNb == nil or maxNb < 1 then maxNb = 0 end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
    return result
end

mysql_query = function(query)
    local version = 55
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    if version == 51 then
        os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi)
    elseif version == 55 then
        os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi)
    else
        return 0
    end
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t,function(a,b)
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber(b) or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber(b) or b or 'NULL'
    end) end
    out.__lines = t[1]
    return out
end
--- Mysql END

Depois tente usar essa quest.

Citar

 

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...