Jump to content

main

Members
  • Posts

    112
  • Joined

  • Days Won

    1

main last won the day on February 25 2019

main had the most liked content!

About main

  • Birthday June 1

Details

  • Location
    Brazil

Recent Profile Visitors

3,730 profile views

main's Achievements

Sucka

Sucka (13/54)

32

Reputation

  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?
×
×
  • Create New...