Taking a Percentage of Players Balance on death.

  • 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!

Status
Not open for further replies.

MykGyvr

Member
Oct 22, 2020
3
0
1
Hello there! I'm semi-new to Skript and the one thing i've never truly worked with is percentages. I've done some research without luck. I'm here to ask, how would I go about taking a percentage of a players balance when killed by another player and paying the attacker that percentage?

Example: Victim has a $555 Balance. When killed, the victim loses 10% of that balance ($55) and that 10% is paid to the attacker.

If anyone could offer any sort of assistance/guidance it would be really appreciated!

Thanks!
 
Code:
on death:
    victim is a player:
        attacker is a player:
            set {_gain} to (balance of victim / 10)
            add {_gain} to balance of attacker
            remove {_gain} from balance of victim
            send "You earned %{_gain}% from killing %victim%" to attacker
            send "You lost %{_gain}%" to victim
 
Status
Not open for further replies.