-
Posts
343 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Doongogar
-
Verificar se elemento possui element data
Doongogar replied to Doongogar's topic in Programação em Lua
entao teria como eu pegar as datas sem saber os nomes no server-side, e passar isso pro client-side? -
Verificar se elemento possui element data
Doongogar replied to Doongogar's topic in Programação em Lua
nao existe uma maneira de verificar sem ter a tabela de nomes? eu queria verificar se o elemento possui pelo menos 1 element data -
you don't need to use getPedOccupiedVehicle to have the vehicle element, since the event revolves around the vehicle, its argument is already defined as source
-
usually in fainting mods they use the onClientPlayerDamage to check for each damage the player has if he has less than a certain life, if he has less than a certain life he faints, since in the event there is the attacker argument that is the aggressor, you could use a getPlayerName(attacker) that if you are really using the onClientPlayerDamage event as I imagine text translated by google translator*
-
Verificar se elemento possui element data
Doongogar replied to Doongogar's topic in Programação em Lua
eu vou dar um exemplo que nao sei se ta certo: fazer um loop com getAllElementData, getando todos os element datas do elemento entao usar o simbolo ~= para verificar se os element datas do elemento e diferente de nil tipo assim: function checkData(elemento) for i, objeto in ipairs(getAllElementData(elemento)) do if objeto ~= nil then --entao faz algo end end end algo assim. Verificar se o elemento possui algum element data sabe? Detalhe: eu tenho que fazer essa verificacao no client e o getAllElementData funciona no server -
então eu não queria verificar se o elemento possui tal element data, eu gostaria de saber se ele possui algum element data verificar caso o elemento abrigue algum element data, independente do nome do element data
-
e como eu implementaria o evento da morte nesse caso ? eu tentei usando getAttachedElements, verificando se o elemento é um blip e se o tipo do blip é 0, ai destruiaria se sim, o blip simplesmente não some function BlipMorte() local blips = getAttachedElements(source) for _, blip in ipairs(blips) do if getElementType(blip) == "blip" then if getBlipType(blip) == 0 then destroyElement(blip) end end end end addEventHandler("onPlayerWasted", root, BlipMorte)
-
pra teleportar o player para um lugar e veiculo para outro você pode usar o removePedFromVehicle que tira o player do veiculo instantâneamente local marker = createMarker(x, y, z, "cylinder", 1.1, 255, 255, 255, 255) -- cria o marker function RemoverDoCarro(thePlayer) if isElementWithinMarker(thePlayer, marker) then -- caso o jogador esteja no marker então... local piloto = getVehicleOccupant(thePlayer) -- pega o ocupante do veiculo if piloto then -- caso o jogador esteja ocupando o volante então... local vehicle = getPedOccupiedVehicle(thePlayer) -- pega o veiculo que o player ocupa if vehicle then -- se tem o veiculo então... removePedFromVehicle(thePlayer) -- tira o player do veiculo setElementPosition(thePlayer, 0, 0, 0) -- seta a posição do player em 0x 0y 0z setElementPosition(vehicle, 2, 2, 2) -- seta a posição do veiculo em 2x 2y 2z end end end end addCommandHandler("desmanchar", RemoverDoCarro
-
Imagem com a face virada sempre a tela anexada a um player
Doongogar replied to Doongogar's topic in Programação em Lua
então como eu faço para anexar a imagem ao player sem usar o attachElements, eu teria que usar o: dxDrawImageOnElement ? -
Imagem com a face virada sempre a tela anexada a um player
Doongogar replied to Doongogar's topic in Programação em Lua
eu tentei assim: local image = dxCreateTexture("armour.png") local cx, cy, cz = getCameraMatrix() function toggleArmorImage(enabled) if enabled then local imagem dxDrawImage3D(0, 0, 0, 100, 100, image, 255, 255, 255, 0, false, cx, cy, cz) attachElements(imagem, localPlayer) else if isElement(imagem) then destroyElement(imagem) imagem = nil end end end addEvent("onProStaffToggle", true) addEventHandler("onProStaffToggle", root, toggleArmorImage) function dxDrawImage3D( x, y, z, width, height, material, color, rotation, ... ) return dxDrawMaterialLine3D( x, y, z, x + width, y + height, z + tonumber( rotation or 0 ), material, height, color or 0xFFFFFFFF, ... ) end ta dando erro no attachElements, primeiro argumento, tenho quase certeza que é porque não pode usar pra attachar uma imagem eu acho, como eu faria nesse caso? -
dxDrawTextOnElement em objetos de tal modelo
Doongogar replied to Doongogar's topic in Programação em Lua
obrigado lord, desculpa acabar com a indentação do código, e que eu sou burro mesmo, eu gostaria de saber como eu faço para alterar a posição do texto no eixo X, eu tentei adicionar um argumento na função util dxDrawTextOnElement, porém como o objeto nesse caso é visto como um 3D na função se alterar o eixo X, o texto começa a sair do objeto, existe alguma forma de mudar o texto de posição em relação ao objeto e não em relação ao centro do objeto visto como 3D? -
-- client function BlipPolicia(players) local blip = createBlipAttachedTo(players, 0) end addEvent("BlipPM", true) addEventHandler("BlipPM", root, BlipPolicia) -- server function start(playerSource, qntd) if exports.BVNInventario:GiveAndTakeAndGetItem("get", playerSource, "maconhaembalada") >= qntd then local random = math.random(6, 6) if random == 6 then exports._infobox:addNotification(playerSource, "O Comprador Recusou e Chamou as Autoridades!", "error") for i, players in ipairs(getElementsByType("player")) do if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(players)), aclGetGroup("Policie")) then exports._infobox:addNotification(players, "Denuncia de Traficante Vendendo Ilegais, o Traficante Foi Marcado no Mapa", "info") triggerClientEvent("BlipPM", players, playerSource) end end else exports.BVNInventario:GiveAndTakeAndGetItem("take", playerSource, "maconhaembalada", qntd) exports.BVNInventario:GiveAndTakeAndGetItem("give", playerSource, "dinheirosujo", qntd * 2000) local time = qntd * 2 if time > 5000 * 5 then time = 5000 * 5 elseif time < 5000 then time = 5000 end setElementFrozen(playerSource, true) toggleAllControls(playerSource, false, true, false) setPedAnimation(playerSource, "CASINO", "dealone", -1, true, false, false, false, _, true) triggerClientEvent(playerSource, "progressBar", playerSource, time) exports._infobox:addNotification(playerSource, "Vendendo a Droga...", "info") setTimer(function() setElementFrozen(playerSource, false) toggleAllControls(playerSource, true) setPedAnimation(playerSource, nil) exports._infobox:addNotification(playerSource, "Você Vendeu " .. tonumber(qntd) .. "x 'Maconha' e recebeu " .. tonumber(qntd * 2000) .. " de Dinheiro Sujo", "money") end, time, 1) end else exports._infobox:addNotification(playerSource, "Você não possui " .. tonumber(qntd) .. "x 'Maconha' na sua mochila", "error") end end addEvent("Start", true) addEventHandler("Start", resourceRoot, start) esse código faz com que crie um blip para os policiais no vendedor caso o comprador recuse a venda, porém eu gostaria que quando o playersource morrer ou passar 10 minutos os blip suma, não to conseguindo de jeito nenhum não to conseguindo passar o blip do client para o server, ajuda ai pelo amor de deus OBS: deixei a chance em 100%, só porque eu tava testando
-
eu queria criar uma imagem 2D porém com um efeito que a face dela sempre esteja virada para o visualizador assim como aquele script de /pro que cria uma imagem no player ai todos podem ver ela, não achei nenhum tópico/wiki/video, caso haja um, pode apontar que eu vou lá e vejo também, mas se puderem dar uma explicação detalhada eu agradeceria, já que sou meio leigo
-
Então estou fazendo esse codigo que cria um texto em todos os objetos do modelo 1491 que é uma porta, no caso o código e pra trancar/destrancar portas, a parte de trancar e destrancar foi bem facil e esta funcionando, porém eu tentei criar o texto com a função útil: dxDrawTextOnElement no entanto eu gostaria de rodar o texto no onClientRender para atualizar caso o jogador tranque/destranque apareça em tempo real se ta trancada ou não mas o texto não esta sendo criado, não apresenta erros, só não cria, gostaria de uma ajuda com isso, também acho que da pra tirar o evento onClientRender e vincular um evento no código de trancar/destrancar para só atualizar quando trancar/destrancar ao invez de frame a frame para deixar mais liso, se puderem ajudar com isso também. Nota: tirei o ultimo argumento da função dxDrawTextOnElement, porque é opcional e eu não estou usando, caso não puder fazer isso avise, mas antes de eu tirar também não estava funcionando. function TextoPortas() for i, portas in ipairs(getElementsByType("object")) do if getElementModel(portas) == 1491 then if isElementFrozen(portas) then dxDrawTextOnElement(portas, "#FF0000[E] #FFFFFFPara Abrir", 0, 0, 5, 255, 255, 255, 255, 1.1, "default-bold") else dxDrawTextOnElement(portas, "#FF0000[E] #FFFFFFPara Fechar", 0, 0, 5, 255, 255, 255, 255, 1.1, "default-bold") end end end end addEventHandler("onClientRender", root, TextoPortas) function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end
-
if getElementModel(v) == 596 then setVehicleHandling(v, "mass", 1600) setVehicleHandling(v, "turnMass", 3000) setVehicleHandling(v, "dragCoeff", 2) setVehicleHandling(v, " centerOfMass", { 0, 0.45, -0.4 } ) setVehicleHandling(v, "percentSubmerged", 75) setVehicleHandling(v, "tractionMultiplier", 0.7) setVehicleHandling(v, "tractionLoss", 1.2) setVehicleHandling(v, "tractionBias", 0.52 ) setVehicleHandling(v, "numberOfGears",5) setVehicleHandling(v, "maxVelocity", 240) setVehicleHandling(v, "engineAcceleration", 17) setVehicleHandling(v, "engineInertia", 20) setVehicleHandling(v, "driveType", "awd") setVehicleHandling(v, "engineType", "gasolina") setVehicleHandling(v, "brakeDeceleration ", 9999) setVehicleHandling(v, "ABS", false) setVehicleHandling(v, "steeringLock", 35) setVehicleHandling(v, "suspensionForceLevel", 1) setVehicleHandling(v, "suspensionDamping", 0.1) setVehicleHandling(v, "suspensionHighSpeedDamping ", 0.) setVehicleHandling(v, "suspensionUpperLimit", 0.3) setVehicleHandling(v, "suspensionLowerLimit", -0.05) setVehicleHandling(v, "suspensionFrontRearBias", 0.4) setVehicleHandling(v, "suspensionAntiDiveMultiplier", 0.5) setVehicleHandling(v, "seatOffsetDistance", 0.2) setVehicleHandling(v, "collisionDam 1Multiplier" ) setVehicleHandling(v, "monetário", 25000) setVehicleHandling(v, "modelFlags", 0x40000001) setVehicleHandling(v, "handlingFlags", 0x10308803) setVehicleHandling(v, "headLight", 0) setVehicleHandling(v, "tailLight",1) setVehicleHandling(v, "animGroup", 0) end end function loadHandlings2() for k, v in ipairs(getElementsByType("vehicle")) do loadHandling2(v) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), loadHandlings2) addEventHandler("onVehicleEnter", root, function(player) --setVehicleHandling(fonte, false) loadHandling2(origem) end) --[[ function resetHandling() for k, v in ipairs(getElementsByType("vehicle")) do for k1,v1 in ipairs(setModelHandling(getVehicleModel(v))) do -- setVehicleHandling(v, k1, nil) end end end addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), resetHandling)]] sempre que for colocar um codigo no post utilize a ferramenta "code", para evitar que a viatura caia ou você pode diminuir a aceleração ou pode aumentar a massa, aqui no caso esse codigo aumenta a massa é o do post acima porém corrigido pois o de cima tinha traduzido algumas coisas do codigo, isso faria não funcionar
-
probably this check "if veh then" checks if the player is in a vehicle and it is being triggered after picking up the player that is in the car, you would have to put the "if veh then" before picking up the player that is in the vehicle , of course, if this check is really what I'm thinking text translated by google translator setTimer(function() if veh then if getElementData(getPedOccupiedVehicle ( localPlayer ), "leftflash" ) then end else playSound("files/povorot.mp3",false) end if veh then if getElementData(getPedOccupiedVehicle ( localPlayer ), "rightflash" ) then end else playSound("files/povorot.mp3",false) end if veh then if getElementData(getPedOccupiedVehicle ( localPlayer ), "allflash" ) then end else playSound("files/povorot.mp3",false) end end, interval * 1000 , 0)
-
como fazer script que notifica no discord o server e ip que ativou
Doongogar replied to EBERTZ's topic in Programação em Lua
com ativa, você quis dizer quando a pessoa loga ou entra no servidor? -
Pegar todos os resource e mandar uma mensagem pro discord
Doongogar replied to Doongogar's topic in Programação em Lua
eu queria agradecer, eu consegui faze-lo funcionar, implementei um timer que de 40 em 40 segundo ele manda de 10 em 10 resources porque estava sobrecarregando e parava de enviar os resources, porém mesmo com a limitação de resources e com o timer, ele ainda não envia todos os resources, fica faltando alguns, também coloquei um string.find para se caso tiver uma sequência de caracteres no resource não mandar ele, para evitar de mandar alguns resources do próprio MTA, gostaria de saber porque o string.find não está funcionando e porque fica faltando alguns resources urlDiscord = "https://discord.com/api/webhooks/1078312698711908422/dcqfCNvzpoQr5GrwV2dJw9Sn3TEo9gNEJVs_gNxjTgqjP4xTujwUcvnZ6VP5IV0xkTge" resourceCount = 0 resourceIndex = 1 resourcesPerBatch = 10 batchDelay = 40 -- segundos function enviarMsg(message) local resourceName = '"' .. message .. '",' sendOptions = { queueName = "dcq", connectionAttempts = 10, connectTimeout = 20000, formFields = { content = resourceName }, } fetchRemote(urlDiscord, sendOptions, callback) end function callback() end NotStart = { '^race', '^web', '^tdma', '^sth', '^map', '^editor', '^play', 'browser', 'manager', '^move', '^dm', '^death', '^ctf', '^ctv', '^br', '^as-', } function displayResources() local resourceTable = getResources() local resourcesToSend = {} for _, res in pairs(resourceTable) do local name = getResourceName(res) local blacklisted = false for _, pattern in pairs(NotStart) do if string.find(name, pattern) == 1 then blacklisted = true break end end if not blacklisted then table.insert(resourcesToSend, name) end end local batchStartIndex = (resourceIndex - 1) * resourcesPerBatch + 1 local batchEndIndex = batchStartIndex + resourcesPerBatch - 1 local batchResources = {} for i = batchStartIndex, batchEndIndex do if resourcesToSend[i] ~= nil then table.insert(batchResources, resourcesToSend[i]) end end for _, name in ipairs(batchResources) do enviarMsg(name) end resourceIndex = resourceIndex + 1 resourceCount = resourceCount + #batchResources if #batchResources == 0 or resourceCount >= #resourcesToSend then resourceCount = 0 resourceIndex = 1 return end setTimer(displayResources, batchDelay * 1000, 1) end addCommandHandler("rsc", displayResources) -
local weapons = {"ak47", "m4a1", "mp5"} local weaponsOwned = {} for i, weapon in ipairs(weapons) do local armas = exports.BVNInventario:GiveAndTakeAndGetItem(player, "get", weapon) if armas then table.insert(weaponsOwned, weapon) end end if #weaponsOwned > 0 then outputChatBox("O cidadão possui as seguintes armas: " .. table.concat(weaponsOwned, ", "), source, 255, 255, 255, true) else outputChatBox("O cidadão não possui nenhuma arma", source, 255, 255, 255, true) end aparece que o player não tem armas mesmo ele tendo, esse export e uma função do inventario para obter itens, ta no modo get para getar os itens a ideia e na hora que revistar aparecer no chat todas as armas que o jogador revistado tem no inventario addEvent("Suspiro.abordarJogador",true) addEventHandler ( "Suspiro.abordarJogador", getRootElement(), function(source, player) local cx, cy, cz = getElementPosition(player) local px, py, pz = getElementPosition(source) local distancia = getDistanceBetweenPoints3D(cx, cy, cz, px, py, pz) if distancia > 5 then exports._infobox:addNotification(player, "Chegue mais perto do jogador.", "error") return end local weapons = {"ak47", "m4a1", "mp5"} local weaponsOwned = {} for i, weapon in ipairs(weapons) do local armas = exports.BVNInventario:GiveAndTakeAndGetItem(player, "get", weapon) if armas then table.insert(weaponsOwned, weapon) end end if #weaponsOwned > 0 then outputChatBox("O cidadão possui as seguintes armas: " .. table.concat(weaponsOwned, ", "), source, 255, 255, 255, true) else outputChatBox("O cidadão não possui nenhuma arma", source, 255, 255, 255, true) end end) codigo completo, a ação revistar esta tudo certo, porém como eu disse sempre exibe a mensagem que o player não tem arma nenhuma mesmo ele tendo
-
então não é bem assim que funciona você tem que fazer assim: local vida = math.floor(getElementHealth(localPlayer)) local coltete = math.floor(getPedArmor(localPlayer)) dxDrawRectangle(x*1, y*1, x*1/100*vida, y*1, tocolor(r, g, b, a), false) -- vai diminur na horizontal dxDrawRectangle(x*1, y*1, x*1, y*1/100*colte, tocolor(r, g, b, a), false) -- vai diminuir na vertical o X diminui a barra no sentido do horizonte ja o Y diminui a barra no sentido vertical bom se não me engano é assim, pode ta errado também, isso só os mais inteligentes diram...
-
se poder dar um 'thanks' na minha postagem que te ajudou, eu agradeco, tambem seria bom voce usar o getElementType pra verificar se player e um elemento do tipo player pra nao bugar caso um carro entre no marker, assim : if getElementType(player) == 'player' then teria que por antes da verificacao do marker e da acl pra n bugar em nenhuma das duas
-
eu coloquei essa função que se o player clickar em qualquer area exeto a da editbox, a edit box some, porém não sei se pode dar um erro ja que o nome da função é setar a visibilidade não sei se ela so tira a visibilidade e isso pode gerar algum erro addEventHandler("onClientClick", root, function(button, state) if states and isCursorShowing() then if button == "left" and state == "down" then if isCursorInPosition(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267) then -- Puxar triggerServerEvent("PuxarTodos", resourceRoot, localPlayer) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267) then -- Destruir Veiculos triggerServerEvent("DestruirVeiculos", resourceRoot) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267) then -- Players local contador = 0 for _, player in pairs(getElementsByType("player")) do if player then contador = contador + 1 end end outputChatBox("Existem: #00ff00"..contador.." #ffffffplayers online.", 255, 255, 255, true) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then -- Dinheiro editBox = guiCreateEdit(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, "", false) guiFocus(editBox) elseif not isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then -- Dinheiro guiSetVisible(editBox, false) end end end end)
-
Editbox aparecer por cima do dx com postgui no "true"
Doongogar replied to Doongogar's topic in Programação em Lua
brigadão, eu tinha setado o postgui em true pq na hora de selecionar o painel ficava por cima do retangulo de roxo de quando selecionava ent não aparecia, não sabia que tinha como juntar assim o painel com o de por o mouse em cima, outra, esse guifocus faz oque exatamente, eu pesquisei, e li na wiki que foca um elemento, não entendi muito bem -
use a ferramenta "Code" quando for colocar um script e adicione a categoria certa do meio de linguagem do script pra isso você pode usar o isObjectInACLGroup, getAccountName, getPlayerAccount e aclGetGroup como condição assim: bombmarker = createMarker (2025.012, -1413.344, 16.000, "cylinder", 1.5, 072,118,255,255 ) function msg(player) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Samu")) then outputChatBox("Aqui os comandos para bombeiros", player, 255, 000, 000, true) outputChatBox("/bomb1 para pegar a skin 1", player, 072, 118, 255, true) outputChatBox("/bomb2 para pegar a skin 2", player, 072, 118, 255, true) outputChatBox("/bomb3 para pegar a skin 3", player, 072, 118, 255, true) outputChatBox("/viatura para pegar a qsv", player, 072, 118, 255, true) end end addEventHandler("onMarkerHit", bombmarker, msg) function skin1(player) if isElementWithinMarker(player, bombmarker) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Samu")) then setElementModel(player, 150) else outputChatBox("Você não tem permissão para pegar essa skin!", player, 255, 0, 0) end else outputChatBox("Você precisa estar no Marker para pegar a skin!", player, 255, 0, 0) end end addCommandHandler("bomb1", skin1) function skin2(player) if isElementWithinMarker(player, bombmarker) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Samu")) then setElementModel(player, 151) else outputChatBox("Você não tem permissão para pegar essa skin!", player, 255, 0, 0) end else outputChatBox("Você precisa estar no Marker para pegar a skin!", player, 255, 0, 0) end end addCommandHandler("bomb2", skin2) function skin3(player) if isElementWithinMarker(player, bombmarker) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Samu")) then setElementModel(player, 152) outputChatBox("Você pegou a skin 3 com suceso", player, 255, 0, 0) else outputChatBox("Você não tem permissão para pegar essa skin!", player, 255, 0, 0) end else outputChatBox("Você precisa estar no Marker para pegar a skin!", player, 255, 0, 0) end end addCommandHandler("bomb3", skin3) function pegarveiculo(player) if isElementWithinMarker(player, bombmarker) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Samu")) then createVehicle(416, 2037.199, -1434.599, 17.138) end end end addCommandHandler("viatura", pegarveiculo) function quitPlayer ( quitType ) if VehSamu[source] and isElement(VehSamu[source]) then destroyElement(VehSamu[source]) VehSamu[source] = nil end end addEventHandler ( "onPlayerQuit", root, quitPlayer )