MU

!kills - Informa quantos você matou sem justificativa em um determinado período de tempo. (usado para saber se pode obter red skull ou ser banido)

Por Muvuka, 21 de set. de 2024 em Scripts

2
628
MuvukaM
21 de setembro de 2024 às 15:19

Não funciona.

 

-- kills.lua
function onSay(cid, words, param)
    if not isPlayer(cid) then
        return false
    end

    -- Verifica o número de mortes injustificadas no banco de dados
    local playerGUID = getPlayerGUID(cid)
    local resultId = db.storeQuery("SELECT unjustified_frags FROM players WHERE id = " .. playerGUID)

    if resultId ~= false then
        -- Recupera os frags injustificados
        local unjustifiedKillsDay = result.getDataInt(resultId, "unjustified_frags_day")
        local unjustifiedKillsWeek = result.getDataInt(resultId, "unjustified_frags_week")
        local unjustifiedKillsMonth = result.getDataInt(resultId, "unjustified_frags_month")
        
        -- Configuração de quantos frags são necessários para obter red skull ou ban
        local dailyFragLimit = getConfigValue("dailyFragLimit")
        local weeklyFragLimit = getConfigValue("weeklyFragLimit")
        local monthlyFragLimit = getConfigValue("monthlyFragLimit")
        
        -- Envia as informações ao jogador
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsDay .. " mortes injustificadas nas últimas 24 horas.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsWeek .. " mortes injustificadas nos últimos 7 dias.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsMonth .. " mortes injustificadas nos últimos 30 dias.")
        
        -- Informar se está perto de obter red skull ou ban
        if unjustifiedKillsDay >= dailyFragLimit or unjustifiedKillsWeek >= weeklyFragLimit or unjustifiedKillsMonth >= monthlyFragLimit then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Cuidado! Você está próximo de obter uma Red Skull ou ser banido!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você ainda está seguro, mas continue atento às suas mortes injustificadas.")
        end
        
        result.free(resultId)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não foi possível recuperar suas mortes injustificadas.")
    end

    return true
end

 

Editado Setembro 21 por Muvuka

El RusherE
24 de setembro de 2024 às 18:52
-- kills.lua
function onSay(cid, words, param)
    if not isPlayer(cid) then
        return false
    end

    -- Obtém o GUID do jogador
    local playerGUID = getPlayerGUID(cid)
    local resultId = db.storeQuery("SELECT unjustified_frags_day, unjustified_frags_week, unjustified_frags_month FROM player_kills WHERE player_id = " .. playerGUID)

    if resultId ~= false then
        -- Recupera os frags injustificados
        local unjustifiedKillsDay = result.getDataInt(resultId, "unjustified_frags_day") or 0
        local unjustifiedKillsWeek = result.getDataInt(resultId, "unjustified_frags_week") or 0
        local unjustifiedKillsMonth = result.getDataInt(resultId, "unjustified_frags_month") or 0
        
        -- Configuração de quantos frags são necessários para obter red skull ou ban
        local dailyFragLimit = getConfigValue("dailyFragsToRedSkull") or 3
        local weeklyFragLimit = getConfigValue("weeklyFragsToRedSkull") or 5
        local monthlyFragLimit = getConfigValue("monthlyFragsToRedSkull") or 10
        
        -- Envia as informações ao jogador
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsDay .. " mortes injustificadas nas últimas 24 horas.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsWeek .. " mortes injustificadas nos últimos 7 dias.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. unjustifiedKillsMonth .. " mortes injustificadas nos últimos 30 dias.")
        
        -- Informar se está perto de obter red skull ou ban
        if unjustifiedKillsDay >= dailyFragLimit or unjustifiedKillsWeek >= weeklyFragLimit or unjustifiedKillsMonth >= monthlyFragLimit then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Cuidado! Você está próximo de obter uma Red Skull ou ser banido!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você ainda está seguro, mas continue atento às suas mortes injustificadas.")
        end
        
        result.free(resultId)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não foi possível recuperar suas mortes injustificadas.")
    end

    return true
end


Certifique-se de que o banco de dados contém as colunas unjustified_frags_day, unjustified_frags_week e unjustified_frags_month na tabela player_kills. Além disso, ajuste os valores de configuração dailyFragsToRedSkull, weeklyFragsToRedSkull, e monthlyFragsToRedSkull para se alinhar ao que você deseja no arquivo de configuração do servidor.