Rapt0r Posted February 26, 2021 Posted February 26, 2021 (edited) Salve, sou novo no fórum e em lua também, o que quero fazer é deixar o ped imortal e incapaz de atirar, trocar de arma etc, por alguns segundos. Mas acontece que invés de somente o ped ficar incapaz de atirar, todos os jogadores ficam também, mas o DX acima do ped fica só pra ele, alguem da um help ai? peço perdão se estiver dificil de entender oq quero fazer, vou fazer algumas observações nas linhas pra ver se facilita Client-side: local rapt = dxCreateFont('files/rapt.ttf', 18, false); addEventHandler ( "onClientPlayerDamage",root, function () if getElementAlpha(source) == 100 then --- quando ele usar o tele, vai ficar com esse alpha, usei isso pra deixar ele imortal, funcionou de boa cancelEvent() end end ) addEventHandler( 'onClientRender', root, function( ) for _, player in ipairs( getElementsByType( 'player') ) do if isElementOnScreen( player ) and getElementAlpha(player) == 100 and not getElementData(player,"ModoPassivo") then local cx, cy, cz, x, y, z, dist local x, y, z = getElementPosition( player ); local cx, cy, cz = getCameraMatrix( ); dist = math.sqrt( ( cx - x ) ^ 2 + ( cy - y ) ^ 2 + ( cz - z ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( cx, cy, cz, x, y, z, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( player, 6 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.75 ) if x then dxDrawImage(x-53, y-35, 105, 21, "files/dx1.png", 0, 0, 0, tocolor(0, 0, 0, 100), false) --- dx funfou de boa dxDrawText("Proteção Spawn", x, y-50, x, y, tocolor(205, 205, 205, 255), 0.52, rapt, "center", "center") --- toggleControl ( "fire", false ) toggleControl ( "aim_weapon", false ) toggleControl ( "next_weapon", false ) --- aqui tá o problema, era pra essas funçoes serem aplicadas só pro ped local :( toggleControl ( "previous_weapon", false ) toggleControl ( "vehicle_fire", false ) end end end end end end ); Server-side: function removerprotecao (source) setElementAlpha(source, 255) end addEventHandler("onPlayerCommand",root, function(command) if (command == "praia") then if not getPedOccupiedVehicle(source) then setElementAlpha(source, 100) setElementPosition ( source, 328.2568359375, -1779.7213134766, 5.5062503814697 ) onClientCrapBox(source, "tele", getPlayerName(source).." #c2c2c2foi para a Praia (#1E90FF/praia#c2c2c2).") setTimer ( removerprotecao, 3300, 1, source) else exports.Infobox:addBox(source, 'Saia do veículo para utilizar este comando.', 'error') end end end) de coração, se alguém poder me ajudar ficarei muito grato Edited February 26, 2021 by Rapt0r
Moderators Lord Henry Posted March 1, 2021 Moderators Posted March 1, 2021 Já tentou fazer server-side e especificar o jogador no primeiro parâmetro? 1 Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
Rapt0r Posted March 2, 2021 Author Posted March 2, 2021 8 hours ago, Lord Henry said: Já tentou fazer server-side e especificar o jogador no primeiro parâmetro? Como assim especificar o jogador no primeiro parâmetro? Já tentei sim server-side da seguinte forma: function removerprotecao (source) setElementAlpha(source, 255) end addEventHandler("onPlayerCommand",root, function(command) if (command == "praia") then if not getPedOccupiedVehicle(source) then setElementAlpha(source, 100) toggleControl ( source, "fire", false ) toggleControl ( source, "aim_weapon", false ) toggleControl ( source, "next_weapon", false ) toggleControl ( source, "previous_weapon", false ) toggleControl ( source, "vehicle_fire", false ) setElementPosition ( source, 328.2568359375, -1779.7213134766, 5.5062503814697 ) onClientCrapBox(source, "tele", getPlayerName(source).." #c2c2c2foi para a Praia (#1E90FF/praia#c2c2c2).") setTimer ( removerprotecao, 3300, 1, source) setTimer ( function() toggleControl ( source, "fire", true ) toggleControl ( source, "aim_weapon", true ) toggleControl ( source, "next_weapon", true ) toggleControl ( source, "previous_weapon", true ) toggleControl ( source, "vehicle_fire", true ) end, 3300, 1 ) else exports.Infobox:addBox(source, 'Saia do veículo para utilizar este comando.', 'error') end end end) Não faço a MÍNIMA IDEIA do porque de não ter funcionado kkkkkkkk
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now