1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Shop

Discussion in 'Skript' started by Runakai, May 1, 2018.

Tags:
Thread Status:
Not open for further replies.
  1. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Yeah, it's me again. So..

    Code (Skript):
    1.  
    2. on inventory click:      
    3.     if event-inventory is not player's inventory:
    4.         if name of player's current inventory is "&cErze":
    5.             cancel event
    6.             if clicked slot is 9:
    7.                 close inventory of player
    8.                 make player execute command "/shop"
    9.             if player has enough space for 64 dirt:
    10.                 clicked item is not air:
    11.                     clicked slot is 0:
    12.                         if clicked type is LEFT mouse:
    13.                             if {coins::%player%} is more than {@ironpricebuyandsell}-1:
    14.                                 give player a iron ingot
    15.                                 remove {@ironpricebuyandsell} from {coins::%player%}
    16.                                 send "{@buyed1}"
    17.                         else if clicked type is right mouse:
    18.                             loop all items in the player's inventory:
    19.                                 if loop-item is iron ingot:
    20.                                     if amount of loop-item is more than 0:
    21.                                         remove 1 iron ingot from the player
    22.                                         play "NOTE_PLING" to player at volume 0.2
    23.                                         add {@ironpricebuyandsell} to {coins::%player%}
    24.                                         #send "{@selled1}"
    25.                                     else:
    26.                                         send "{@needone}"
    27.                         else if clicked type is right mouse button with shift:
    28.                             loop all items in the player's inventory:
    29.                                 if loop-item is iron ingot:
    30.                                     if amount of loop-item is more than 63:
    31.                                         set {_amountitem} to amount of loop-item
    32.                                         remove 64 iron ingot from the player
    33.                                         play "NOTE_PLING" to player at volume 0.2
    34.                                         add {@ironpricebuyandsell}*64 to {coins::%player%}
    35.                                         #send "{@selledstack}"
    36.                                     else:
    37.                                         send "{@needstack}"
    38.                         else if clicked type is left mouse button with shift:
    39.                             if {coins::%player%} is more than {@ironpricebuyandsell}*64-1:
    40.                                 remove {@ironpricebuyandsell}*64 from {coins::%player%}
    41.                                 send "{@buyedstack}"
    42.                                 loop 64 times:
    43.                                     wait 1 tick
    44.                                     give player a iron ingot
    I want skript to ignore actually the total amount of the item in the player's inventory. They should just sell 1 if they have more than 1 in their inventory. But with this skript, when i have e.g 10 stacks of Iron ingots, it sells 10 iron ingots although it should just sell one.

     
  2. Best Answer:
    Post #6 by TeAm6_AZLIK, May 1, 2018
  3. TeAm6_AZLIK

    TeAm6_AZLIK Member

    Joined:
    Dec 5, 2017
    Messages:
    23
    Likes Received:
    0
    Add me on discord TeAm6_AZLIK#5741
     
  4. JustADev

    JustADev Well-Known Member

    Joined:
    Apr 8, 2017
    Messages:
    380
    Likes Received:
    9
    you need to do, loop-items in {_player}'s inventory,

    Code (Skript):
    1. function Sell(player: player, block: item):
    2.     set {_Amount} to amount of {_block} in {_player}'s inventory
    3.     send "%{_Amount}%" to {_player}
     
  5. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Everything is working alright but I just want the Skript to remove 1 of the iron I got but it removes 1 from every stack it looped and not 1 from the whole amount of the item Ingots in the inventory
     
  6. JustADev

    JustADev Well-Known Member

    Joined:
    Apr 8, 2017
    Messages:
    380
    Likes Received:
    9
    remove 1 of item from item stack of player?
     
  7. TeAm6_AZLIK

    TeAm6_AZLIK Member

    Joined:
    Dec 5, 2017
    Messages:
    23
    Likes Received:
    0
    Code (Skript):
    1.     loop all items in the player's inventory:
    2.         if loop-item is iron ingot:
    3.             if amount of loop-item is more than 0:
    4.                 remove 1 iron ingot from the player"
    5.  
    6.    #Cant you use this instead of this ^?
    7.  
    8.  
    9.    if player's inventory contains a iron ingot:
    10.        remove 1 irong ingot from player's inventory
     
Thread Status:
Not open for further replies.

Share This Page

Loading...