Jump to content

androksi

Other Languages Moderators
  • Posts

    542
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by androksi

  1. Hello. First of all, you need a table to store all the player elements. It's a way easier to destroy futher elements. The player element would be the table index and its value would be your object and your colshape. I make an example: local playerData = {} -- We define a table to store all player elements as a key. function createObjectAndColShape(player) -- I don't now what these "myx", "myy" and "myz" are, I presume that's the player's position or matrix. I will use player's position local myx, myy, myz = getElementPosition(player) local object = createObject(8873, myx, myy, myz) local colshape = createColSphere(myx, myy, myz, 320) setElementData(colshape, "col", object) setElementData(colshape, "colplayer", player) playerData[player] = {object, colshape} -- Here we set the index as being the player, and it stores the object and the colshape end function destroyObjectAndColShape(player) if type(playerData[player]) ~= "table" then return false end for player, element in pairs(playerData[player]) do if isElement(element) then destroyElement(element) end end playerData[player] = nil end addEventHandler("onPlayerQuit", root, function() -- When the player quits the server, so we call that function to destroy its elements and free memory destroyObjectAndColShape(source) end) addCommandHandler("cp", function(player) -- Just a command /cp to create the objects, you can use this function on your bindKey function createObjectAndColShape(player) end)
  2. Olá. A função setPlayerWantedLevel é server-side. Você está usando no client-side. Diga qual função executa assim que o jogador termina de assaltar, fica mais fácil pra gente ajudar.
  3. Entendi. Como está o código server-side, a parte que transfere moedas? Às vezes é só um pequeno erro de lógica. Pois, pra ser bem sincero, isso não deveria acontecer, independente da conexão do jogador.
  4. Olá. Você pode usar o evento onClientPlayerNetworkStatus, que acontece exatamente quando o jogador perde a conexão. Um exemplo: local isOffline = false addEventHandler("onClientPlayerNetworkStatus", root, function(status) isOffline = status == 0 and true or false end) Daí você checaria com a variável isOffline. Mas assim, independente da conexão do jogador, certos bugs não deveriam ocorrer. Algo lá no server-side está incorretamente configurado, validações faltando ou algo do tipo.
  5. Hello. It would be good if you also use onClientVehicleExit, to remove the eventHandler; then that error won't probably happen. Example: addEventHandler("onClientVehicleEnter", root, function(player, seat) --[[ We should check here if the player who entered the vehicle is the localPlayer, otherwise the addEventHandler would be called for everyone Also, we need to check if the seat is 0 (driver), otherwise passengers would execute the function ]] if player == localPlayer and seat == 0 then addEventHandler("onClientRender", root, getspeed) end end) addEventHandler("onClientVehicleExit", root, function(player, seat) if player == localPlayer and seat == 0 then removeEventHandler("onClientRender", root, getspeed) end end)
  6. Hello. I've moved your topic into a suitable place. The color code type is AARRGGBB. It's a hex color code, but with the alpha included, at the beginning. Example: ffff0000 - first two values (ff) represents the alpha, the rest (ff0000) [red] is the hex color.
  7. Apenas remova as aspas do "5000", pois é pra ser um número. A partir do momento que você coloca " (aspas) ela vira uma string. Sendo assim, a função getPlayerMoney retorna o dinheiro do jogador (número), ao comparar ali na condição, o número seria diferente de uma string, por isso o erro. Recomendo que você dê uma lida neste tutorial. Além disso, na função takePlayerMoney, você não deve usar aspas. Apenas deixe a variável.
  8. Olá. Basta você colocar o PrecoLSComercial ali no lugar do 5. Não precisa concatenar. Pra ter certeza de que será um número, use: tonumber(PrecoLSComercial)
  9. Com a opção "d" no campo de opções (Options), no IPB, é possível ver qual arquivo, qual linha, qual função/evento. Só pra constar, a opção "a" atualiza o collectgarbage em tempo real.
  10. Olá. Não está detectando pois o evento onPlayerMarkerHit leva o JOGADOR como sendo o source. O parâmetro é o MARKER. Logo, o seu parâmetro markerHit está levando o marker, e não o jogador. Altere o markerHit desta linha para source: if getElementType(markerHit) == "player" and not isPedInVehicle(markerHit) then
  11. Olá. Use a função createWater. Com ela, é possível criar "pedaços" de água pelo mapa.
  12. Olá. Você pode usar esta função: getPositionFromElementOffset - Código fonte: function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end Ela pega a posição de acordo com o que você deseja. Frente, trás, direita, esquerda, cima ou baixo. Basicamente o uso dela seria desta maneira (levando em consideração que você já colou aquela função dentro do seu código): addCommandHandler("object", function(player) local x, y, z = getPositionFromElementOffset(player, -2, 0, 0) -- -2 seria a posição X, horizontal. Sendo assim, -2 é à esquerda do jogador. local object = createObject(1337, 0, 0, 0) -- Cria o objeto no centro de San Andreas setElementPosition(object, x, y, z) -- Move o objeto para a posição que obtemos através daquela função end)
  13. Olá. Creio que não tenha como, pois objetos nativos do GTA: SA não aparecem na função getElementsByType. Mas no site do Prineside, o qual você citou, já possui uma tabela com todas as coordenadas. Basta copiar.
  14. Olá. Você pode usar a função getElementsWithinRange. É retornado uma tabela com todos os elementos. Exemplo: -- Server-side addCommandHandler("pradius", function(player, cmd, radius) radius = tonumber(radius) or 5 -- Caso "radius" seja inválido, teremos o valor 5 como padrão local x, y, z = getElementPosition(player) local playersInRadius = getElementsWithinRange(x, y, z, radius, "player") -- Iremos pegar tudo o que é "player", ou seja, jogador if #playersInRadius == 0 then -- Caso não haja jogadores no raio especificado, então mostraremos a mensagem de erro: return outputChatBox("Não há jogadores num raio de " .. radius .. " metros.", player, 255, 45, 45) end for index, element in pairs(playersInRadius) do outputChatBox(getPlayerName(element) .. " está num raio de " .. radius .. " metros perto de você!", player, 45, 255, 45) end end) -- Comando: /pradius <raio> -- Exemplo: /pradius 200
  15. Olá. Você pode usar a função outputChatBox. No caso, o parâmetro visibleTo levaria a variável do abordado. Veja a função na Wiki para entender melhor.
  16. Olá. Substitua a linha 3 por isto, no server-side mesmo: if exports.ada_admin:isPlayerFaccao(client) or getElementData(client, "acc:id") == 1 and client ~= Player then
  17. Olá. Você pode gerar números de 0 a 9 usando math.random. Crie uma função pra facilitar. Algo deste tipo: function generatePhoneNumber(startsWith) local str = startsWith or math.random(0, 9) for i = 1, 7 do str = str .. math.random(0, 9) end return string.sub(str, 1, 4) .. "-" .. string.sub(str, 5, 8) end print(generatePhoneNumber()) -- Início aleatório print(generatePhoneNumber(5)) -- Início do número começando com 5 sempre Você pode testar o código acima aqui neste site.
  18. Entendi. Você pode fazer desta forma: local animationAlpha = 0 local animationDelta = 0.08 local animationStep local function render() if animationStep == "in" then animationAlpha = math.min(animationAlpha + animationDelta, 1) -- Vai de 0 a 1. Basta multiplicar pelo valor máximo if animationAlpha == 1 then animationStep = "out" end elseif animationStep == "out" then animationAlpha = math.max(animationAlpha - animationDelta, 0) -- Vai de 1 a 0. if animationAlpha == 0 then animationStep = "in" end end dxDrawImage(0, 0, 200, 200, tocolor(255, 255, 0, animationAlpha * 255), false) -- Exemplo com o valor máximo sendo 255 dxDrawImage(0, 205, 200, 200, tocolor(255, 0, 0, animationAlpha * 100), false) -- Exemplo com o valor máximo sendo 100 end -- Supondo que esta seja a função de abrir o painel bindKey("u", "down", function() animationAlpha = 0 animationStep = "in" addEventHandler("onClientRender", root, render) end)
  19. Eu nunca trabalhei com esses sistemas, então não sei dizer com experiência. Mas provavelmente eles criam as texturas todas de uma só vez, depois bastaria só aplicar e/ou remover. Ainda assim, acredito que definitivamente NÃO SEJA o caminho mais otimizado, pois consumiria uma quantidade considerável de memória de vídeo.
  20. Olá. local animationAlpha = 0 local function render() animationAlpha = math.min(animationAlpha + 0.08, 1) -- Vai de 0 a 1. Basta multiplicar pelo valor máximo dxDrawImage(0, 0, 200, 200, tocolor(255, 255, 0, animationAlpha * 255), false) -- Exemplo com o valor máximo sendo 255 dxDrawImage(0, 205, 200, 200, tocolor(255, 0, 0, animationAlpha * 100), false) -- Exemplo com o valor máximo sendo 100 end -- Supondo que esta seja a função de abrir o painel bindKey("u", "down", function() animationAlpha = 0 addEventHandler("onClientRender", root, render) end) Como dito no comentário dentro do código, a variável animationAlpha armazena o valor 0, que vai até o valor 1. Com esse valor, bastaria multiplicar pelo valor máximo, pois qualquer número multiplicado por 1, é ele mesmo. A biblioteca math possui um método chamado min, que pega o MENOR valor. No caso do exemplo, a variável está sendo incrementada com + 0.08, até chegar a 1. Então, se o valor for maior que 1, ele vai pegar o menor valor, que é 1, como eu defini.
  21. Se a imagem for muito grande, por exemplo 512x512, já começa a travar. Ainda mais se estiver mais de uma sendo carregada.
  22. Olá. No evento onClientMarkerHit, o source dele é o marker. O "jogador" seria o hitElement. Aliás, é necessário verificar se o hitElement é igual ao localPlayer, também. Pois trata-se do client-side.
  23. Olá. Seja bem-vindo(a) ao fórum. Abra o seu painel de admin (P), vá até a aba Resources e busque pelo headshot. Clique duas vezes em cima dele, vai abrir um painel de configurações do resource. Terá uma linha com o nome removeHeadOnHeadshot, dê dois cliques, renomeie de true para false.
×
×
  • Create New...