Solved auction like skyslayer

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

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

Cupex

Member
Feb 16, 2020
43
1
8
26
Hello,
I wanted to ask if someone can make a auctions script.
Commands:
/auction (amount) > This is to start a auction the price is the start amount. You need a Item in the hand to start.
/offer (amount) > This Command is to bet more than the start amount. So if the start amount is 1000 the offer amount HAS to be more than 1000

Here is explained how I imagine it:
So if you start a auction with /auction (amount) there will be a broadcast. Something like
"%player% started a auction."
"The Item: (amount of held item)x (name of held item). Use /offer to bet for the item"
Then there is 1 minute time to offer for the item.

--------------

Now to the offer Command:
You can only offer once per auction.
The amount you offer must be higher than the start amount of the auction
You cant cancel the offer, so the money is gone if you offer.

---------------

The last player who has bid the most gets the item.
 
Ich nehme mal an das du Deutsch bist, wenn nicht, sag Bescheid
I assume that you are german, if not tell me

Nicht sicher, ob das ganze funktioniert, hab es nicht getestet
Code:
command /auction [<text>]:
  trigger:
    if player's tool is not air:
      set {_preis} to arg-1 parsed as a integer
      if {_preis} is set:
        if {auktion::status} is not true:
          set {auktion::status} to true
          set {auktion::creator} to player
          set {auktion::tool} to tool of player
          set {auktion::hbit} to {_preis}
          set {auktion::hbitp} to player
          set tool of player to air
          broadcast "%player% hat eine Auktion gestartet"
          broadcast "%player's tool% (Preis: %{_preis}%)"
          broadcast "Setze einen höheren Preis mit /offer (Preis)"
          set {_tleft} to 61
          while {auktion::status} is true:
            if {_tleft} is 30:
              broadcast "30 Sekunden verbleiben | Höchste Wette von %{auktion::hbitp}% (%{auktion::hbit}%)"
            if {_tleft} is less than 1:
              if {auktion::hbitp} is not player:
                broadcast "Gewinner der Auktion %{auktion::hbitp}% mit %{auktion::hbit}%"
                give {auktion::tool} to {auktion::hbitp}
                add {auktion::hbit} to balance of {auktion::creator}
              else:
                broadcast "niemand hat an der auktion teilgenommen"
                give {auktion::tool} to {auktion::hbitp}
              delete {auktion::*}
              stop
            remove 1 from {_tleft}
            wait 1 second
        else:
          send "es läuft bereits eine auktion"
      else:
        send "ungültiger preis"
    else:
      send "ungültiger gegenstand"

command /offer [<text>]:
  trigger:
    if {auktion::status} is true:
      if {auktion::creator} is not player:
        if {auktion::bet::%player%} is not true:
          set {_preis} to arg-1 parsed as a integer
          if {_preis} is set:
            if {_preis} is more than {auktion::hbit}:
              set {auktion::bet::%player%} to true
              set {auktion::hbitp} to player
              set {auktion::hbit} to {_preis}
              remove {_preis} from balance of player
              broadcast "neues höchsgebot bei der auktion: %{_price}% von %player%"
            else:
              send "du hast bereits eine wette abgegeben"
          else:
            send "ungültiger preis"
      else:
        send "du kannst nicht an deiner eigenen auktion teilnehmen"
    else:
      else "Es läuft keine Auktion"
[doublepost=1626284913,1625404114][/doublepost]Hey, I marked my answer as the best solution in this thread! You can mark the best answer to give the user a small thank you and additionally this will be displayed at the top which helps others to find the best solution directly.