variable not working

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

    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.

JustADev

Well-Known Member
Apr 8, 2017
379
9
18
Whenever i try to send the msg it gives me an error:
CODE:

code_language.skript:
on death:
    attacker is a player
    set {_head} to ("%victim%" parsed as offline player)'s skull
    drop {_head} named "&c%victim%'s Head &7(Right Click)" at victim's location
    
on rightclick holding a player head:
    remove player head from player
    make player execute command "/g123e73"
    make player execute command "/head145"
    message "&cChaoticMC &8&l» &7You have sold &c%UUID of victim%'s Head &7for &b5 XP"
 
Whenever i try to send the msg it gives me an error:
CODE:

code_language.skript:
on death:
    attacker is a player
    set {_head} to ("%victim%" parsed as offline player)'s skull
    drop {_head} named "&c%victim%'s Head &7(Right Click)" at victim's location
   
on rightclick holding a player head:
    remove player head from player
    make player execute command "/g123e73"
    make player execute command "/head145"
    message "&cChaoticMC &8&l» &7You have sold &c%UUID of victim%'s Head &7for &b5 XP"
what error do you get?
 
oh lol we just worked on this codeXD it'd need to be %player%, but that's going to give you the uuid of the player in the event, not the head. I still think you need to set a variable to the name of the players head in the on death event and then reference it in the click command, though. I can;t think of another way to do it.
 
Oooo wait better idea, how silly of me x3
code_language.skript:
on death:
    attacker is a player
    set {_head} to ("%victim%" parsed as offline player)'s skull
    drop {_head} named "&c%victim%'s Head &7(Right Click)" at victim's location
  
on rightclick holding a player head:
    make player execute command "/g123e73"
    make player execute command "/head145"
    message "&cChaoticMC &8&l» &7You have sold &c%name of player's tool% &7for &b5 XP"
    remove player head from player
I think this should set the message name to the name your local variable set in your on death event. and then I moved the item delete after it so it could send the message first and have a name to pull from
 
Oh, nice, Now one question, how would you make it so that:
when the head is dropped, it is shot straight up into the air?
 
Oh, nice, Now one question, how would you make it so that:
when the head is dropped, it is shot straight up into the air?
Maybe like this? not certain if it will work. The on drop event is super finicky.
code_language.skript:
on drop:
    loop entities in radius 4 of player:
        if loop-entity is player head:
            push loop-entity upwards at speed 1
 
Maybe like this? not certain if it will work. The on drop event is super finicky.
code_language.skript:
on drop:
    loop entities in radius 4 of player:
        if loop-entity is player head:
            push loop-entity upwards at speed 1
No it's not, use event-entity
 
No it's not, use event-entity
Neither actually work. So yes, it is a finicky event.
**Also, could you kindly stop quoting like all my posts to leave a snarky comment? Maybe that's just what you do normally or something, but it's ultimately unhelpful to the OP and rude. :/ Try just helping the poster.
 
Last edited by a moderator:
@Pikachu It will not work the same.

@Wynnevir It's not the drop event the problem , but that the loop doesn't get the dropped items list as "items" but just as "dropped item" , so it can't recognise the type of drop.

@JustADev That's a nice workaround:

code_language.skript:
on drop of head:
    wait 1 ticks
    loop all entities in radius 2 of event-player:
        if loop-entity isn't alive:
            push loop-entity upwards at speed 1
 
Last edited by a moderator:
Neither actually work. So yes, it is a finicky event.
**Also, could you kindly stop quoting like all my posts to leave a snarky comment? Maybe that's just what you do normally or something, but it's ultimately unhelpful to the OP and rude. :/ Try just helping the poster.
I always just respond to whatever the current solution is, most of the time I'm on mobile so i can't really bother typing out full code snippets
[doublepost=1501464099,1501463928][/doublepost]
@Pikachu It will not work the same.

@Wynnevir It's not the drop event the problem , but that the loop doesn't get the dropped items list as "items" but just as "dropped item" , so it can't recognise the type of drop.

@JustADev That's a nice workaround:

code_language.skript:
on drop of head:
    wait 1 ticks
    loop all entities in radius 2 of event-player:
        if loop-entity isn't alive:
            push loop-entity upwards at speed 1
That's part of it, but he also didn't wait a tick... @Wynnevir events (mostly) are called before they occur, so the entity doesnt actually exist there yet. By waiting a tick, the event is guaranteed to pass.
code_language.skript:
on drop:
  push event-entity upwards with force 3
should be what the final code is
 
@Pikachu Your right , forgot that the drop was an event-item instead of event-entity , that's the reason of my workaround.
In this way it works well without the tick too.
 
Status
Not open for further replies.