Jump to content

Carro ir para garagem ao dar dv


Recommended Posts

quando eu do dv nos carros eles desaparecem da garagem, somente dando restart no mod que volta para garagem
como faço para quando der dv em vez de destuir o veiculo triggar o evento de guarda o veiculo?
 

function guardarveiculo (player)
local id = getElementData(player, "ID")
local accName = getAccountName(getPlayerAccount(player))
local carro = getPedOccupiedVehicle(player)
local nomecarro = getElementData(carro, "Nome")
local donocarro = getElementData(carro, "Owner")
local saude = getElementHealth(carro)
local gasolina = getElementData(carro, "MD:Gasolina") or 50
local multas = getElementData(carro, "Multas") or 0
local r1, g1, b1, r2, g2, b2, r3, g3, b3 = getVehicleColor(carro, true)
local result = dbPoll(dbQuery(db, "SELECT * FROM player WHERE Login = ? AND Veiculo = ?", accName, nomecarro), -1)
if donocarro == id then
    if #result > 0 then
        if result[1]["Status"] == "Em Rua" then
        dbExec(db, "UPDATE player SET Status = ? WHERE Login = ? AND Veiculo = ?", "Guardado", accName, nomecarro)
        dbExec(db, "UPDATE player SET Saude = ? WHERE Login = ? AND Veiculo = ?", saude, accName, nomecarro)
        dbExec(db, "UPDATE player SET R = ? WHERE Login = ? AND Veiculo = ?", r1, accName, nomecarro)
        dbExec(db, "UPDATE player SET G = ? WHERE Login = ? AND Veiculo = ?", g1, accName, nomecarro)
        dbExec(db, "UPDATE player SET B = ? WHERE Login = ? AND Veiculo = ?", b1, accName, nomecarro)
        dbExec(db, "UPDATE player SET Gas = ? WHERE Login = ? AND Veiculo = ?", gasolina, accName, nomecarro)
        dbExec(db, "UPDATE player SET Multas = ? WHERE Login = ? AND Veiculo = ?", multas, accName, nomecarro)
        destroyElement(carro)
        exports._infobox:addNotification(player, "Você guardou seu veiculo!", "success")
        end
    end
end
end
addEvent("H3>GuardarVeiculo", true)
addEventHandler("H3>GuardarVeiculo", root, guardarveiculo)
addCommandHandler("dv",
		function(playerSource,commandName,id)
	if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("Staff")) then
    if(id) then
    local playerID = tonumber(id)
        if(playerID) then
                local targetPlayer, targetPlayerName = getPlayerID(playerID)
                if targetPlayer then
                local veh = getPedOccupiedVehicle(targetPlayer)
                    if veh then
                    destroyElement(veh)
                    end
                end                   
            end
        end
    end
end
)

ambos estão em pastas diferentes

Edited by SciptNovato
Link to comment
function guardarveiculo (player)
local id = getElementData(player, "ID")
local accName = getAccountName(getPlayerAccount(player))
local carro = getPedOccupiedVehicle(player)
local nomecarro = getElementData(carro, "Nome")
local donocarro = getElementData(carro, "Owner")
local saude = getElementHealth(carro)
local gasolina = getElementData(carro, "MD:Gasolina") or 50
local multas = getElementData(carro, "Multas") or 0
local r1, g1, b1, r2, g2, b2, r3, g3, b3 = getVehicleColor(carro, true)
local result = dbPoll(dbQuery(db, "SELECT * FROM player WHERE Login = ? AND Veiculo = ?", accName, nomecarro), -1)
    if donocarro == id then
        if #result > 0 then
            if result[1]["Status"] == "Em Rua" then
            dbExec(db, "UPDATE player SET Status = ? WHERE Login = ? AND Veiculo = ?", "Guardado", accName, nomecarro)
            dbExec(db, "UPDATE player SET Saude = ? WHERE Login = ? AND Veiculo = ?", saude, accName, nomecarro)
            dbExec(db, "UPDATE player SET R = ? WHERE Login = ? AND Veiculo = ?", r1, accName, nomecarro)
            dbExec(db, "UPDATE player SET G = ? WHERE Login = ? AND Veiculo = ?", g1, accName, nomecarro)
            dbExec(db, "UPDATE player SET B = ? WHERE Login = ? AND Veiculo = ?", b1, accName, nomecarro)
            dbExec(db, "UPDATE player SET Gas = ? WHERE Login = ? AND Veiculo = ?", gasolina, accName, nomecarro)
            dbExec(db, "UPDATE player SET Multas = ? WHERE Login = ? AND Veiculo = ?", multas, accName, nomecarro)
            destroyElement(carro)
            exports._infobox:addNotification(player, "Você guardou seu veiculo!", "success")
            end
        end
    end
end
addEvent("H3>GuardarVeiculo", true)
addEventHandler("H3>GuardarVeiculo", root, guardarveiculo)


addCommandHandler("dv",
function(playerSource,commandName,id)
    if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("Staff")) then
        if (id) then
        local playerID = tonumber(id)
            if(playerID) then
            local targetPlayer, targetPlayerName = getPlayerID(playerID)
                if targetPlayer then
                local veh = getPedOccupiedVehicle(targetPlayer)
                    if veh then
                    destroyElement(veh)
                    end
                end                   
            end
        end
    end
end
)

assim ta certo?, não editei lá pq n to achando o botão de editar acho que some depois de um tempo né

Link to comment
  • Other Languages Moderators

Sim, some depois de um tempo pra evitar que os usuários deletem códigos prontos.

Só faltou dar mais espaço ali nos dbExec, no exports e nos destroyElement.

Link to comment
function guardarveiculo (player)
local id = getElementData(player, "ID")
local accName = getAccountName(getPlayerAccount(player))
local carro = getPedOccupiedVehicle(player)
local nomecarro = getElementData(carro, "Nome")
local donocarro = getElementData(carro, "Owner")
local saude = getElementHealth(carro)
local gasolina = getElementData(carro, "MD:Gasolina") or 50
local multas = getElementData(carro, "Multas") or 0
local r1, g1, b1, r2, g2, b2, r3, g3, b3 = getVehicleColor(carro, true)
local result = dbPoll(dbQuery(db, "SELECT * FROM player WHERE Login = ? AND Veiculo = ?", accName, nomecarro), -1)
    if donocarro == id then
        if #result > 0 then
            if result[1]["Status"] == "Em Rua" then
                dbExec(db, "UPDATE player SET Status = ? WHERE Login = ? AND Veiculo = ?", "Guardado", accName, nomecarro)
                dbExec(db, "UPDATE player SET Saude = ? WHERE Login = ? AND Veiculo = ?", saude, accName, nomecarro)
                dbExec(db, "UPDATE player SET R = ? WHERE Login = ? AND Veiculo = ?", r1, accName, nomecarro)
                dbExec(db, "UPDATE player SET G = ? WHERE Login = ? AND Veiculo = ?", g1, accName, nomecarro)
                dbExec(db, "UPDATE player SET B = ? WHERE Login = ? AND Veiculo = ?", b1, accName, nomecarro)
                dbExec(db, "UPDATE player SET Gas = ? WHERE Login = ? AND Veiculo = ?", gasolina, accName, nomecarro)
                dbExec(db, "UPDATE player SET Multas = ? WHERE Login = ? AND Veiculo = ?", multas, accName, nomecarro)
                destroyElement(carro)
                exports._infobox:addNotification(player, "Você guardou seu veiculo!", "success")
            end
        end
    end
end
addEvent("H3>GuardarVeiculo", true)
addEventHandler("H3>GuardarVeiculo", root, guardarveiculo)


addCommandHandler("dv",
function(playerSource,commandName,id)
    if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("Staff")) then
        if (id) then
        local playerID = tonumber(id)
            if(playerID) then
            local targetPlayer, targetPlayerName = getPlayerID(playerID)
                if targetPlayer then
                local veh = getPedOccupiedVehicle(targetPlayer)
                    if veh then
                        destroyElement(veh)
                    end
                end                   
            end
        end
    end
end
)

 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...