Bom dia, tenho um script de concessionaria e não quero que os jogador venda o carro quando os carro está spawnados, par a verificação do script eu devo usar setElementData ou algum evento. Bom eu dei uma olhada e coloquei esse codigo
< if tabela.state == "Spawnado" then notifyS(player, "Você não pode vender veículos spawnados!", "error") return end >
Código da concessionaria server.lua (parte de spawn)
<
addEvent("JOAO.manageVehicleGARAGEM", true)
addEventHandler("JOAO.manageVehicleGARAGEM", root,
function(player, type, tabela, indexMarker)
if insertSpam(player) then
notifyS(player, "Aguarde alguns segundos...", "info")
return
end
local vehicle = getVehicleCar2(player, tonumber(tabela.idCar))
if type == "retirar" then
if tabela.state == "Spawnado" then
notifyS(player, "Seu veículo já está spawnado!", "error")
else
if tonumber(tabela.imposto) <= getRealTime().timestamp then
notifyS(player, "Esse veículo está com imposto, portanto não é possível pegar ele!", "error")
else
if isElement(vehicle) then
notifyS(player, "Você já tem um veículo spawnado!", "error")
else
local dadosVeh = fromJSON(tabela.dataCar)
local color = (dadosVeh[1].color)
local colorLight = (dadosVeh[1].light)
local tuningA = fromJSON(tabela.tuning)
vehicle = createVehicle(tabela.idCar, config["Markers"][indexMarker][5], config["Markers"][indexMarker][6], config["Markers"][indexMarker][7])
for i, v in pairs(tuningA) do
if v then
if i == "pneu" then
addVehicleUpgrade(vehicle, v[1])
elseif i == "neonA" then
setElementData(vehicle, "tuning.neon", v[1])
setElementData(vehicle, "vehicle.neon.active", true)
end
setElementData(vehicle, "tuning."..i, v)
end
end
setVehicleHeadLightColor(vehicle, colorLight[1], colorLight[2], colorLight[3])
setVehicleColor(vehicle, color[1], color[2], color[3], color[4], color[5], color[6], color[7], color[8], color[9], color[10], color[11], color[12])
setElementData(vehicle, "JOAO.idVehicle", tabela.idColum)
setVehiclePlateText(vehicle, tabela.placa)
setElementHealth(vehicle, dadosVeh[1].vida)
setElementData(vehicle, "JOAO.fuel", dadosVeh[1].gasolina)
setElementData(vehicle, "Owner", player)
notifyS(player, "Você spawnou o veículo com sucesso!", "success")
contaDono[vehicle] = getAccountName(getPlayerAccount(player))
dados[vehicle] = {owner = player, account = getAccountName(getPlayerAccount(player)), id = tabela.idColum, rgDono = puxarID(player), seguroCar = tabela.seguro}
dbExec(db, 'UPDATE Carros SET state = ? WHERE ID = ?', "Spawnado", tabela.idColum)
end
end
end
elseif type == "guardar" then
if tabela.state == "Guardado" then
notifyS(player, "Seu veículo já está guardado!", "error")
else
if isElement(vehicle) then
local posVeh = {getElementPosition(vehicle)}
local pos = {getElementPosition(player)}
local distance = getDistanceBetweenPoints3D(posVeh[1], posVeh[2], posVeh[3], pos[1], pos[2], pos[3])
if distance <= 12 then
saveDadosVeh(vehicle)
if isElement(vehicle) then destroyElement(vehicle) end
if isElement(blip[player]) then destroyElement(blip[player]) end
notifyS(player, "Você guardou o veículo com sucesso!", "success")
dbExec(db, 'UPDATE Carros SET state = ? WHERE ID = ?', "Guardado", dados[vehicle].id)
else
notifyS(player, "O veículo não está próximo a você!", "error")
end
else
notifyS(player, "Erro ao guardar o veículo!", "error")
end
end
end
sendData(player, "garagem")
end)
>
Parte de vender
<
function(player, tabela, id, valores, tipomoney, tipo)
local infos = fromJSON(tabela.dataCar)
local vehicle = getVehicleCar2(player, tonumber(tabela.idCar))
if insertSpam(player) then
notifyS(player, "Aguarde alguns segundos...", "info")
return
end
if infos[1].marca == "Exclusivo" then
notifyS(player, "Esse veículo é exclusivo!", "error")
else
if tipo == "conce" then
if tabela.state == "Recuperar" or tonumber(tabela.imposto) <= getRealTime().timestamp then
notifyS(player, "Seu veículo precisa ser recuperado ou pagar imposto para poder vender!", "error")
else
if infos[1].typePago == "dinheiro" then
givePlayerMoney(player, (infos[1].price-(10*infos[1].price/100)))
notifyS(player, "Você vendeu seu carro para a concessionária e recebeu R$ "..formatNumber((infos[1].price-(10*infos[1].price/100)))..",00!", "info")
dbExec(db, 'DELETE FROM Carros WHERE ID = ?', tabela.idColum)
if isElement(vehicle) then destroyElement(vehicle) end
sendData(player, "garagem")
exports["astral_util"]:messageDiscord("O jogador(a) "..(exports["astral_util"]:puxarNome(player)).." ("..(exports["astral_util"]:puxarID(player))..") SE REPETIU A MSG 2 VEZES = DUP", "https://discord.com/api/webhooks/1189504786744221748/PysgtxxTlTVAVXT1VHNaqxqyCbhyOUX89XWfJFKLZeeSPFMnTtxOwTew2MVZRj7vReZc")
else
local atualVP = (getElementData(player, "moneycoins") or 0)
setElementData(player, "moneycoins", atualVP+(infos[1].pricevp-(10*infos[1].pricevp/100)))
notifyS(player, "Você vendeu seu carro para a concessionária e recebeu v$ "..formatNumber((infos[1].pricevp-(10*infos[1].pricevp/100))).."!", "info")
dbExec(db, 'DELETE FROM Carros WHERE ID = ?', tabela.idColum)
if isElement(vehicle) then destroyElement(vehicle) end
sendData(player, "garagem")
exports["astral_util"]:messageDiscord("O jogador(a) "..(exports["astral_util"]:puxarNome(player)).." ("..(exports["astral_util"]:puxarID(player))..") SE REPETIU A MSG 2 VEZES = DUP", "https://discord.com/api/webhooks/1189504786744221748/PysgtxxTlTVAVXT1VHNaqxqyCbhyOUX89XWfJFKLZeeSPFMnTtxOwTew2MVZRj7vReZc")
end
end
else
if verifyNumber(valores) then
notifyS(player, "Você precisa digitar um valor em número!", "error")
else
if verifyNumber(id) then
notifyS(player, "Você precisa digitar um ID em número!", "error")
else
local receiver = getPlayerFromID(tonumber(id))
if isElement(receiver) then
if proposta[receiver] then
notifyS(player, "Esse jogador já tem uma proposta pendente!", "error")
else
if infos[1].typePago ~= "dinheiro" then notifyS(player, "Você não pode vender carro que não seja comprado por money!", "error") return end
if tabela.state == "Spawnado" then notifyS(player, "Você não pode vender veículos spawnados!", "error") return end
if tabela.state == "Recuperar" or tonumber(tabela.imposto) <= getRealTime().timestamp then
notifyS(player, "Seu veículo precisa ser recuperado ou pagar imposto para poder vender!", "error")
else
if tipomoney == "money" then
if getPlayerMoney(receiver) >= valores then
proposta[receiver] = {(getElementData(player, "ID") or 0)}
dadosVenda[receiver] = {valores, infos[1].name, "money", tabela.idColum, tabela.idCar, tabela.state}
notifyS(player, "Você enviou a proposta do veículo "..(infos[1].name).." com sucesso para o jogador "..puxarNome(receiver).."("..puxarID(receiver)..")", "success")
notifyS(receiver, "Você recebeu a proposta do veículo "..(infos[1].name).." para aceitar digite /aceitarcar ou /negarcar", "info")
else
notifyS(player, "O jogador que você está oferecendo o carro não tem dinheiro suficiente!", "error")
end
else
local pontos = getElementData(receiver, "moneycoins") or 0
if pontos >= valores then
proposta[receiver] = {(getElementData(player, "ID") or 0)}
dadosVenda[receiver] = {valores, infos[1].name, "pontos", tabela.idColum, tabela.idCar, tabela.state}
setElementData(receiver, "propostaConce", (getElementData(player, "ID") or 0))
notifyS(player, "Você enviou a proposta do veículo "..(infos[1].name).." com sucesso para o jogador "..puxarNome(receiver).."("..puxarID(receiver)..")", "success")
notifyS(receiver, "Você recebeu a proposta do veículo "..(infos[1].name).." para aceitar digite /aceitarcar ou /negarcar", "info")
else
notifyS(player, "O jogador que você está oferecendo o carro não tem Cash suficiente!", "error")
end
end
end
end
else
notifyS(player, "Esse jogador não está online!", "error")
end
end
end
end
end
end)
>