EW1611
Members-
Posts
80 -
Joined
-
Last visited
Everything posted by EW1611
-
é, ao soltar a tecla que o player usa para acelerar o veículo Erro na linha 2: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'accelerate']; linha 3:Bad argument @ 'playSound3D' [Expected vector 3 at argument 2, got boolean]; linha 4: bad 'sound/player' pointer @ 'setSoundVolume'(1)
-
Olá fiz o seguinte script, para quando o player soltar o acelerador dar play no som, mas não da play e nenhum erro no debugscript, até tentei aumentar o volume, mas ainda não acontece nada: function blowoff(thePlayer) p = getPedOccupiedVehicle(thePlayer) id = getElementModel(p) if id == 562 then pos = getElementPosition(thePlayer) s1 = playSound3D("BlowOff.mp3", pos, true) setSoundVolume(s1, 10) end end function bnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleEnter", root, bnd) function ubnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleExit", root, ubnd) Obs: O áudio tem 1 segundo, não sei se pode ser isso
-
Olá, queria que quando acontecer um certo evento, ele mostrasse uma mensagem no chat dos players que estivessem em uma acl, alguém sabe me dizer como fazer e explicar como funciona a função?
-
Olá, fiz um alteração em uma hud, para mostrar a fome,sede e sono, porem, ela só pega os valores qndo o resource inicia, dps qndo é alterada, ela continua mostrando o msm numero, em vez de atualizar local Sono = getElementData ( localPlayer, "Sono" ) local Sede = getElementData ( localPlayer, "Sede" ) local Fome = getElementData ( localPlayer, "Fome" ) addEventHandler("onClientRender", root, function() dxDrawImage(screenW * 0.6332, screenH * 0.0729, screenW * 0.1881, screenH * 0.1068, "images/vida2.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.6523, screenH * 0.1146, screenW * 0.0220, screenH * 0.0313, "images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.7577, screenH * 0.1159, screenW * 0.0220, screenH * 0.0299, "images/sono.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(""..Fome.."", screenW * 0.6772, screenH * 0.1172, screenW * 0.6991, screenH * 0.1458, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText(""..Sede.."", screenW * 0.7255, screenH * 0.1172, screenW * 0.7474, screenH * 0.1458, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText(""..Sono.."", screenW * 0.7826, screenH * 0.1172, screenW * 0.8045, screenH * 0.1458, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawImage(screenW * 0.7035, screenH * 0.1159, screenW * 0.0220, screenH * 0.0299, "images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end )
-
Agora da um erro na linha 123: server.Lua:124: dbExec failed; (1) near ")": syntax error Na verdade foi um erro bobo, apaguei um "?" sem querer, está funcionando tudo certo
-
Ah, agora entendi, é que aquela primeira parte da função, era para o DX não mostrar quando em uma bike, mas está funcionando. Muito obrigado e desculpe o incômodo
-
Você diz as funções q eu usei que n fizeram sentido, ou a forma que eu montei ele?
-
era pra ser um mostrador de gasolina, que mostrasse qndo o player estivesse no carro, ele teria 10 retângulos sendo, 1 retângulo para 10% de combustível. Sabe me dizer como fazer certo?
-
Olá, fiz o código, é pra ser um mostrador de combustível, mas qndo entra no veiculo e sai, o dx continua lá, e tbm, ele só atualiza qndo o Fuel sobe, e sobrepõe os que já estavam, alguem sabe como fazer para atualizar sempre q o fuel mudar, e n sobrepor os outros? local screenW, screenH = guiGetScreenSize() local playerC = isPedInVehicle ( localPlayer ) local assento = getPedOccupiedVehicleSeat(localPlayer) function Hud(localPlayer) for i,v in ipairs(getElementsByType("vehicle")) do if getVehicleType (v) ~= "BMX" then if playerC then if assento >=0 then dxDrawLine(screenW * 0.7818, screenH * 0.7266, screenW * 0.7818, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.7279, screenW * 0.8075, screenH * 0.7279, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.9427, screenW * 0.8075, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) dxDrawImage(screenW * 0.7456, screenH * 0.7904, screenW * 0.0329, screenH * 0.0716, "FuelSzam.png", 0, 0, 0, tocolor(180, 180, 180, 255), false) local fuel = getElementData(v, "fuel") if (fuel)>=1 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9219, screenW * 0.0205, screenH * 0.0156, tocolor(255, 0, 0, 130), true) if (fuel)>=10 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9010, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=20 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8802, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=30 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8594, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=40 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8385, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=50 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8177, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=60 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7969, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=70 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7760, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=80 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7552, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=90 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7344, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) end end end end end end end end end end end end end end end addEventHandler("onClientPlayerVehicleEnter", root, Hud)
-
Olá, tenho um script de loja de veículos que salva toda a data em um arquivo database, e outro de combustível, eu qria que q quantidade de combustivel tbm fosse salva no arquivo database, eu não entendo direito disso, ja vi os tutorias do fórum. Server do script de gasolina factor = 0.03 function createVehicles(player) for i,v in ipairs(getElementsByType("vehicle")) do if getVehicleType (v) ~= "BMX" then fuel = math.random(10,25) setElementData(v, "fuel", fuel) end end end function processFuel(player) for i,v in ipairs(getElementsByType("vehicle")) do if getVehicleType (v) ~= "BMX" then local fuel = getElementData(v, "fuel") or math.random(10,25) if (getVehicleEngineState(v) and fuel > 0 ) then fuel = fuel - factor end if (fuel <= 0.99) then fuel = 0 setVehicleEngineState(v, false) end setElementData(v, "fuel", fuel) end end end createVehicles() setTimer(processFuel, 1000, 0) Server da loja de veículos: customCarNames = -- новые названия { } shopsVehSpawns = { [1] = { 2131, -1133, 25.6, 0,0,359 }, [2] = { 555, -1278, 18, 0,0,100 }, [3] = { 1941, 2097, 10.8, 0,0,350 }, [4] = { -1988, 272, 36, 0,0,259 }, [5] = { -1637, 1213, 7.17, 0,0,0 }, } function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList 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 function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP, new_hydr, fuel)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local fuel = getElementData(theVehicle, "fuel") local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ?, new_hydr = ?, fuel = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getElementData ( theVehicle, "NewHydr") and 1 or 0, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 25 then outputChatBox(" Desculpe, mas você só pode comprar #00FF6625#FFFFFF veiculos.", source, 38, 122, 216, true) return end if abc then outputChatBox(" Você já tem este veiculo.", source, 38, 122, 216, true) return end if getPlayerMoney(source) >= tonumber(cost) then takePlayerMoney ( source, cost ) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local shopID = getElementData ( source, "atVehShop") local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 if shopID and shopsVehSpawns[shopID] then vehicle = createVehicle(Model, shopsVehSpawns[shopID][1], shopsVehSpawns[shopID][2], shopsVehSpawns[shopID][3], shopsVehSpawns[shopID][4], shopsVehSpawns[shopID][6]) else vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) end setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000, 0) outputChatBox("#FFFFFF Por: #00FF66$"..cost, source, 38, 122, 216, true) updateVehicleInfo(source) setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source))) warpPedIntoVehicle ( source, vehicle ) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 150, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox(" Você não tem grana para comprar este veiculo.", source, 38, 122, 216, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox(" Seu veiculo #00FF66"..(customCarNames[data[1]["Model"]] or getVehicleNameFromModel(data[1]["Model"])).." #FFFFFF já está spawnado.", source, 38, 122, 216, true) else local color = split(data[1]["Colors"], ',') 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 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if tonumber(data[1]["HP"]) <= 255.5 then data[1]["HP"] = 255 end if data[1]["new_hydr"] and data[1]["new_hydr"] == 1 then setElementData(vehicle, "NewHydr", true) else setElementData(vehicle, "NewHydr", false) end setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source))) setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox(" Seu veiculo #00FF66"..(customCarNames[data[1]["Model"]] or getVehicleNameFromModel(data[1]["Model"])).." #FFFFFF foi spawnado.", source, 38, 122, 216, true) end else outputChatBox(" Há um problema com o veiculo, notifique o administrador.", source, 38, 122, 216, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not getElementData(vehicle, "ABlip") then setElementData(vehicle, "ABlip", true) createBlipAttachedTo(vehicle, 41, 2, 255, 0, 0, 255, 0, 65535, source) outputChatBox(" Seu veículo Foi Marcado no Mapa, Aperte F11 Pra Encontra-lo.", source, 38, 122, 216, true) else local attached = getAttachedElements(vehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end setElementData(vehicle, "ABlip", false) outputChatBox(" Seu veículo Foi Desmarcado do Mapa.", source, 38, 122, 216, true) end else outputChatBox(" Seu Veiculo Não foi Spawnado.", source, 38, 122, 216, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("# Seu veiculo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF teve as luzes acesas.", source, 38, 122, 216, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("# Seu veiculo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF teve as luzes apagadas.", source, 38, 122, 216, true) end else outputChatBox("# Você não está no veiculo!", source, 38, 122, 216, true) end else outputChatBox("# O seu veiculo não está spawnado.", source, 38, 122, 216, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("# O seu veículo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF foi #00FF66fechado.", source, 38, 122, 216, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) setVehicleDoorsUndamageable(vehicle, false) outputChatBox("# O seu veículo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF foi #00FF66aberto.", source, 38, 122, 216, true) end else outputChatBox("# O seu veiculo não foi spawnado.", source, 38, 122, 216, true) end end) addEvent("BlipMyVehicle", true) addEventHandler("BlipMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not getElementData(vehicle, "ABlip") then setElementData(vehicle, "ABlip", true) createBlipAttachedTo(vehicle, 41, 2, 255, 0, 0, 255, 0, 65535, source) outputChatBox("# O seu veículo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." # foi marcado no mapa, usar #00FF66F11# para encontrá-lo.", source, 38, 122, 216, true) else local attached = getAttachedElements(vehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end setElementData(vehicle, "ABlip", false) outputChatBox("# O seu veículo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF teve o blip removido.", source, 38, 122, 216, true) end else outputChatBox("# O seu veiculo não está spawnado.", source, 38, 122, 216, true) end end) addEvent("FixMyVehicle", true) addEventHandler("FixMyVehicle", root, function(id) if getPlayerMoney(source) >= tonumber(500) then takePlayerMoney ( source, 500 ) local vehicle = getVehicleByID(id) if isElement(vehicle) then fixVehicle(vehicle) setVehicleEngineState(vehicle, true) if isVehicleDamageProof(vehicle) then setVehicleDamageProof(vehicle, false) end end dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND ID = ?", 1000, getAccountName(getPlayerAccount(source)), id) updateVehicleInfo(source) outputChatBox ("# O seu veículo foi reparado.", source, 38, 122, 216, true) else outputChatBox("# Você não tem dinheiro suficiente para reparar.", source, 38, 122, 216, true) outputChatBox("# Preço: #00FF66$500.", source, 38, 122, 216, true) end end) addEvent("WarpMyVehicle", true) addEventHandler("WarpMyVehicle", root, function(id) if not isPedInVehicle (source) then if getElementInterior(source) == 0 then if getPlayerMoney(source) >= tonumber(500) then local vehicle = getVehicleByID(id) if isElement(vehicle) then takePlayerMoney ( source, 500 ) local x, y, z = getElementPosition(source) setElementPosition(vehicle, x, y, z) warpPedIntoVehicle ( source, vehicle ) outputChatBox ("# O seu veiculo #00FF66"..(customCarNames[getElementModel(vehicle)] or getVehicleNameFromModel(getElementModel(vehicle))).." #FFFFFF foi entregue a você.", source, 38, 122, 216, true) else outputChatBox("# O seu veiculo não está spawnado.", source, 38, 122, 216, true) end else outputChatBox("# Você não tem os meios de se teletransportar para o veiculo.", source, 38, 122, 216, true) end else outputChatBox("# Você só poderá mudar de veiculo se sair do atual.", source, 38, 122, 216, true) end else outputChatBox("# Nós não podemos dirigir seu veiculo. Por favor, sair do outro veiculo.", source, 38, 122, 216, true) end end) addEvent("SellMyVehicle", true) addEventHandler("SellMyVehicle", root, function(id) local vehicle = getVehicleByID(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then local Money = math.ceil((data[1]["Cost"]*.9)*math.floor(data[1]["HP"])/100/10) givePlayerMoney (source, Money) if isElement(vehicle) then destroyElement(vehicle) end dbExec(db, "DELETE FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id) updateVehicleInfo(source) outputChatBox("# Você vendeu o seu veiculo por #00FF66$"..Money, source, 38, 122, 216, true) end end) function getDataOnLogin(_, account) updateVehicleInfo(source) end addEventHandler("onPlayerLogin", root, getDataOnLogin) function SaveVehicleDataOnQuit() for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "Owner") == source then destroyVehicle(veh) end end end addEventHandler("onPlayerQuit", root,SaveVehicleDataOnQuit) addEvent("inviteToBuyCarSended", true) addEventHandler("inviteToBuyCarSended", root, function(player, price, veh_name, veh_id) if player and price and veh_name and veh_id then local pl = getPlayerFromName ( player ) if pl then triggerClientEvent ( pl, "recieveInviteToBuyCar", pl, getPlayerName (source), getAccountName(getPlayerAccount(source)), price, veh_name, veh_id ) else outputChatBox ( "# O jogador não foi encontrado, a venda foi cancelada", source, 250, 10, 10, true) triggerClientEvent ( source, "cleanCarInvitations", source ) end end end) addEvent("invitationBuyCarNotAccepted", true) addEventHandler("invitationBuyCarNotAccepted", root, function(player, acc, price, veh_name, veh_id) local pl = getPlayerFromName ( player ) if pl then triggerClientEvent ( pl, "cleanCarInvitations", pl ) outputChatBox ( "# O jogador recusou-se a comprar o seu carro", pl, 250, 10, 10,true) end end) addEvent("invitationBuyCarAccepted", true) addEventHandler("invitationBuyCarAccepted", root, function(player, acc, price, veh_name, veh_id) local carName = customCarNames[ v[1] ] or getVehicleNameFromModel(v[1]) local pl = getPlayerFromName ( player ) local avail = false if pl and getAccountName ( getPlayerAccount (pl)) == acc then avail = true triggerClientEvent ( pl, "cleanCarInvitations", pl ) --outputChatBox ( "Игрок отказался покупать ваше авто", pl, 250, 10, 10) else for i, v in ipairs( getElementsByType ( 'player' ) ) do if getAccountName(getPlayerAccount ( v )) == acc then avail = true pl = v break end end end price = tonumber(price) or 0 if avail then if isGuestAccount ( getPlayerAccount ( source ) ) then triggerClientEvent ( pl, "cleanCarInvitations", pl ) outputChatBox ( "# Você não está logado em sua conta, a transação foi cancelada", source, 250, 10, 10,true ) outputChatBox ( "# O jogador não entrou na conta, a transação foi cancelada", pl, 250, 10, 10,true ) return true end if getPlayerMoney ( source ) >= price then local vehicle = getVehicleByID(tonumber(veh_id)) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(pl)), veh_id), -1) if type(data) == "table" and #data ~= 0 and isElement ( vehicle ) then givePlayerMoney ( pl, price ) takePlayerMoney ( source, price ) dbExec(db, "UPDATE VehicleList SET Account = ? WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), getAccountName(getPlayerAccount(pl)), veh_id) updateVehicleInfo(source) updateVehicleInfo(pl) setElementData(vehicle, "Owner", source) setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source))) outputChatBox("# Você vendeu o seu veiculo por #00FF66$"..price, pl, 38, 122, 216, true) outputChatBox("# Você comprou um carro por #00FF66$"..price, source, 38, 122, 216, true) triggerClientEvent ( pl, "cleanCarInvitations", pl ) else outputChatBox ( "# A máquina não pode ser encontrado, o negócio é cancelado", source, 250, 10, 10,true ) outputChatBox ( "# A máquina não pode ser encontrado, o negócio é cancelado. Tente carro desova.", pl, 250, 10, 10,true ) triggerClientEvent ( pl, "cleanCarInvitations", pl ) end else outputChatBox ( "# Você não tem dinheiro suficiente, a transação foi cancelada", source, 250, 10, 10,true ) end else outputChatBox ( "# O jogador não foi encontrado, a operação foi cancelada", source, 250, 10, 10,true) end end) function getDataOnLogin(_, account) updateVehicleInfo(source) end addEventHandler("onPlayerLogin", root, getDataOnLogin) function SaveVehicleDataOnQuit() for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "Owner") == source then destroyVehicle(veh) end end end addEventHandler("onPlayerQuit", root,SaveVehicleDataOnQuit) No log do server mostra isso: server.Lua:80: dbExec failed; (1) no such column: fuel
-
Olá, baixei um carro, ele vem com outras .txd q seriam os paintjob, tem uma função pra isso?
-
getElementData no client, de elemento do server
EW1611 replied to EW1611's topic in Programação em Lua
saberia explicar esse script? -
olá, criei um elemento no server-side, mas qrio pegar a data dele no lado client, para por no DX, mas da o seguinte erro: Bad argument @'getElementData' [Expected element at argument 1, got string 'candidato1] parte dos elementos no client local votos1 = getElementData("candidato1","votos") or 0 local votos2 = getElementData("candidato2","votos") or 0 local votosB = getElementData("vbrancos","votosB") or 0
-
Entendi, muito obrigado pela ajuda. o certo é usar setAccountData, para se caso o player saia do server sem votar, quando ele voltar, ele ainda possa votar?
-
Ah sim, é que eu meio que copiei essas funções de um outro script q eu tinha, obg por me avisar
-
Você diz o accountname? Consegue pfv me explicar o poque não se usa?
-
Agora está funcionando function setVote() for i, source in ipairs(getElementsByType("player")) do accountname = getAccountName(getPlayerAccount(source)) accountname1 = getPlayerAccount(source) if isObjectInACLGroup("user."..accountname, aclGetGroup("Everyone")) then setAccountData(accountname1, "votos", 1) end end end addEventHandler("onResourceStart", getRootElement(), setVote) function teste(thePlayer) accountname = getPlayerAccount(thePlayer) votos = getAccountData(accountname, "votos", 1) outputChatBox("Você tem "..votos.." voto", thePlayer, 255, 255, 255, true) end addCommandHandler("votos", teste)
-
Não sabia disso, obrigado por me dizer, mas acabou que mudei o script fiz assim agr, e funcionou como eu queria local marker1 = createMarker(-2432.2885742188,-614.54174804688,131.56077575684, "cylinder", 1, 255, 255, 255, 255) local rendering = nil addEventHandler ("onClientMarkerHit", resourceRoot, function (hitPlayer, matchingDimension) if source == marker1 then if not rendering then addEventHandler ("onClientRender", root, DX1) rendering = true botao1 = guiCreateButton(780, 462, 74, 37, "", false) guiSetAlpha(botao1, 255) botao2 = guiCreateButton(0.23, 0.28, 0.31, 0.08, "", true) guiSetAlpha(botao2, 255) botao3 = guiCreateButton(0.23, 0.37, 0.31, 0.08, "", true) guiSetAlpha(botao3, 255) showCursor(true, false) end end end) addEventHandler ("onClientMarkerLeave", resourceRoot, function (hitPlayer, matchingDimension) if source == marker1 then if rendering then removeEventHandler ("onClientRender", root, DX1) rendering = false destroyElement(botao1) destroyElement(botao2) destroyElement(botao3) showCursor(false, false) end end end) local screenW, screenH = guiGetScreenSize() function DX1 (hitPlayer) dxDrawImage(screenW * 0.1999, screenH * 0.2331, screenW * 0.6003, screenH * 0.5339, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawLine((screenW * 0.2277) - 1, (screenH * 0.2747) - 1, (screenW * 0.2277) - 1, screenH * 0.3620, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, (screenH * 0.2747) - 1, (screenW * 0.2277) - 1, (screenH * 0.2747) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawLine((screenW * 0.2277) - 1, screenH * 0.3620, screenW * 0.5388, screenH * 0.3620, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, screenH * 0.3620, screenW * 0.5388, (screenH * 0.2747) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawRectangle(screenW * 0.2277, screenH * 0.2747, screenW * 0.3111, screenH * 0.0872, tocolor(254, 254, 254, 86), false) dxDrawLine((screenW * 0.2277) - 1, (screenH * 0.3698) - 1, (screenW * 0.2277) - 1, screenH * 0.4570, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, (screenH * 0.3698) - 1, (screenW * 0.2277) - 1, (screenH * 0.3698) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawLine((screenW * 0.2277) - 1, screenH * 0.4570, screenW * 0.5388, screenH * 0.4570, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, screenH * 0.4570, screenW * 0.5388, (screenH * 0.3698) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawRectangle(screenW * 0.2277, screenH * 0.3698, screenW * 0.3111, screenH * 0.0872, tocolor(254, 254, 254, 86), false) dxDrawImage(screenW * 0.2350, screenH * 0.2813, screenW * 0.0469, screenH * 0.0755, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.2350, screenH * 0.3750, screenW * 0.0469, screenH * 0.0755, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("", screenW * 0.2936, screenH * 0.3958, screenW * 0.4605, screenH * 0.4323, tocolor(0, 0, 0, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("", screenW * 0.2943, screenH * 0.3008, screenW * 0.4612, screenH * 0.3372, tocolor(0, 0, 0, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawLine((screenW * 0.1999) - 1, (screenH * 0.1615) - 1, (screenW * 0.1999) - 1, screenH * 0.2253, tocolor(254, 254, 254, 182), 1, false) dxDrawLine(screenW * 0.8001, (screenH * 0.1615) - 1, (screenW * 0.1999) - 1, (screenH * 0.1615) - 1, tocolor(254, 254, 254, 182), 1, false) dxDrawLine((screenW * 0.1999) - 1, screenH * 0.2253, screenW * 0.8001, screenH * 0.2253, tocolor(254, 254, 254, 182), 1, false) dxDrawLine(screenW * 0.8001, screenH * 0.2253, screenW * 0.8001, (screenH * 0.1615) - 1, tocolor(254, 254, 254, 182), 1, false) dxDrawRectangle(screenW * 0.1999, screenH * 0.1615, screenW * 0.6003, screenH * 0.0638, tocolor(0, 0, 0, 114), false) dxDrawText("", screenW * 0.2079, screenH * 0.1706, screenW * 0.7928, screenH * 0.2122, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "bottom", false, false, false, false, false) dxDrawRectangle(screenW * 0.5710, screenH * 0.6016, screenW * 0.0542, screenH * 0.0430, tocolor(254, 254, 254, 0), false) end
-
Ainda da os mesmos erros na primeira função: WARNING: [--Script--]\Votação\server.Lua:5: Bad argument @ 'setAccountData' [Expected account at argument 1, got string 'user.EW1611'] E na segunda função: WARNING: [--Script--]\Votação\server.Lua:13: Bad argument @ 'getAccountData' [Expected account at argument 1, got string 'EW1611'] ERROR: [--Script--]\Votação\server.Lua:14: attempt to concatenate local 'votos' (a boolean value)
-
olá, fiz um script que, quando ele inicia, era pra ser setado 1 voto para o player votar, mas da estes erros: https://imgur.com/a/phI8sMg o código server: function setVote(source) for i, source in ipairs(getElementsByType("player")) do local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accountname, aclGetGroup("Everyone")) then setAccountData("user."..accountname, "votos", 1) end end end addEventHandler("onResourceStart", getRootElement(), setVote) function teste(thePlayer) accountname = getAccountName(getPlayerAccount(thePlayer)) local votos = getAccountData(accountname, "votos", 1) outputChatBox("Você tem "..votos.." voto", thePlayer, 255, 255, 255, true) end addCommandHandler("votos", teste)
-
Já consegui fazer, criei os botões, e dps defini o alpha deles com o guiSetAlpha em 0, porem ele não sai da tela, então usei o destroyElement
-
Olá, eu de novo, tenho um painel pronto, ainda não testei, mas queria que ao clicar em uma parte começasse a função, teria como deixar os botões invisíveis? marker1 = createMarker(-2432.2885742188,-614.54174804688,132.56077575684, "cylinder", 255, 255, 255, 255) local screenW, screenH = guiGetScreenSize() function DX1 (localPayer) guiCreateButton(0.23, 0.28, 0.31, 0.08, "", true) guiCreateButton(0.23, 0.37, 0.31, 0.08, "", true) dxDrawImage(screenW * 0.1999, screenH * 0.2331, screenW * 0.6003, screenH * 0.5339, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawLine((screenW * 0.2277) - 1, (screenH * 0.2747) - 1, (screenW * 0.2277) - 1, screenH * 0.3620, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, (screenH * 0.2747) - 1, (screenW * 0.2277) - 1, (screenH * 0.2747) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawLine((screenW * 0.2277) - 1, screenH * 0.3620, screenW * 0.5388, screenH * 0.3620, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, screenH * 0.3620, screenW * 0.5388, (screenH * 0.2747) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawRectangle(screenW * 0.2277, screenH * 0.2747, screenW * 0.3111, screenH * 0.0872, tocolor(254, 254, 254, 86), false) dxDrawLine((screenW * 0.2277) - 1, (screenH * 0.3698) - 1, (screenW * 0.2277) - 1, screenH * 0.4570, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, (screenH * 0.3698) - 1, (screenW * 0.2277) - 1, (screenH * 0.3698) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawLine((screenW * 0.2277) - 1, screenH * 0.4570, screenW * 0.5388, screenH * 0.4570, tocolor(207, 207, 207, 255), 1, false) dxDrawLine(screenW * 0.5388, screenH * 0.4570, screenW * 0.5388, (screenH * 0.3698) - 1, tocolor(207, 207, 207, 255), 1, false) dxDrawRectangle(screenW * 0.2277, screenH * 0.3698, screenW * 0.3111, screenH * 0.0872, tocolor(254, 254, 254, 86), false) dxDrawImage(screenW * 0.2350, screenH * 0.2813, screenW * 0.0469, screenH * 0.0755, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.2350, screenH * 0.3750, screenW * 0.0469, screenH * 0.0755, "", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("", screenW * 0.2936, screenH * 0.3958, screenW * 0.4605, screenH * 0.4323, tocolor(0, 0, 0, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("", screenW * 0.2943, screenH * 0.3008, screenW * 0.4612, screenH * 0.3372, tocolor(0, 0, 0, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawLine((screenW * 0.1999) - 1, (screenH * 0.1615) - 1, (screenW * 0.1999) - 1, screenH * 0.2253, tocolor(254, 254, 254, 182), 1, false) dxDrawLine(screenW * 0.8001, (screenH * 0.1615) - 1, (screenW * 0.1999) - 1, (screenH * 0.1615) - 1, tocolor(254, 254, 254, 182), 1, false) dxDrawLine((screenW * 0.1999) - 1, screenH * 0.2253, screenW * 0.8001, screenH * 0.2253, tocolor(254, 254, 254, 182), 1, false) dxDrawLine(screenW * 0.8001, screenH * 0.2253, screenW * 0.8001, (screenH * 0.1615) - 1, tocolor(254, 254, 254, 182), 1, false) dxDrawRectangle(screenW * 0.1999, screenH * 0.1615, screenW * 0.6003, screenH * 0.0638, tocolor(0, 0, 0, 114), false) dxDrawText("", screenW * 0.2079, screenH * 0.1706, screenW * 0.7928, screenH * 0.2122, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "bottom", false, false, false, false, false) dxDrawRectangle(screenW * 0.5710, screenH * 0.6016, screenW * 0.0542, screenH * 0.0430, tocolor(254, 254, 254, 0), false) end addEventHandler("onMarkerHit", marker1, DX1)
-
Da algum erro no script? No debug script?
-
Olá, modelei um prédio no sketchup, com partes em vidro, tinha visto em algum fórum que para colocar vidro em um prédio do gta msm teria que mudar o ide, mas n achei nd sobre isso no mta, alguem saberia dizer melhor? e outra, preciso fazer algo para mudar o model de um prédio que ja está no gta, alem do normal(como se fosse com carros)?
