luccah_ds Posted August 15, 2021 Posted August 15, 2021 (edited) Alguem me ajuda !! sou novo e estou tentando criar um script q ao perder vida, o player perde dinheiro! function vida = setElementHealth(thePlayer) if vida <= 80 then local takeCash = takeCash(thePlayer) takePlayerMoney(thePlayer, 3000) outputChatBox("vc perdeu 3mil por se ferir!") end end Edited August 15, 2021 by luccah_ds
Human Resources Staff Vinyard Posted August 15, 2021 Human Resources Staff Posted August 15, 2021 Hi, welcome to the forums! Your thread has been moved to a more language-specific section so you can get help in your native language. 1
Other Languages Moderators androksi Posted August 15, 2021 Other Languages Moderators Posted August 15, 2021 Olá! Se você está começando, nada melhor que visitar alguns links super úteis para entender a base, antes de tentar fazer qualquer coisa. Veja estes links: Tutorial de Lua + conceitos do MTA:SA Playlist de Lua para MTA:SA + projeto Entendendo a Wiki do MTA A base é importante para você não cometer erros bobos. 1
Looktovask Posted August 15, 2021 Posted August 15, 2021 addEventHandler( "onPlayerDamage", root, function (attacker, damage_causing, bodypart, loss) local Dano = damage_causing local Dinheiro = getPlayerMoney( source ) local Multiplicador = 2 takePlayerMoney( source, Dinheiro-Dano*Multiplicador ) end) não testei, deve ser adicionado num script server side, ele pega quanto tem de dinheiro, quanto de dano foi feito, multiplica o dano e remove este valor de dinheiro do player 1
luccah_ds Posted August 15, 2021 Author Posted August 15, 2021 Esse está funcionando perfeitamente, mas ele tira o dinheiro baseado no dano que o player tomou, eu queria que fosse retirado uma quantia fixa, se a vida do player fosse abaixo de 80
Looktovask Posted August 16, 2021 Posted August 16, 2021 (edited) addEventHandler( "onPlayerDamage", root, function (attacker, damage_causing, bodypart, loss) local Vida = getElementHealth( source ) local Dinheiro = getPlayerMoney( source ) local DinheiroRemover = 500 -- quantidade a remover local QntdVidaMin = 80 -- quantidade minima para começar a remover dinheiro if Vida < QntdVidaMin then takePlayerMoney( source, Dinheiro-DinheiroRemover ) end end) Edited August 16, 2021 by Looktovask 1
luccah_ds Posted August 16, 2021 Author Posted August 16, 2021 Perfeito! Agradeço, vc me ensinou bastante.
Boechat Posted August 17, 2021 Posted August 17, 2021 addEventHandler( "onPlayerDamage", root, function (attacker, damage, bodypart, loss) if getElementHealth(source) - loss < 80 then --Calcula se o player ficará com menos de 80 de vida com o dano. Se sim, já retira o dinheiro. takePlayerMoney( source, 100 ) --Tira 100 de dinheiro de quem sofreu dano end end) Corrigi algumas coisinhas e diminui um pouco o código. 1 1
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