Wont read name

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

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hello, im working on a fishing skript, and seem to be running into a very small issue. Im making a gui i place the fish in, and it will detect the fish that i added in and will add the correct amount of money. But i want the gui to pickup on the custom fish and not a normal fish you get by fishing. I have the fish called "Common Herring", and when i place it in the gui and click the diamond, it says its not a fish. But i have it setup to check for the common herring and it says its not the correct thing. Ill post the code and a sample of what is happening. If anyone might know whats going on, please let me know ASAP.
Thanks!
~Matt

Skript version:
2.4

Server version.
1.14.4

Code:

Code:
function fisherman(P: player):
    open chest with 4 rows named "&bMr. Boatwright" to {_P}
    set {temp::%{_P}%} to true
    set {_a} to 0
    set {sell::%{_P}%} to 0
    format gui slot 27, 28, 29, 30, 32, 33 and 34 of {_P} with green stained glass pane named ""
    format gui slot 35 of {_P} with diamond named "&aSell" to run:
        set {_a} to amount of raw cod named "Common Herring" in {_P}'s current inventory
        add ({_a} * 10.00) to balance of {_P}
        add ({_a} * 10.00) to {_m}
        if {_P}'s current inventory contains raw cod named "Common Herring":
            send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_m}%" to {_P}
            close {_P}'s inventory
        else:
            set {_num} to 0
            loop 27 times:
                set slot {_num} of {_P}'s current inventory to air
                add 1 to {_num}
            send "&b[Mr. Boatwright] &7You can only send fish here!" to {_P}
    while {temp::%{_P}%} is true:
        set {_a} to amount of raw cod named "Common Herring" in {_P}'s current inventory
        set {_m} to {_a} * 10.00
        format gui slot 31 of {_P} with emerald named "&aSell for: &a$&a%{_m}%" with lore "&bAmount of fish: %{_a}%"
        wait 1 ticks
Video:
https://gyazo.com/0d1af89dc668a57f536554a8eb79404a

It says i can only send fish, but i am sending fish. I even have it in the sample video. I even tried named colored "Common Herring"
[doublepost=1582047430,1581914648][/doublepost]bump
[doublepost=1582132293][/doublepost]Ok, so i know it has to do with this line here. I was looking way more into this, and this is the line thats not making it work i think.

Code:
if {_P}'s current inventory contains raw cod named "Common Herring":
 
Try to include the color code (&)

Like this:
Code:
if {_P}'s current inventory contains raw cod named "&7Common Herring":

// EDIT

Finally a Person that used a loop to Format gui-slots. THANKS!
Also do that with every "Common Fish" name

Here's your Code fully edited:
Code:
function fisherman(P: player):
    open chest with 4 rows named "&bMr. Boatwright" to {_P}
    set {temp::%{_P}%} to true
    set {_a} to 0
    set {sell::%{_P}%} to 0
    format gui slot 27, 28, 29, 30, 32, 33 and 34 of {_P} with green stained glass pane named ""
    format gui slot 35 of {_P} with diamond named "&aSell" to run:
        set {_a} to amount of raw cod named "&7Common Herring" in {_P}'s current inventory
        add ({_a} * 10.00) to balance of {_P}
        add ({_a} * 10.00) to {_m}
        if {_P}'s current inventory contains raw cod named "&7Common Herring":
            send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_m}%" to {_P}
            close {_P}'s inventory
        else:
            set {_num} to 0
            loop 27 times:
                set slot {_num} of {_P}'s current inventory to air
                add 1 to {_num}
            send "&b[Mr. Boatwright] &7You can only send fish here!" to {_P}
    while {temp::%{_P}%} is true:
        set {_a} to amount of raw cod named "&7Common Herring" in {_P}'s current inventory
        set {_m} to {_a} * 10.00
        format gui slot 31 of {_P} with emerald named "&aSell for: &a$&a%{_m}%" with lore "&bAmount of fish: %{_a}%"
        wait 1 ticks
 
Try to include the color code (&)

Like this:
Code:
if {_P}'s current inventory contains raw cod named "&7Common Herring":

// EDIT

Finally a Person that used a loop to Format gui-slots. THANKS!
Also do that with every "Common Fish" name

Here's your Code fully edited:
Code:
function fisherman(P: player):
    open chest with 4 rows named "&bMr. Boatwright" to {_P}
    set {temp::%{_P}%} to true
    set {_a} to 0
    set {sell::%{_P}%} to 0
    format gui slot 27, 28, 29, 30, 32, 33 and 34 of {_P} with green stained glass pane named ""
    format gui slot 35 of {_P} with diamond named "&aSell" to run:
        set {_a} to amount of raw cod named "&7Common Herring" in {_P}'s current inventory
        add ({_a} * 10.00) to balance of {_P}
        add ({_a} * 10.00) to {_m}
        if {_P}'s current inventory contains raw cod named "&7Common Herring":
            send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_m}%" to {_P}
            close {_P}'s inventory
        else:
            set {_num} to 0
            loop 27 times:
                set slot {_num} of {_P}'s current inventory to air
                add 1 to {_num}
            send "&b[Mr. Boatwright] &7You can only send fish here!" to {_P}
    while {temp::%{_P}%} is true:
        set {_a} to amount of raw cod named "&7Common Herring" in {_P}'s current inventory
        set {_m} to {_a} * 10.00
        format gui slot 31 of {_P} with emerald named "&aSell for: &a$&a%{_m}%" with lore "&bAmount of fish: %{_a}%"
        wait 1 ticks
Hi, thank you for responding to me! But I’m currently at my great grandmas house to help watch her. I can test it out later today, and see if it works. But I’ve tried named colored “&7Common Herring” before, and the same thing has happened. But I dug a little deeper into this last night, and I think it also has to do with the lore of the fish. Because when I try to place a fish In with no lore and only a name, it works fine. It will only work if the fish has a name only I think. But I need the lore on the fish because it tells who caught the fish and the size of the fish. :emoji_slight_smile:
 
Hi, thank you for responding to me! But I’m currently at my great grandmas house to help watch her. I can test it out later today, and see if it works. But I’ve tried named colored “&7Common Herring” before, and the same thing has happened. But I dug a little deeper into this last night, and I think it also has to do with the lore of the fish. Because when I try to place a fish In with no lore and only a name, it works fine. It will only work if the fish has a name only I think. But I need the lore on the fish because it tells who caught the fish and the size of the fish. :emoji_slight_smile:
Ah that's the problem! If you wanna have the lore in there too and have it work, you'll have to put
Code:
if {_P}'s current inventory contains raw cod named "&7Common Herring" with lore "blah blah":
 
Ah that's the problem! If you wanna have the lore in there too and have it work, you'll have to put
Code:
if {_P}'s current inventory contains raw cod named "&7Common Herring" with lore "blah blah":
Ok, i did what you said, and its still not working. Ill post a pic of what the name and lore look like on the fish, and ill post the new code i have.

Fish name:
https://gyazo.com/0ea23ff642141bb3bebc8d3f7a1eea16

Code:
Code:
function fisherman(P: player):
    open chest with 4 rows named "&bMr. Boatwright" to {_P}
    set {temp::%{_P}%} to true
    set {_a} to 0
    set {sell::%{_P}%} to 0
    format gui slot 27, 28, 29, 30, 32, 33 and 34 of {_P} with green stained glass pane named ""
    format gui slot 35 of {_P} with diamond named "&aSell" to run:
        set {_a} to amount of raw cod named "&7Common Herring" with lore "&* &aSize" in {_P}'s current inventory
        add ({_a} * 10.00) to balance of {_P}
        add ({_a} * 10.00) to {_m}
        if {_P}'s current inventory contains raw cod named "&7Common Herring" with lore "&* &aSize":
            send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_m}%" to {_P}
            close {_P}'s inventory
        else:
            set {_num} to 0
            loop 27 times:
                set slot {_num} of {_P}'s current inventory to air
                add 1 to {_num}
            send "&b[Mr. Boatwright] &7You can only send fish here!" to {_P}
    while {temp::%{_P}%} is true:
        set {_a} to amount of raw cod named "&7Common Herring" with lore "&* &aSize" in {_P}'s current inventory
        set {_m} to {_a} * 10.00
        format gui slot 31 of {_P} with emerald named "&aSell for: &a$&a%{_m}%" with lore "&bAmount of fish: %{_a}%"
        wait 1 ticks

Also, here is a example of 1 of the fish i have:

Code:
set {_var} to random number between 20 and 29.99
        if {_var} is less than 29.99:
            give {_P} a cod named "&7Common Herring" with lore "&8* &aSize: %{_var}%cm" and "&b* &7Caught By %{_P}%"
            send "&8[&bFishing&8] &7You cought a &7Common &aHerring" to {_P}
        if {_var} > ({size::fish::%{_P}%} ? 0):
            set {size::fish::%{_P}%} to {_var}
The indentation is a tad bit off i know lol :emoji_wink:
 
Last edited:
are these bits supposed to not have all the lore?

Code:
set {_a} to amount of raw cod named "&7Common Herring" with lore "&* &aSize" in {_P}'s current inventory
add ({_a} * 10.00) to balance of {_P}
add ({_a} * 10.00) to {_m}
if {_P}'s current inventory contains raw cod named "&7Common Herring" with lore "&* &aSize":
 
I think it will have to have the lore set to work? But if i have the lore, or not have the lore, its not going to work. xD
[doublepost=1582579850,1582410406][/doublepost]bump
[doublepost=1582661806][/doublepost]Ok, i made tons of new changes and im finally getting somewhere now. The only problem im having is, when i place a named fish with a lore, it works and sells the fish. But when i place a normal cod with no name or lore, it shows that it would sell for money and the amount of fish i placed in the gui. How can i make it only detect the custom fish in the gui, and not normal fish?

Code:
function commonherring(P: player):
    set {temp::%{_P}%} to true
    set {_m} to 0
    set {_a} to 0
    open chest with 4 rows named "&bMr. Boatwright" to {_P}
    format gui slot 27, 28, 29, 30, 32, 33, 34 and 35 of {_P} with green stained glass pane named ""
    while {temp::%{_P}%} is true:
        set {_a} to amount of raw cod in {_P}'s current inventory
        set {_f} to amount of raw cod in {_P}'s current inventory
        set {_m} to {_f} * 10.00
        format gui slot 31 of {_P} with diamond named "&aSell for: &a$&a%{_m}%" with lore "&bAmount of fish: %{_f}%" to run:
            add ({_f} * 10.00) to balance of {_P}
            add ({_f} * 10.00) to {_m}
            set {_m} to {_f} * 10.00
            loop all items in {_P}'s current inventory:
                if name of loop-value contains "&7Common Herring":
                    if line 1 of lore of loop-value contains "&8* &aSize":
                        send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_m}%" to {_P}
                        close {_P}'s inventory
                        stop
                else:
                    send "&b[Mr. Boatwright] &7You cant sell that item here!" to {_P}
                    stop
        wait 1 ticks
 
Status
Not open for further replies.