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.

Take away XP? Also enchanting item in variable.

Discussion in 'Skript' started by Krazy, Jan 26, 2017.

Thread Status:
Not open for further replies.
  1. Krazy

    Krazy Member

    Joined:
    Jan 26, 2017
    Messages:
    68
    Likes Received:
    4
    Hi, I just made this account today, the new forums are awesome! Like xenforo over discourse :emoji_wink:

    Anyways, I made a post about a year ago on the other forums asking if you could take XP away, is this possible now? I couldn't find anything on the docs but it could be with some math or something. The other question is.. I have a random loot generator, but I'm having trouble enchanting the item with random vanilla enchantments. I've tried parsed as enchantment, without it with "%%" without it, I've tried a lot and to no avail, doesn't work. I've also tried enchanting {_loot} with {_e}, didn't work. Anyone have this problem or have a solution? Thanks!

    Code (Skript):
    1.         set {_u} to block at player
    2.         set block at {_u} to chest
    3.         set {_prefix} to a random element of {randomitem_prefixes::*}
    4.         set {_suffix} to a random element of {randomitem_suffixes::*}
    5.         set {_loot?} to a random number between 1 and 100
    6.         if {_loot?} is less than or equal to 86:
    7.             set {_loot} to a random element of {commonrloot::*}
    8.         else if {_loot?} is less than or equal to 99:
    9.        
    10.         else if {_loot?} is less than or equal to 100:
    11.         if {_loot} is any helmet:
    12.             set {_item} to "Helmet"
    13.         if {_loot} is any chestplate:
    14.             set {_item} to "Chestplate"
    15.         if {_loot} is any leggings:
    16.             set {_item} to "Leggings"
    17.         if {_loot} is any boots:
    18.             set {_item} to "Boots"
    19.         if {_loot} is any sword:
    20.             set {_item} to "Sword"
    21.         if {_loot} is any axe:
    22.             set {_item} to "Axe"
    23.         if {_loot} is any bow:
    24.             set {_item} to "Bow"
    25.         if {_loot} is any pickaxe:
    26.             set {_item} to "Pickaxe"
    27.         set {_e} to "protection 4" parsed as enchantment
    28.            
    29.            
    30.         if {_loot} is any helmet or chestplate or leggings or boots or sword or axe or bow or pickaxe:
    31.             set {_loot} to {_loot} of {_e} named "&7%{_prefix}%%{_item}% of %{_suffix}%"
    32.             broadcast "&e%{_loot}%"
    33.             add {_loot} to block at {_u}
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    You can use
    Code (Skript):
    1. player's xp
    as an expression, can add/subtract/set it. So
    Code (Skript):
    1. subtract 5 from player's xp
    should work fine.

    If you're sure you've tried everything, and it won't let you use a variable as an enchantment type, you could try to use the SkQuery evaluate instead.
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Already tried setting {_e} to a enchantment without " around it.
    subtract <x> xp from player exists??!?! When was this made :emoji_astonished: Also do you have a example of evaluate? Never used it

    EDIT: the xp thing did not work :/
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    The way you wrote it is wrong, it's not "subtract <x> xp from player", it's "subtract <x> from player's xp" (like I said the first time). I'm not sure if it needs an addon, but I'm using the subtract effect on my server and it works fine. You could also try "xp of player" instead.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Code (Skript):
    1. Example:
    2.  
    3. if xp of player is more than 100:
    4.     remove 100 from xp of player
    I think you need of addon tuske
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Yeah I know, sorry :emoji_stuck_out_tongue: I used
    remove 1000 from xp of player
    and it says it can only be used in an on fishing event o-O
    --- Double Post Merged, Jan 26, 2017, Original Post Date: Jan 26, 2017 ---
    Oh awesome, it works. Never knew about that.. Do you know how to use the evaluate thing? I've personally never used it before.
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Evaluate is using string as codes.
    |evaluate "send ""hi"" to %player%"|will send "Hi" to typed player
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    So it'd be
    Code (Skript):
    1. evaluate "set {_loot} to {_loot} of {_e} named ""&7%{_prefix}%%{_item}% of %{_suffix}%"""
    ?
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Yeah, it's very handy for firework generator or block break particles
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    Code (Skript):
    1.         set {_e} to protection 4
    2.            
    3.         if {_loot} is any helmet or chestplate or leggings or boots or sword or axe or bow or pickaxe:
    4.             evaluate "set %{_loot}% to %{_loot}% of %{_e}% named ""&7%{_prefix}%%{_item}% of %{_suffix}%"" parsed as itemtype"
    5.             broadcast "&e%{_loot}%"
    6.             add {_loot} to block at {_u}
    Using this and it's only putting just the item without name/enchants in the chest. Any ideas? I set {_e} to "protection 4" also and it didn't work, as well as adding parsed as enchantment at the end.
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,178
    Likes Received:
    218
    ```
    set {_e} to "protection 4"
    ```
     
Thread Status:
Not open for further replies.

Share This Page

Loading...