Mec.Love Posted October 11, 2020 Share Posted October 11, 2020 E ai galera, peço por favor que me ajudem nesse! A duvida dos outros tópicos eu já consegui resolver. Porém quero vincular mais um script ao outro. Porém não tive sucesso! É um desmanche e uma loja de veiculos com garagem. Queria que ao desmanchar o veiculo o player perdesse o veiculo que comprou na loja. loja de veh lado server --[[ =========================================================== # Minha página: https://www.facebook.com/TioSteinScripter/# #╔════╗╔══╗╔═══╗ ╔═══╗╔════╗╔═══╗╔══╗╔═╗─╔╗ # #║╔╗╔╗║╚╣─╝║╔═╗║ ║╔═╗║║╔╗╔╗║║╔══╝╚╣─╝║║╚╗║║ # #╚╝║║╚╝─║║─║║─║║ ║╚══╗╚╝║║╚╝║╚══╗─║║─║╔╗╚╝║ # #──║║───║║─║║─║║ ╚══╗║──║║──║╔══╝─║║─║║╚╗║║ # #──║║──╔╣─╗║╚═╝║ ║╚═╝║──║║──║╚══╗╔╣─╗║║─║║║ # #──╚╝──╚══╝╚═══╝ ╚═══╝──╚╝──╚═══╝╚══╝╚╝─╚═╝ # =========================================================== --]] addEventHandler("onResourceStart", resourceRoot, function(res) if res == getThisResource() then db = dbConnect( "sqlite", "veiculos.sqlite" ) dbExec(db, "CREATE TABLE IF NOT EXISTS Veiculos (ID, Conta, Valor, IDVeiculo, NomeVeiculo, Status, Cores)") for i, player in ipairs(getElementsByType("player")) do CarregarLista(player) end if db then outputDebugString("dbConnect[veiculos]: Sucesso!") else outputDebugString("dbConnect[veiculos]: Fail!") end end end) function getTabelaVehicles () return VeiculosAVenda end function NovoID() local result = dbPoll(dbQuery(db, "SELECT ID FROM Veiculos ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end for i=1, #Lojas do local x, y, z, int = Lojas[i][1], Lojas[i][2], Lojas[i][3], Lojas[i][4] Lojas[i] = createMarker( x, y, z, "cylinder", 1.8, 0, 255, 127, 90) Lojas.ID[Lojas[i]] = i --local Blips = createBlipAttachedTo ( Lojas[i], 55 ) --setBlipVisibleDistance(Blips, 180) setElementInterior(Lojas[i], int) end function hit (element) if Lojas.ID[source] then if getElementType(element) == "player" then local Conta = getPlayerAccount ( element ) if isGuestAccount ( Conta ) then triggerClientEvent(element, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffLogue-se para entrar na loja de veiculos!", "info") return end CarregarLista(element) triggerClientEvent(element, "TS:AbrirComprarCarro", element) end end end addEventHandler("onMarkerHit", resourceRoot, hit) for i=1, #Markers do local x, y, z, int = Markers[i][1], Markers[i][2], Markers[i][3], Markers[i][4] Markers[i] = createMarker( x, y, z, "cylinder", 1.8, 0, 255, 127, 90) Markers.ID[Markers[i]] = i --local Blips = createBlipAttachedTo ( Markers[i], 32 ) setBlipVisibleDistance(Blips, 180) setElementInterior(Markers[i], int) end function hit (element) if Markers.ID[source] then if getElementType(element) == "player" then local Conta = getPlayerAccount ( element ) if isGuestAccount ( Conta ) then triggerClientEvent(element, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffLogue-se para entrar na garagem!", "info") return end CarregarLista(element) triggerClientEvent(element, "TS:AbrirLojaCarros2", element) end end end addEventHandler("onMarkerHit", resourceRoot, hit) function AbrirDocumentacao(source) local VeiculoDentro = getPedOccupiedVehicle(source) if not VeiculoDentro then return end triggerClientEvent(source,"TS:AbrirDoc", source) end addCommandHandler("doc", AbrirDocumentacao) function RoubarVeiculo (source) for id, Veiculo in ipairs(getElementsByType("vehicle")) do local cx, cy, cz = getElementPosition ( Veiculo ) local px, py, pz = getElementPosition ( source ) local distance= getDistanceBetweenPoints3D ( cx, cy, cz, px, py, pz ) if ( distance <= 3 ) then if getElementData(Veiculo, "TS:Trancado") == true then local speedx, speedy, speedz = getElementVelocity ( Veiculo ) local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) kmh = actualspeed * 180 if kmh >= 2 then return end triggerClientEvent(source, "TS:AbrirRouboVeiculo", source) toggleAllControls(source, false) setPedAnimation( source, "BOMBER", "BOM_Plant", 60000, true) setTimer(function() setElementData(Veiculo, "TS:Roubado", true) setPedAnimation( source, nil) triggerClientEvent(source, "TS:AbrirRouboVeiculo", source) toggleAllControls(source, true) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo Aberto!") setElementData(Veiculo, "TS:Trancado", false) end, 60000, 1) end end end end addCommandHandler("roubarveiculo", RoubarVeiculo) VeiculoComprei = {} function ComprarVeiculo(source, NomeVeiculo, ValorVeiculo, AluguelVeiculo, IDVeiculo, r1, g1, b1, r2, g2, b2) local data = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ?", getAccountName(getPlayerAccount(source))), -1) if #data >= LimiteVeiculos then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff O seu limite de veiculos é "..LimiteVeiculos.."!") return end local Dinheiro = getPlayerMoney(source) local VeiculoDentro = getPedOccupiedVehicle(source) local NomeDono = getElementData(source,"ID") or "Error" abc = false for i, data in ipairs (data) do if data["IDVeiculo"] == tonumber(IDVeiculo) then abc = true break end end if abc == true then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você já tem esse veiculo!") return end if IDVeiculo and ValorVeiculo then if tonumber(Dinheiro) >= tonumber(ValorVeiculo) then local NewID = NovoID() local Placa = "CV" takePlayerMoney(source, ValorVeiculo) local Cor = r1, g1, b1, r2, g2, b2 dbExec(db, "INSERT INTO Veiculos VALUES( ?, ?, ?, ?, ?, ?, ?)", tonumber(NewID), getAccountName(getPlayerAccount(source)), tonumber(ValorVeiculo), tonumber(IDVeiculo), NomeVeiculo, "Guardado", Cor) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo Comprado, olhe sua garagem!") CarregarLista(source) else triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Dinheiro Insuficiente") end end end addEvent("TS:ComprarVeiculo", true) addEventHandler("TS:ComprarVeiculo", root, ComprarVeiculo) VeiculoAluguel = {} function AlugarVeiculo (source, NomeVeiculo, ValorVeiculo, ValorAluguel, IDVeiculo, r1, g1, b1, r2, g2, b2) if getElementData(source, "TS:VeiculoAlugado") == true then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você já tem um veiculo alugado, aguarde "..TempoDeAluguel.." minutos !") return end local Dinheiro = getPlayerMoney(source) local NomeDono = getElementData(source,"ID") or "Error" if Dinheiro < tonumber(ValorAluguel) then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você não tem dinheiro suficiente!") return end takePlayerMoney(source, ValorAluguel) setElementData(source, "TS:VeiculoAlugado", true) VeiculoAluguel[source] = createVehicle(IDVeiculo, PosxAluga, PosyAluga, PoszAluga) warpPedIntoVehicle ( source, VeiculoAluguel[source] ) setElementData(VeiculoAluguel[source], "TS:Dono", NomeDono) setElementData(VeiculoAluguel[source], "TS:RGDono", "Alugado Por : "..getElementData(source, "ID")) setElementData(VeiculoAluguel[source], "TS:ValorCarro", 0) setVehiclePlateText(VeiculoAluguel[source], "Aluguel") triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo Alugado por "..TempoDeAluguel.." Minutos") setVehicleColor( VeiculoAluguel[source], r1, g1, b1, r2, g2, b2 ) setTimer(function() if VeiculoAluguel[source] then destroyElement(VeiculoAluguel[source]) end triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff A loja de veiculos pegou o veiculo alugado de volta !") setElementData(source, "TS:VeiculoAlugado", false) end, TempoDeAluguel*60000, 1) end addEvent("TS:AlugarVeiculo", true) addEventHandler("TS:AlugarVeiculo", root, AlugarVeiculo) VeiculoSpawnar = {} function getVehicleConceStein (vehicle) local tabela = VeiculosAVenda local model = getElementModel(vehicle) for i=1, #tabela do if tonumber(model) == tonumber(tabela[i][1]) then return tonumber(tabela[i][3]) end end end function getPorcentagem (porce, valor) if porce and valor then local valor_01 = porce/100 if valor_01 then local valor_02 = valor_01*valor if valor_02 then local valor = math.floor(valor_02) return tonumber(valor) end end end end function PegarVeiculo (source, NomeCarro, IDCarro, SlotCarro, ValorCarro41) local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND NomeVeiculo = ?", getAccountName(getPlayerAccount(source)), NomeCarro), -1) for i, data in ipairs (data2) do local VeiculoDentro = getPedOccupiedVehicle(source) if exports.MAT_Desmanche:isVehicleDesmanche(VeiculoDentro) then if getPlayerMoney(source) < tonumber(getPorcentagem (50, tonumber(getVehicleConceStein (vehicle)))) then return triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você não possui o valor de retirada do veiculo: "..tonumber(getPorcentagem (50, tonumber(getVehicleConceStein (vehicle))))) else takePlayerMoney(source, tonumber(getPorcentagem (50, tonumber(getVehicleConceStein (vehicle))))) exports.MAT_Desmanche:unlockvehicle(VeiculoDentro) end end if VeiculoDentro then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Saia do veiculo!") return end local ValorCarro = data["Valor"] local StatusVeiculo = data["Status"] local IDSlot = data["ID"] local IDVeiculo2 = data["IDVeiculo"] local ValorTotal = 10/100*ValorCarro if StatusVeiculo ~= "Guardado" then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Esse veiculo já está spawnado") return end local Nome = getElementData(source,"ID") or "Error" local PosPlayerx, PosPlayery,PosPlayerz = getElementPosition(source) local Cor1 = data["R"] local Cor2 = data["G"] local Cor3 = data["B"] VeiculoSpawnar[source] = createVehicle(IDVeiculo2, PosPlayerx, PosPlayery,PosPlayerz) warpPedIntoVehicle ( source, VeiculoSpawnar[source] ) setElementData(VeiculoSpawnar[source], "TS:Dono", Nome) setElementData(VeiculoSpawnar[source], "TS:ValorCarro", ValorCarro) setElementData(VeiculoSpawnar[source], "TS:NomeCarro", NomeCarro) setElementData(VeiculoSpawnar[source], "TS:ContaDono", getAccountName(getPlayerAccount(source))) setElementData(VeiculoSpawnar[source], "TS:IDCarro", IDCarro) setElementData(VeiculoSpawnar[source], "TS:RGDono", getElementData(source, "ID")) setElementData(VeiculoSpawnar[source], "TS:ID", IDSlot) setVehiclePlateText(VeiculoSpawnar[source], "ITOS - "..IDSlot) dbExec(db, "UPDATE Veiculos SET Status = ? WHERE Conta = ? AND ID = ?", "Spawnado", getAccountName(getPlayerAccount(source)), IDSlot) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Seu veiculo foi spawnado") local color = split(data["Cores"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 setVehicleColor( VeiculoSpawnar[source], r1, g1, b1, r2, g2, b2 ) CarregarLista(source) end end addEvent("TS:PegarVeiculo", true) addEventHandler("TS:PegarVeiculo", root, PegarVeiculo) function GuardarVeiculo (source, NomeCarro, IDCarro, SlotCarro) local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND NomeVeiculo = ?", getAccountName(getPlayerAccount(source)), NomeCarro), -1) for i, data in ipairs (data2) do local VeiculoDentro = getPedOccupiedVehicle(source) local Nome = getElementData(source,"ID") or "Error" if not VeiculoDentro then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end local IDVeiculo = getElementModel(VeiculoDentro) local NomeVeiculo = getElementData(VeiculoDentro, "TS:NomeCarro") or getVehicleNameFromModel (IDVeiculo) if getElementData(VeiculoDentro, "TS:Dono") ~= Nome then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end if NomeVeiculo ~= NomeCarro then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você não está dentro do veiculo!") return end local StatusVeiculo = data["Status"] if StatusVeiculo == "Guardado" then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Esse veiculo já está guardado") return end local r1, g1, b1, r2, g2, b2 = getVehicleColor(VeiculoDentro, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 local IDVeiculo2 = getElementData(VeiculoDentro, "TS:ID") dbExec(db, "UPDATE Veiculos SET Cores = ?, Status = ? WHERE Conta = ? AND ID = ?", color, "Guardado", getAccountName(getPlayerAccount(source)), IDVeiculo2) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Seu veiculo foi Guardado") CarregarLista(source) destroyElement(VeiculoDentro) end end addEvent("TS:GuardarVeiculo", true) addEventHandler("TS:GuardarVeiculo", root, GuardarVeiculo) function VenderVeiculoConce (source, IDVeiculo, NomeVeiculo) local VeiculoDentro = getPedOccupiedVehicle(source) if not VeiculoDentro then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end local Nome = getElementData(source,"ID") or "Error" local IDProprietario = getElementData(VeiculoDentro,"TS:ID") or "Error" local IDVeiculo2 = getElementModel(VeiculoDentro) local NomeVeiculo2 = getElementData(VeiculoDentro, "TS:NomeCarro") or getVehicleNameFromModel (IDVeiculo) local Valor = getElementData(VeiculoDentro, "TS:ValorCarro") or 0 local ValorTotal = 70/100*Valor local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND ID = ?", getAccountName(getPlayerAccount(source)), IDProprietario), -1) for i, data in ipairs (data2) do if getElementData(VeiculoDentro, "TS:Dono") ~= Nome then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end if NomeVeiculo2 ~= NomeVeiculo then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você não está dentro do veiculo!") return end dbExec(db, "DELETE FROM Veiculos WHERE Conta = ? AND ID = ?", getAccountName(getPlayerAccount(source)), IDProprietario) destroyElement(VeiculoDentro) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo Vendido Por "..ValorTotal.." ( 70% )") givePlayerMoney(source, ValorTotal) end end addEvent("TS:VenderVeiculoConce", true) addEventHandler("TS:VenderVeiculoConce", root, VenderVeiculoConce) function LocalizarVeiculo (source, NomeCarro, IDCarro, Emplacamento, ValorCarro41) if isElement(Blip) then destroyElement(Blip) return end local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND NomeVeiculo = ?", getAccountName(getPlayerAccount(source)), NomeCarro), -1) for i, data in ipairs (data2) do local VeiculoDentro = getPedOccupiedVehicle(source) local StatusVeiculo = data["Status"] local IDSlot = data["ID"] if StatusVeiculo == "Guardado" then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Esse veiculo não está spawnado!") return end local Veiculo = ProcurarPlacaVeiculo("ITOS - "..Emplacamento) if not Veiculo then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo não encontrado!") return end Blip = createBlipAttachedTo(Veiculo, 41) setElementVisibleTo(Blip, root, false) setElementVisibleTo(Blip, source, true) end end addEvent("TS:LocalizarVeiculo", true) addEventHandler("TS:LocalizarVeiculo", root, LocalizarVeiculo) function EnviarVeiculo (source, IDJogador, IDVeiculo, NomeVeiculo) local Jogador = getPlayerID(IDJogador) if Jogador then local VeiculoDentro = getPedOccupiedVehicle(source) if not VeiculoDentro then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end local Nome = getElementData(source,"ID") or "Error" local IDProprietario = getElementData(VeiculoDentro,"TS:ID") or "Error" local IDVeiculo2 = getElementModel(VeiculoDentro) local NomeVeiculo2 = getElementData(VeiculoDentro, "TS:NomeCarro") or getVehicleNameFromModel (IDVeiculo) local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND ID = ?", getAccountName(getPlayerAccount(source)), IDProprietario), -1) for i, data in ipairs (data2) do local data3 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ?", getAccountName(getPlayerAccount(Jogador))), -1) if #data3 >= LimiteVeiculos then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff O limite de veiculos do jogador é "..LimiteVeiculos.."!") return end if getElementData(VeiculoDentro, "TS:Dono") ~= Nome then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Para realizar essa ação é preciso estar no carro!") return end if NomeVeiculo2 ~= NomeVeiculo then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você não está dentro do veiculo!") return end abc = false for i, data3 in ipairs (data3) do if data3["IDVeiculo"] == IDVeiculo2 then abc = true break end end if abc == true then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff O jogador já tem esse veiculo!") return end triggerClientEvent(Jogador, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Você recebeu um veiculo, Olhe sua garagem") dbExec(db, "UPDATE Veiculos SET Conta = ?, Status = ? WHERE Conta = ? AND ID = ?", getAccountName(getPlayerAccount(Jogador)), "Guardado", getAccountName(getPlayerAccount(source)), IDProprietario) destroyElement(VeiculoDentro) triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Veiculo Enviado") end else triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Jogador não encontrado") end end addEvent("TS:EnviarVeiculo", true) addEventHandler("TS:EnviarVeiculo", root, EnviarVeiculo) addEventHandler ( "onResourceStart", resourceRoot, function ( mod ) setTimer( function() for i, player in ipairs (getElementsByType("player")) do dbExec(db, "UPDATE Veiculos SET Status = ? WHERE Conta = ? AND Status = ?", "Guardado", getAccountName(getPlayerAccount(player)), "Spawnado") setElementData(player, "TS:VeiculoAlugado", nil) end end, 3000, 1) end ) function DesmancheCarro(source, IdCar, ValorSeguro) local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ? AND IDVeiculo = ?", getAccountName(getPlayerAccount(source)), IdCar), -1) for i, data in ipairs (data2) do local Seguro = data["Seguro"] if Seguro == "Sim" then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Seu veiculo foi desmanchado, você tinha seguro e recuperou 80% do valor!") givePlayerMoney(source, ValorSeguro) dbExec(db, "DELETE FROM Veiculos WHERE Conta = ? AND IDVeiculo = ?", getAccountName(getPlayerAccount(source)), IdCar) else triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Seu veiculo foi desmanchado, você não tinha seguro!") dbExec(db, "DELETE FROM Veiculos WHERE Conta = ? AND IDVeiculo = ?", getAccountName(getPlayerAccount(source)), IdCar) end end end addEvent("TS:DesmancheCarro", true) addEventHandler("TS:DesmancheCarro", root, DesmancheCarro) function Deslogar () local data2 = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data2) do local IDDoDono = getElementData(source, "ID") if not IDDoDono then return end local VeiculoIDDoDono = ProcurarVeiculosNoJogo(IDDoDono) --if VeiculoIDDoDono then destroyElement(VeiculoIDDoDono) end if VeiculoAluguel[source] then destroyElement(VeiculoAluguel[source]) end dbExec(db, "UPDATE Veiculos SET Status = ? WHERE Conta = ? AND Status = ?", "Guardado", getAccountName(getPlayerAccount(source)), "Spawnado") end end addEventHandler("onPlayerQuit", root, Deslogar) addEventHandler("onPlayerLogin", root, Deslogar) function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end function getVehicleIDConce(id) v = false for i, player in ipairs (getElementsByType("vehicle")) do if getElementData(player, "TS:ID") == id then v = player break end end return v end function ProcurarPlacaVeiculo(id) v = false for i, player in ipairs (getElementsByType("vehicle")) do if getVehiclePlateText(player) == id then v = player break end end return v end function ProcurarVeiculosNoJogo(id) v = false for i, player in ipairs (getElementsByType("vehicle")) do if getElementData(player, "TS:Dono") == id then v = player break end end return v end function CarregarLista(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM Veiculos WHERE Conta = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "TS:VeiculosInfo", result) end end end addEvent("TS:CarregarLista", true) addEventHandler("TS:CarregarLista", root, CarregarLista) function Placa(source, cmd) local Placa = getElementData(source, "TS:Placa") or "Ativa" if Placa == "Ativa" then setElementData(source, "TS:Placa", "Desativa") triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Placas desativadas") else setElementData(source, "TS:Placa", "Ativa") triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺#ffffff Placas Ativadas") end end addCommandHandler("placa", Placa) Desmanche lado server local zones = { {2553.872, -1126.315, 63.709}, } local zone = {} local myZone = {} local elements = {} local zonetime = {} local tableZone = {} addEventHandler('onResourceStart', resourceRoot, function() for i=1, #zones do zone[i] = createColSphere(zones[i][1], zones[i][2], zones[i][3], 10) addEventHandler('onColShapeHit', zone[i], enterZone) addEventHandler('onColShapeLeave', zone[i], exitZone) end end) local function checkZone (zone) for i = 1, #zonetime do if zonetime[i] == zone then return false end end return true end local function getPosZone (zone) for i = 1, #zonetime do if zonetime[i] == zone then return i end end end setTimer(function() for i = 1, #zonetime do if tableZone and not tableZone[zonetime[i]] then tableZone[zonetime[i]] = {['Ocupada'] = true, ['Horas'] = 3, ['Minutos'] = 0, ['Segundos'] = 0} attWithinZone(zonetime[i]) end if tableZone[zonetime[i]]['Segundos'] <= 0 then tableZone[zonetime[i]]['Segundos'] = 59 tableZone[zonetime[i]]['Minutos'] = tableZone[zonetime[i]]['Minutos'] - 1 if tableZone[zonetime[i]]['Minutos'] <= 0 then tableZone[zonetime[i]]['Minutos'] = 59 if tableZone[zonetime[i]]['Horas'] > 0 then tableZone[zonetime[i]]['Horas'] = tableZone[zonetime[i]]['Horas'] - 1 end end end tableZone[zonetime[i]]['Segundos'] = tableZone[zonetime[i]]['Segundos'] - 1 if tableZone[zonetime[i]]['Segundos'] <= 0 and tableZone[zonetime[i]]['Horas'] == 0 then table.remove(zonetime, getPosZone (zonetime[i])) tableZone[zonetime[i]] = nil end end end, 1000, 0) function attWithinZone (zone) if tableZone[zone] then local player = nil for i=1, #getElementsWithinColShape(zone, "player" ) do player = getElementsWithinColShape(zone, "player" )[i] triggerClientEvent(player, 'rzk:load:timezone', resourceRoot, zone, true, tableZone[zone]['Horas'], tableZone[zone]['Minutos'], tableZone[zone]['Segundos']) end end end addEvent('rzk:ocupezone', true) addEventHandler('rzk:ocupezone', resourceRoot, function (player, zone, vehicle) if isElement(zone) then if checkZone (zone) then if not tableZone[zone] then table.insert(zonetime, zone) setElementData(vehicle, 'vehicle:desmanche', true) setElementData(player, 'player:vehicle', vehicle) else triggerClientEvent(player, 'cancel:service', resourceRoot) end else triggerClientEvent(player, 'cancel:service', resourceRoot) end end end) function exitZone (element) if getElementType (element) == "player" then triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, false) local vehicle = getPedOccupiedVehicle (element) if vehicle then removeEventHandler ( "onVehicleExit", vehicle, exitVehicle) myZone[element] = nil end end end function enterZone (element) if getElementType (element) == "player" then if tableZone[source] then triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, true, tableZone[source]['Horas'], tableZone[source]['Minutos'], tableZone[source]['Segundos']) else triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, true) end local vehicle = getPedOccupiedVehicle (element) if vehicle then addEventHandler ( "onVehicleExit", vehicle, exitVehicle) end myZone[element] = source end end local blackListVehicle = { [401]=true, } function exitVehicle (player, seat) if isElement(source) then if not tableZone[myZone[player]] then if not blackListVehicle[getElementModel(source)] then if seat == 0 then removeEventHandler ( "onVehicleExit", source, exitVehicle) triggerClientEvent(player, 'rzk:startprogress', resourceRoot, source, myZone[player]) else removeEventHandler ( "onVehicleExit", source, exitVehicle) end else exports.Mat_Infos:serverNotification(player, "info", "Esse veiculo não pode ser desmanchado.", 10, 25) removeEventHandler ( "onVehicleExit", source, exitVehicle) end else exports.Mat_Infos:serverNotification(player, "info", "Aguarde "..tableZone[myZone[player]]['Horas'].." Horas e "..tableZone[myZone[player]]['Minutos'].." Minutos para realizar outro desmanche.", 10, 25) end end myZone[player] = nil end addEventHandler ( "onVehicleStartEnter", getRootElement(), function ( player, seat, jacked ) if (getElementData(source, 'vehicle:desmanche')) then --if the vehicle is one of 4 police cars, and the skin is not a police skin cancelEvent() exports.Mat_Infos:serverNotification(player, "info", "Esse veiculo está sendo desmanchado.", 10, 25) end end) addEvent('rzk:action:vehicle', true) addEventHandler('rzk:action:vehicle', resourceRoot, function (vehicle, door, action) if isElement(vehicle) then local door = tonumber(door) setVehicleDoorOpenRatio (vehicle, door, action, 2000) end end) addEvent('rzk:remove:component', true) addEventHandler('rzk:remove:component', resourceRoot, function (vehicle, component) if isElement(vehicle) then local players = getElementsByType("player") local player = nil for i = 1, #players do player = players[i] triggerClientEvent(player, 'remove:component', resourceRoot, vehicle, component) end end end) addEvent('rzk:setAnimation', true) addEventHandler('rzk:setAnimation', resourceRoot, function (player, anim_1, anim_2) if isElement(player) then if anim_1 then setElementFrozen(player, true) setPedAnimation(player, anim_1, anim_2) else setPedAnimation(player) setElementFrozen(player, false) end end end) addEvent('rzk:destroyVehicle', true) addEventHandler('rzk:destroyVehicle', resourceRoot, function (player, vehicle) if isElement(vehicle) then setElementData(vehicle, 'vehicle:desmanche', nil) setElementData(player, 'player:vehicle', nil) destroyElement(vehicle) givePlayerMoney(player, math.random(100, 1000)) exports.Mat_Infos:serverNotification(player, "info", "Veiculo desmanchado com sucesso.", 10, 25) end end) addEventHandler ( "onPlayerQuit", root, function () if getElementData(source, 'player:vehicle') then local vehicle = getElementData(source, 'player:vehicle') setElementData(vehicle, 'vehicle:desmanche', nil) local players = getElementsByType("player") local player = nil for i = 1, #players do player = players[i] triggerClientEvent(player, 'reset:remove:component', resourceRoot, vehicle) end setElementData(source, 'player:vehicle', nil) end end) Link to comment
HiroShi Posted October 12, 2020 Share Posted October 12, 2020 basta usar isso: dbExec(db, "DELETE FROM Veiculos WHERE Conta = ? AND ID = ?", getAccountName(getPlayerAccount(player)), id_do_elemento) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now