Custom food

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

Raigna

Member
Oct 2, 2017
17
0
0
36
Hi

i have 2 problems im trying to solve, im trying to create custom food items for my server but im having trouble with the line "remove 1 player head named "<gold><b>Honey" from player" the skript will work as intended but will not remove the item i right clicked from my inventory

the second problem is I want to increase the players hunger bar by 8 instead of just setting the food bars level but i have no idea how to do this

code_language.skript:
On rightclick:
    if name of held item of player is "<gold><b>Honey":
        play ENTITY GENERIC EAT at player with pitch 1
        set the player's food level to 8
        remove 1 player head named "<gold><b>Honey" from player

any help would be appreciated, thanks!
 
Try this, maybe it will solve the problem first:
code_language.skript:
on rightclick holding player's head:
    if name of item-event is "Your name item":
        play ENTITY GENERIC EAT at player with pitch 1
        set the player's food level to 8
        remove 1 item-event from player
 
  • Like
Reactions: Dems26
1. youre near right...

code_language.skript:
remove 1 player head named "..." from player's inventory

2. Math things.

code_language.skript:
set {_p} to player's food level
add 8 to {_p}
if {_p} is more than 20:
    set {_p} to 20 #Im not sure if this requried, maybe if more than 20 would maybe bugged?
set player's food level to {_p}
 
thank you both i'll try that
[doublepost=1510243224,1510239754][/doublepost]so i tried and its working but it wont remove one item every time i consume it

when using the code from HackerOTVW i was getting the error "can't compare item-event with a text" and so i changed the last part as ChisleLP instructed and updated the hunger level part (which works :emoji_stuck_out_tongue:) but the item still doesnt remove itself

code_language.skript:
on rightclick holding a player head:
    if name of held item of player is "<gold><b>Honey":
        play ENTITY GENERIC EAT at player with pitch 1
        set {_p} to player's food level
        add 8 to {_p}
        if {_p} is more than 20:
            set {_p} to 20 #Im not sure if this requried, maybe if more than 20 would maybe bugged?
        set player's food level to {_p}
        remove 1 player head named "<gold><b>Honey" from player's inventory
[doublepost=1510244560][/doublepost]never mind i worked it out but thanks for your help, i really appreciate it, it had something to do with it being a player head

code_language.skript:
on rightclick holding a player head:
    if name of held item of player is "<gold><b>Honey":
        play ENTITY GENERIC EAT at player with pitch 1
        set {_p} to player's food level
        add 8 to {_p}
        if {_p} is more than 20:
            set {_p} to 20 #Im not sure if this requried, maybe if more than 20 would maybe bugged?
        set player's food level to {_p}
        set {_name} to name of player's tool
        if {_name} contains "<gold><b>Honey":
            remove 1 of player's tool from player
 
Status
Not open for further replies.