Jump to content

main

Members
  • Posts

    112
  • Joined

  • Days Won

    1

Everything posted by main

  1. Como você usou o fromJSON? acho que houve um equívoco aí Vou deixar um exemplo de uso abaixo local test = {} addEventHandler("onResourceStart", resourceRoot, function() local weapons = {[24] = 1000, [31] = 1000} -- vamos supor que quero salvar o id da arma e a munição na tabela 'test' test = toJSON(weapons) local player = getPlayerFromName("main") for k, v in pairs(fromJSON(test)) do -- faço um loop na tabela com fromJSON local id, ammo = tonumber(k), v giveWeapon(player, id, ammo, true) end end )
  2. Isso deve resolver: string.format("%.1f", tostring(peso))
  3. This is a great resource, but cause lower fps.
  4. Coloque para ler primeiro o arquivo que contém as variáveis globais <meta> <info author="Gaimo"/> <script src="c.Lua" type="client"/> <script src="vars.Lua" type="server"/> <script src="s.Lua" type="server"/> </meta>
  5. Aqui está o erro, os três primeiros argumentos não condiz com a posição desejada do texto resultando em um não aparecimento do texto mediante a verificação de distancia if getDistanceBetweenPoints3D(0 , 0, 4 + 5, x, y, z) < 10 then Desta forma, deve solucionar o problema: local pX,pY,pZ = 1007.8150024414, -1993.7969970703, 13.155365943909 function texto() local x,y,z = getElementPosition( source ) if getDistanceBetweenPoints3D(pX, pY, pZ, x, y, z) < 10 then local coords = {getScreenFromWorldPosition(pX,pY,pZ)} if coords[1] and coords[2] then dxDrawText("teste", coords[1], coords[2], coords[1], coords[2], tocolor(0, 5, 254, 255), 4.00, "sans", "center", "center", false, false, false, false, false) end end end addEventHandler("onClientRender", root,texto)
  6. Não necessita do source como parâmetro no server-side -- CLIENT-SIDE triggerServerEvent ( "onGreeting", localPlayer, guiGetText ( GUIEditor.edit[1] ) ) -- SERVER-SIDE function greetingHandler ( message ) local data = getAccountData ( getAccount("database", "senha"), message ) if data then outputChatBox("Jogador : "..getPlayerName(source), source, 255, 255, 255, true) else outputChatBox("Não achei :(", source, 255,255,255, true) end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler )
  7. Basta verificar no evento onClientMarkerHit se o hitElement é igual a localPlayer addEventHandler( "onClientMarkerHit", getRootElement(), function (thePlayer, dim) -- Source = Marker que o player hitou if dim and thePlayer == localPlayer then if source == getJob and not isPedInVehicle(thePlayer) then showPanel(thePlayer) end if source == startMarker then -- Avisar se o jogador já tem as caixas e não pode pegar mais if aBoxes >= 10 then outputChatBox("Aviso, player ja tem as caixas") return end -- Roda alguma animacao frozen(thePlayer, 3000) -- Seta a quantidade de caixas pra 10 aBoxes = 3 -- Gera uma rota aleatoria setTimer(function() rota() end, 3000, 1) end -- Se o marker existe e eh o destino do player if target ~= nil and source == target then del() frozen(thePlayer, 3000) -- Paga o player setElementData(localPlayer, "dinheiro", math.random(100, 200)) -- Faz alguma animacao e para o carro -- Diminui uma caixa aBoxes = aBoxes - 1 -- Informa a quantidade de caixas outputChatBox("Caixas restantes: "..aBoxes) if aBoxes > 0 then -- Gera uma rota aleatoria setTimer(function() rota() end, 3000, 1) elseif aBoxes == 0 then outputChatBox("Retorne ao estoque para pegar mais caixas.") end end end end)
  8. local tempoMensagem = 5 -- Tempo em minutos para aparecer a mensagem local enviarMensagem = { "#FFFFFFO banco cobrou #FFFF00{1} #FFFFFFda sua conta.", "#FFFFFFVocê perdeu #FFFF00{1} #FFFFFFquando estava a caminho do trabalho." } setTimer(function() for _, player in ipairs(getElementsByType("player")) do local value = math.random(100, 1000) takePlayerMoney(player, value) local randomMessage = enviarMensagem[math.random(1, #enviarMensagem)] outputChatBox(format(randomMessage, value), root, 255, 255, 255, true) end end, 60000 * tempoMensagem, 0) function format(s, ...) local result = s for k, v in ipairs({...}) do result = string.gsub(result, string.format("{%d}",k), v) end return result end
  9. Depurei o código e sim, estão sendo salvas porém na pos { 0, 0, 0 }.
  10. To com um problema no servidor referente ao spawn no 'limbo' ( pos { 0, 0, 0 } ); Alguns jogadores spawnam no 'limbo' após cair do servidor por perda de pacote ou algo relacionado a isso; Parece que antes de acontecer isso ele é direcionado pro limbo por padrão. Tentei uma forma de solucionar no meu save-system, porém não obtive sucesso. Há alguma forma melhor de solucionar isso? local joinX, joinY, joinZ = 1481.1440429688, -1766.98828125, 18.795755386353 local spawnX, spawnY, spawnZ, rotZ = 2029.8, -1406.0, 23.1, 180 function loadAccountData(source) if isElement(source) then local account = getPlayerAccount(source) local position = getAccountData(account, "funmodev2-position") or toJSON({joinX, joinY, joinZ}) local rotation = getAccountData(account, "funmodev2-rotation") or 0 local interior = getAccountData(account, "funmodev2-int") or 0 local dimensao = getAccountData(account, "funmodev2-dim") or 0 local skin = getAccountData(account, "funmodev2-skin") or 0 local health = getAccountData(account, "funmodev2-health") or 100 local armor = getAccountData(account, "funmodev2-armor") or 0 local money = getAccountData(account, "funmodev2-money") or 0 local wanted = getAccountData(account, "funmodev2-wantedlevel") or 0 local clothes = getAccountData(account, "funmondev2-clothes") local stats = getAccountData(account, "funmodev2-stats") local weapons = getAccountData(account, "funmodev2-weapons") local firstLogin = getAccountData(account, "Registrado") local x, y, z = unpack(fromJSON(position)) spawnPlayer(source, x, y, z, rotation, skin, interior, dimensao) setElementHealth(source, health) setPedArmor(source, armor) setPlayerWantedLevel(source, wanted) if not firstLogin then setAccountData(account, "Registrado", true) givePlayerMoney(source, 2000) else setPlayerMoney(source, money) end if clothes then removeAllPedClothes(source) for _, clothe in pairs(fromJSON(clothes)) do local tipo, texture, model = unpack(clothe) addPedClothes(source, texture, model, tipo) end end if stats then for stat, value in pairs(fromJSON(stats)) do setPedStat(source, stat, value) end end if weapons then takeAllWeapons(source) for weapon, ammo in pairs(fromJSON(weapons)) do giveWeapon(source, weapon, ammo, false) end end end end function saveAccountData(source) if isElement(source) then local account = getPlayerAccount(source) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local interior = getElementInterior(source) local dimensao = getElementDimension(source) local skin = getElementModel(source) local health = getElementHealth(source) local armor = getPedArmor(source) local money = getPlayerMoney(source) local wanted = getPlayerWantedLevel(source) local clothes = getAllPedClothes(source) local stats = getAllPedStats(source) local weapons = getAllPedWeapon(source) setAccountData(account, "funmodev2-position", toJSON({x, y, z})) setAccountData(account, "funmodev2-rotation", rz) setAccountData(account, "funmodev2-int", interior) setAccountData(account, "funmodev2-dim", dimensao) setAccountData(account, "funmodev2-skin", skin) setAccountData(account, "funmodev2-health", health) setAccountData(account, "funmodev2-armor", armor) setAccountData(account, "funmodev2-money", money) setAccountData(account, "funmodev2-wantedlevel", wanted) setAccountData(account, "funmondev2-clothes", toJSON(clothes)) setAccountData(account, "funmodev2-stats", toJSON(stats)) setAccountData(account, "funmodev2-weapons", toJSON(weapons)) end end addEventHandler("onPlayerSpawn", root, function() local posPlayer = Vector3(getElementPosition(source)) if posPlayer.x == 0 and posPlayer.y == 0 then setElementPosition(source, spawnX, spawnY, spawnZ) end fadeCamera(source, true) setCameraTarget(source, source) end) addEventHandler("onResourceStart", resourceRoot, function() for _, thePlayer in ipairs(getElementsByType("player")) do local account = getPlayerAccount(thePlayer) if not isGuestAccount(account) then loadAccountData(thePlayer) end end end) addEventHandler("onResourceStop", resourceRoot, function() for _, thePlayer in ipairs(getElementsByType("player")) do local account = getPlayerAccount(thePlayer) if not isGuestAccount(account) then saveAccountData(thePlayer) end end end) addEventHandler("onPlayerLogin", root, function() loadAccountData(source) end) addEventHandler("onPlayerQuit", root, function() local account = getPlayerAccount(source) if not isGuestAccount(account) then saveAccountData(source) end end) addEventHandler("onPlayerLogout", root, function() saveAccountData(source) end) addEventHandler("onPlayerWasted", root, function() takePlayerMoney(source, math.random(250, 500)) setTimer(spawnPlayer, 2500, 1, source, spawnX+math.random(-3,3), spawnY+math.random(-3,3), spawnZ, rotZ, getElementModel(source)) end) ---------------------------------------------------------------------------------------------------- --- FUNCTIONS --- ---------------------------------------------------------------------------------------------------- function getAllPedClothes(thePed) local clothes = { } for i=0, 17 do local texture, model = getPedClothes(thePed, i) if (texture) and (model) then table.insert(clothes, {i, texture, model}) end end return clothes end function removeAllPedClothes(thePed) for i=0, 17 do removePedClothes(thePed, i) end return true end function getAllPedStats(thePed) local stats = {} for stat=0, 230 do local value = getPedStat(thePed, stat) if (value) and (value > 0) then stats[stat] = value end end return stats end function getAllPedWeapon(thePed) local weapons = {} for slot=1, 12 do local weapon = getPedWeapon(thePed, slot) local ammo = getPedTotalAmmo(thePed, slot) if (weapon > 0) and (ammo > 0) then weapons[weapon] = ammo end end return weapons end
  11. function checkPointFinal(hitElement, d) if isElement(hitElement) and getElementType(hitElement) == "player" and d then -- se existir o elemento e se o tipo do elemento for player e se esta na mesma dimensao do marcador if getElementData(hitElement, "checkpoint3") then destroyElement(getPedOccupiedVehicle(hitElement)) setElementVisibleTo(blip2, hitElement, false) setElementVisibleTo(blip3, hitElement, false) setElementVisibleTo(blip4, hitElement, false) setElementVisibleTo(blip5, hitElement, false) setElementVisibleTo(job2, hitElement, false) setElementVisibleTo(job3, hitElement, false) setElementVisibleTo(job4, hitElement, false) setElementVisibleTo(job5, hitElement, false) setElementData(hitElement, "checkpoint1", false) setElementData(hitElement, "checkpoint2", false) setElementData(hitElement, "checkpoint3", false) setElementData(hitElement, "checkpoint4", false) setElementData(hitElement, "jobIniciar", false) givePlayerMoney(hitElement, 500) outputChatBox("Debitados R$500,00.", hitElement, 0, 250, 0) outputChatBox("Digite /iniciar no marcador para fazer a corrida novamente.", hitElement, 0, 220, 0) setElementPosition(hitElement, 1714.3785400391, -1949.0649414063, 14.1171875) end end end addEventHandler("onMarkerHit", job5, checkPointFinal) Tente isso
  12. Creio que com essa função você consiga fazer isso: https://wiki.multitheftauto.com/wiki/FxAddBlood
  13. O resource padrão 'defaultstats' faz isso, basta você configurar os valores de cada habilidade na tabela.
  14. Você quer resetar o saldo de todos os jogadores, ou só de um jogador especifico?
  15. Sem código não tem como saber como está sendo salvo...
  16. Creio que seja do resource 'deathmessages', basta desativa-lo. Está localizado na pasta [gameplay].
  17. Seu código está bagunçado e não faz sentido você colocar o parâmetro do evento na função do setTimer. Comentei cada parte do código, espero que entenda. -- SERVER-SIDE local commands = { ["coco"] = true } local antiSpam = {} addEventHandler("onPlayerCommand", root, function(cmd) -- quando executar o comando if commands[cmd] then -- verifica se é o comando que está na tabela if isTimer(antiSpam[source]) then -- se existir o timer cancelEvent() -- cancela o evento fazendo com o que o comando não seja executado outputChatBox("Aguarde mais um pouco para utilizar o comando novamente!", source, 255, 0, 0) -- mostra a msg return end antiSpam[source] = setTimer(function(p) -- cria o timer if isElement(p) then -- verifica se existe o elemento, para evitar erros no debug if antiSpam[p] then -- verifica a tabela if isTimer(antiSpam[p]) then -- se existir o timer killTimer(antiSpam[p]) -- cancela o timer end antiSpam[p] = nil -- anula a tabela end end end, 10000, 1, source) end end) addEventHandler("onPlayerQuit", root, function() -- quando player sair, anular a tabela if antiSpam[source] then -- verifica a tabela if isTimer(antiSpam[source]) then -- se existir o timer killTimer(antiSpam[source]) -- cancela o timer end antiSpam[source] = nil -- anula a tabela end end)
  18. Da próxima vez, utilize o botão <> do fórum para postar código. Bom, vamos lá, você pode fazer isto de 2 formas: Utilizando 'or', que na tradução para português é 'ou' function revistar (source, cmd, pname) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accountname, aclGetGroup("BOPE")) or isObjectInACLGroup("user."..accountname, aclGetGroup("PMERJ")) then -- seguindo a lógica, se estiver na acl BOPE ou PMERJ, executa a funcao local Player_2 = getPlayerFromPartialName(pname) if isElement(Player_2) then Ou através de uma função function revistar (source, cmd, pname) if isPlayerPermission(source) then local Player_2 = getPlayerFromPartialName(pname) if isElement(Player_2) then local corpACLS = { "BOPE", "PMERJ", "EB" } function isPlayerPermission(thePlayer) -- faz um loop das acls declaradas na tabela e verifica se a acl do jogador é uma das acls declarada na tabela if isElement(thePlayer) and getElementType(thePlayer) == "player" then if isGuestAccount(getPlayerAccount(thePlayer)) then return end for _, group in ipairs(corpACLS) do if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup(group)) then return true end end end return false end
  19. Tente isto: -- func para arredondar os numeros, encontrada em: Lua-users.org/wiki/SimpleRound function round2(num, numDecimalPlaces) return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) end local kill = getElementData(source, "Kills") or 0 local mortes = getElementData(source, "Deaths") or 0 local kdr = round2(kill/mortes, 3)
  20. Entendi @Lord Henry, muito obrigado pela ajuda!
  21. Olá pessoal, estou tentando identificar o clique no porta-malas do veículo com a função processLineOfSight, porém sempre que clico no porta-malas do veículo retorna 4 identificando que o clique foi na parte de trás do carro. Eu acho que as posições que coloquei no parâmetro da função estejam erradas e não estou conseguindo solucionar isto. local vehicleClicked = nil function fClientClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if button == "left" and state == "up" then if not getPedOccupiedVehicle(localPlayer) and isElement(clickedElement) and getElementType(clickedElement) == "vehicle" then if getElementData(clickedElement, "Owner") == localPlayer then local cx, cy, cz = getVehicleComponentPosition(clickedElement, "boot_dummy", "world") if cx and cy and cz then local hit, x, y, z, hitElement, _, _, _, _, _, part = processLineOfSight(worldX, worldY, worldZ, cx, cy, cz) iprint(part) -- if not guiGetVisible(weaponWindow) then -- guiSetVisible(weaponWindow, true) -- triggerServerEvent("RefreshListWeapons", resourceRoot, getElementModel(clickedElement)) -- triggerServerEvent("OpenVehicleTrunk", resourceRoot, clickedElement, true) -- end -- vehicleClicked = clickedElement end end end end end addEventHandler("onClientClick", root, fClientClick)
  22. local screenW, screenH = guiGetScreenSize() local render = false -- variável function f_tabPanel() dxDrawLine(screenW * 0.3160, screenH * 0.3444, screenW * 0.7694, screenH * 0.3444, tocolor(41, 49, 213, 255), 1, false) end function f_executeTab() local addRemove = render and removeEventHandler("onClientRender", root, f_tabPanel) or addEventHandler("onClientRender", root, f_tabPanel) -- se a váriavel render for true vai remover o evento caso contrário irá adicionar if addRemove then render = not render -- alterna a variável end end addCommandHandler("rectangle", f_executeTab) Tente isso, coloquei umas explicações para você, espero que entenda!
  23. @MaligNos deu certo convertendo para string, muito obrigado!
×
×
  • Create New...