Solved Naming problem

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

BaddCamden

Member
Nov 18, 2019
25
0
0
America
So I am trying to make a wand plugin, but if I have a regular stick, it confuses it with a wand. I want to know how to let the skript know it is unnamed/named.

Code:
on load:
register new shapeless recipe for stick named "&2&lBasic Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with 2 cobblestone," and "&c2 coal, and 1 dirt!" using stick, dirt, cobblestone, air, air, air, air, air, air
register new shapeless recipe for stick named "&c&oImproved &2Basic Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with 3 cobblestone," and "&c4 coal, and 1 dirt!" using stick named "&2&lBasic Wand&r", dirt, cobblestone, cobblestone, coal, coal, air, air, air
register new shapeless recipe for stick named "&9Better Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with " and "&c7 coal and 1 dirt!" using stick named "&c&oImproved &2Basic Wand&r", dirt, cobblestone, cobblestone, coal, coal, cobblestone, coal, coal
set {named} to false

on shoot:
shooter is a player
if name of shooter's held item is "&2&lBasic Wand&r":
set metadata value "Damage" of event-projectile to "1"
set metadata value "Wand" of event-projectile to "Basic Wand"
set {named} to true
if name of shooter's held item is "&c&oImproved &2Basic Wand&r":
set metadata value "Damage" of event-projectile to "2"
set metadata value "Wand" of event-projectile to "Improved Basic Wand"
set {named} to true
if name of shooter's held item is "&9Better Wand&r":
set metadata value "Damage" of event-projectile to "3"
set metadata value "Wand" of event-projectile to "Better Wand"
set {named} to true

on damage:
"%damage cause%" is "projectile"
set {_damage} to metadata value "Damage" of event-projectile
set damage to {_damage} parsed as number
set {type} to metadata value "Wand" of event-projectile
#broadcast "%attacker% damaged %victim% by %damage% with %{type}%."

on rightclick holding stick:
set {wanduser} to player
set {_cd} to difference between {shoot-arrow.%uuid of player%} and now
if {_cd} is less than 0.2 seconds:
stop
set {shoot-arrow.%uuid of player%} to now
shoot arrow from player at speed 10



on projectile hit:
set {_locationtarget} to the location 1 in front of the projectile
drawLine particle redstone, RGB 0, 1, 1, center {wanduser}, target {_locationtarget}, id "%shooter%", rainbowMode true, solid false, density 1, length 0, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 1.2, 0, pulseDelay 0
delete projectile

Plugins:
skDragon, Skript, SkVault, Skquery
 
Pretty sure this is right:
code_language.skript:
on rightclick holding stick:
    name of player's held item is set
    #do wand stuff
From my experience, if the custom name of an item is not set, %name of %itemstack%" will return <none> which means that it isn't set. That code should prevent players using normal sticks as wands but it will work like a wand if it has a custom name set. I don't know if this varies from version to version though.

To detect if a player's held item is not named, you do the opposite:
code_language.skript:
name of player's held item is not set
 
Status
Not open for further replies.