I am making a skript so when a player dies, they lose some of their money, and if it's in the negatives, the balance goes farther into the negatives. The problem is, when I test it, when the player's balance is negative, it doesn't want to work and the balance of the player just stays the same. Here is the code:
Please help. I don't understand why this is not working. Also, I double-checked the math and it all checks out so I'm struggling to find where the issue is. If you think there is another way to do this, please let me know.
Code:
function mw(p: player, num1: number, num2: number) :: number:
set {_bal} to {_p}'s balance
if {_bal} >= 0:
return ({_bal} * ({_num1}/{_num2}))
else:
return ({_bal} / ({_num1}/{_num2}))
on death:
victim is a player
if attacker is a player:
remove mw(victim, 1, 2) from victim's balance
send "&cWhen you died, you lost half your money!" to victim
increase attacker's balance by mw(victim, 1, 2)
else:
remove mw(victim, 2, 3) from victim's balance
Please help. I don't understand why this is not working. Also, I double-checked the math and it all checks out so I'm struggling to find where the issue is. If you think there is another way to do this, please let me know.