Take away XP? Also enchanting item in variable.

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

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

Krazy

Member
Jan 26, 2017
68
4
8
22
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_language.skript:
        set {_u} to block at player
        set block at {_u} to chest
        set {_prefix} to a random element of {randomitem_prefixes::*}
        set {_suffix} to a random element of {randomitem_suffixes::*}
        set {_loot?} to a random number between 1 and 100
        if {_loot?} is less than or equal to 86:
            set {_loot} to a random element of {commonrloot::*}
        else if {_loot?} is less than or equal to 99:
        
        else if {_loot?} is less than or equal to 100:
        if {_loot} is any helmet:
            set {_item} to "Helmet"
        if {_loot} is any chestplate:
            set {_item} to "Chestplate"
        if {_loot} is any leggings:
            set {_item} to "Leggings"
        if {_loot} is any boots:
            set {_item} to "Boots"
        if {_loot} is any sword:
            set {_item} to "Sword"
        if {_loot} is any axe:
            set {_item} to "Axe"
        if {_loot} is any bow:
            set {_item} to "Bow"
        if {_loot} is any pickaxe:
            set {_item} to "Pickaxe"
        set {_e} to "protection 4" parsed as enchantment
            
            
        if {_loot} is any helmet or chestplate or leggings or boots or sword or axe or bow or pickaxe:
            set {_loot} to {_loot} of {_e} named "&7%{_prefix}%%{_item}% of %{_suffix}%"
            broadcast "&e%{_loot}%"
            add {_loot} to block at {_u}
 
You can use
code_language.skript:
player's xp
as an expression, can add/subtract/set it. So
code_language.skript:
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.
 
Try this
code_language.skript:
set {_e} to protection 4
        if {_loot} is any helmet or chestplate or leggings or boots:
            enchant {_loot} with {_e}
Already tried setting {_e} to a enchantment without " around it.
You can use
code_language.skript:
player's xp
as an expression, can add/subtract/set it. So
code_language.skript:
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.
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 :/
 
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.
 
code_language.skript:
Example:

if xp of player is more than 100:
    remove 100 from xp of player
I think you need of addon tuske
 
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.
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
[doublepost=1485456056,1485455756][/doublepost]
code_language.skript:
Example:

if xp of player is more than 100:
    remove 100 from xp of player
I think you need of addon tuske
Oh awesome, it works. Never knew about that.. Do you know how to use the evaluate thing? I've personally never used it before.
 
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
[doublepost=1485456056,1485455756][/doublepost]
Oh awesome, it works. Never knew about that.. Do you know how to use the evaluate thing? I've personally never used it before.
Evaluate is using string as codes.
|evaluate "send ""hi"" to %player%"|will send "Hi" to typed player
 
Yeah, it's very handy for firework generator or block break particles
code_language.skript:
        set {_e} to protection 4
            
        if {_loot} is any helmet or chestplate or leggings or boots or sword or axe or bow or pickaxe:
            evaluate "set %{_loot}% to %{_loot}% of %{_e}% named ""&7%{_prefix}%%{_item}% of %{_suffix}%"" parsed as itemtype"
            broadcast "&e%{_loot}%"
            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.
 
code_language.skript:
        set {_e} to protection 4
          
        if {_loot} is any helmet or chestplate or leggings or boots or sword or axe or bow or pickaxe:
            evaluate "set %{_loot}% to %{_loot}% of %{_e}% named ""&7%{_prefix}%%{_item}% of %{_suffix}%"" parsed as itemtype"
            broadcast "&e%{_loot}%"
            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.
```
set {_e} to "protection 4"
```
 
Status
Not open for further replies.