negative balance

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Doodle

Well-Known Member
Sep 3, 2023
490
63
28
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:

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.
 
I still don't understand what you mean by 'use variables'.
 
you could check essentials (or another plugin) config, also that’s basically the first thing you learn in skript lol
I mean 1k how to use variables and list variables, but then it's kinda complicated from there. I'll try to check config.
 
I don't understand what you mean by storing money. I do know how to use variables.
I bet you can go simple.
Code:
#skript by zcx2

on death:
    if {balance::%victim's uuid%} <=5:
        set {balance::%victim's uuid%} to 0
    else if {balance::%victim's uuid%} >=6:
        remove 5 from {balance::%victim's uuid%}
 
I bet you can go simple.
Code:
#skript by zcx2

on death:
    if {balance::%victim's uuid%} <=5:
        set {balance::%victim's uuid%} to 0
    else if {balance::%victim's uuid%} >=6:
        remove 5 from {balance::%victim's uuid%}
Well, thanks for giving me an actual example, but I doubt this will work.