Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/11/19 in all areas

  1. Chegou a aparecer a mensagem "Level setado no jogador com sucesso."? Se não apareceu, é pq vc errou o nick do jogador. Tem que ser o nick exato, incluindo os códigos de cores.
    1 point
  2. Isto resolve o problema: function getStart () if (getElementData (localPlayer, "tempo:Logou")) then return end -- Evita de resetar o tempo online quando este resource for reiniciado, impedindo que os players resetem suas datas. setElementData (localPlayer, "tempo:Logou", getTickCount()) end addEventHandler ("onClientResourceStart", resourceRoot, getStart) function renderTest () if getElementData (localPlayer, "tempo:Logou") then local tempoJogando = getTickCount() - getElementData (localPlayer, "tempo:Logou") local hours = tempoJogando/3600000 local minutes = (tempoJogando/60000) % 60 local seconds = (tempoJogando/1000) % 60 local tempoOnline = string.format("%02d:%02d:%02d", hours, minutes, seconds) dxDrawText ("Tempo Online: "..tempoOnline.."", 653, 413, 874, 441, tocolor(0, 0, 0, 255), 1.00, "default", "left", "top", false, false, false, false, false) end end addEventHandler ("onClientRender", root, renderTest) Obs: No cálculo do servidor, estará errado agora. Pois a data do jogador foi obtida no cliente e não no servidor. Mas seu DX estará sempre certo. Remova a parte de setar a data no jogador ao fazer login no servidor.
    1 point
  3. Já descobri o erro. getTickCount no servidor, mostra os milissegundos desde que o servidor foi iniciado, no caso de servidor local, quantos milissegundos o MTA Server.exe está em execução. No cliente, é quantos milissegundos desde que o cliente Multi Theft Auto.exe está em execução. Por isso que sempre dará diferença entre eles. Isso significa, que quando o player loga e salva o getTickCount() nele. No cliente, esse getTickCount salvo no jogador é do servidor, mas ele tenta fazer uma subtração com o getTickCount do cliente. Gerando essa diferença.
    1 point
  4. No lado server, não precisa disso: local time = tempoJogando; E o outputChatBox acabou ficando estranho: "Você está jogando a exatamente 0:10:14 segundos."
    1 point
  5. addEventHandler ("onPlayerLogin", root, function (prevAcc, currAcc) setElementData (source, "tempo.Logou", getTickCount()) end) function meuTempoOnline (thePlayer, cmd) if (getElementData (thePlayer, "tempo.Logou")) then local tempoJogando = getTickCount() - getElementData (thePlayer, "tempo.Logou") -- Isso também pode ser usado no client. outputChatBox ("Você esta jogando a exatamente: "..tempoJogando.." segundos.", thePlayer) end end addCommandHandler ("temp", meuTempoOnline) Em vez de salvar em variável, daria pra salvar como elementData para ser possível usar no client também.
    1 point
  6. Por se tratar de um script server-side, você precisa indexar as variáveis no jogador. Você não pode usar variáveis simples pois outros jogadores irão influenciar nela. Isso significa, que quando um segundo jogador logar, a variável tempo do primeiro jogador será substituída pelo tempo do segundo jogador, perdendo o tempo online do primeiro jogador. E não use setElementData dentro de timers curtos. Pois eles são muito pesados.
    1 point
  7. local screenW,screenH = guiGetScreenSize() local resW,resH = 1366,768 local x,y = (screenW/resW), (screenH/resH) local font = dxCreateFont("fonts/font.ttf", 10) local MaxFuel = 100 function getVehicleFuel(v) local fuel = getElementData(v, "fuel") if (fuel) then return fuel end return 0 end addCommandHandler("fueladm",fuel) Hello! You can insert code blocks with the <> sign. Use it next time. Your problem is that this code does not set any value. In order to set the "amount of fuel" you have to use setElementData to set the value for fuel. Also functions can get parameters/arguments from command calls. You can catch those arguments in the paramter list after the function's name. -- Catch parameters of command call -- On server-side function funcName(player, command, value1, value2) end addCommandHandler("testCall", funcName) -- When you type /testCall it will call the funcName function, providing the calling player, the command that has been used for the call, and additional values typed in alongside the command. In command calls, additional values are seperated with spaces. For example: /testCall value1 value2 -- On client-side function funcName(command, value1, value2) end addCommandHandler("testCall", funcName) -- The same playbook here, except that client-side calls do not provide the calling player, because it is obvious that the calling player is the client itself. The localPlayer. Now your function should look somehow like this: -- Client-side function setVehFuel(cmd, fuel) local veh = getPedOccupiedVehicle(localPlayer); -- Gets the currently occupied vehicle of the player, returns false if the player is not in a vehicle. if (veh) then -- Translates to if (veh ~= false/nil) then setElementData(veh, "fuel", tonumber(fuel)); -- Sets the fuel element data of the vehicle to the value that the caller provided converted into a number from string. end end addCommandHandler("setFuel", setVehFuel);
    1 point
×
×
  • Create New...