Solved Setting value to a projectile

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

Bilbo

Member
Jan 26, 2017
27
0
0
29
Good evening everybody.

What i cant exactly realize is one thing, that is this.
I tried many ways, read the docs, couldnt figure out how to call out the value from a projectile.

What i want to do is set a value to a projectile that is fireball and afterwards when it hits something, it reads the value and does the specific thing from the value type.

Here is the code:

code_language.skript:
on right click holding redstone repeater:
    if player has clay ball:
        remove 1 clay ball from player
        shoot a fireball from player at speed 1
        set {_flm} to event-projectile
    else:
        send "you dont have ammo"

on projectile hit:
    if event-projectile is a fireball:
        if {_flm} of event-projectile is set:
            broadcast "works"
    broadcast "Canon"


Cant manage for it to broadcast "works"
 
Good evening everybody.

What i cant exactly realize is one thing, that is this.
I tried many ways, read the docs, couldnt figure out how to call out the value from a projectile.

What i want to do is set a value to a projectile that is fireball and afterwards when it hits something, it reads the value and does the specific thing from the value type.

Here is the code:

code_language.skript:
on right click holding redstone repeater:
    if player has clay ball:
        remove 1 clay ball from player
        shoot a fireball from player at speed 1
        set {_flm} to event-projectile
    else:
        send "you dont have ammo"

on projectile hit:
    if event-projectile is a fireball:
        if {_flm} of event-projectile is set:
            broadcast "works"
    broadcast "Canon"


Cant manage for it to broadcast "works"

You can't use local variables outside of the event they're set in.
code_language.skript:
on right click holding redstone repeater:
    if player has clay ball:
        remove 1 clay ball from player
        shoot a fireball from player at speed 1
        set {flm.%event-projectile%} to "whatever"
    else:
        send "you dont have ammo"
 
on projectile hit:
    if event-projectile is a fireball:
        if {flm.%event-projectile%} is set:
            broadcast "works"
    broadcast "Canon"

EDIT: actually, this won't work, since you don't have an event projectile in an on right click event. You could try "last shot projectile" but I don't know if that'll work. Stumbled upon the same problem myself. (otherwise the code is fine except for the 'event-projectile' part in the on right click)
 
You might be looking for metadatas, you can use either Skellett or RandomSK if you want them, example:
code_language.skript:
on right click holding a redstone repeater:
    if player has clay ball:
        remove 1 of clay ball from player
        shoot a fireball from player
        set metadata "Special" of shot projectile to "whatever"

on projectile hit:
    if projectile is a fireball:
        if metadata "Special" of projectile is "whatever":
            broadcast "Works"
 
You might be looking for metadatas, you can use either Skellett or RandomSK if you want them, example:
code_language.skript:
on right click holding a redstone repeater:
    if player has clay ball:
        remove 1 of clay ball from player
        shoot a fireball from player
        set metadata "Special" of shot projectile to "whatever"

on projectile hit:
    if projectile is a fireball:
        if metadata "Special" of projectile is "whatever":
            broadcast "Works"
RandomSK isnt outdated? or unsopported? I read that Skellet use the same expression of metada that RandomSK uses. But i didn't found documentation of Skellet related to metadatas.
 
You might be looking for metadatas, you can use either Skellett or RandomSK if you want them, example:
code_language.skript:
on right click holding a redstone repeater:
    if player has clay ball:
        remove 1 of clay ball from player
        shoot a fireball from player
        set metadata "Special" of shot projectile to "whatever"

on projectile hit:
    if projectile is a fireball:
        if metadata "Special" of projectile is "whatever":
            broadcast "Works"
Thank you, this worked ^^
 
RandomSK isnt outdated? or unsopported? I read that Skellet use the same expression of metada that RandomSK uses. But i didn't found documentation of Skellet related to metadatas.
RandomSK is outdated and unsupported but if you apply the special source fix to it you can use it on every 1.9+ server (actually using it on my 1.11.2 server).
 
I just only want give you a note. If you restart your server all metadata are gonna lost. I think, because I test it with entity.
 
I just only want give you a note. If you restart your server all metadata are gonna lost. I think, because I test it with entity.

Oky, thats something ill keep in mind in the future.
For my case, its a cannon that works like a flying tnt. So i guess im good with it this time.
 
Status
Not open for further replies.