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!
You can always check out skUnity Downloads for downloads and any other information about Skript!
import:
org.bukkit.event.inventory.InventoryDragEvent
org.bukkit.event.inventory.InventoryClickEvent
function getWorthOfFish(i: Item Type) :: number:
broadcast "Fish4DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()%"
if name of {_i} contains "&7Common Herring":
return 10
else if name of {_i} contains "&7Common Crab":
return 100
else:
return 0
#Bonus money u get wenn a fish has a bigger size than 1.
# Example:
# Inc value = 1$:
# size = 1 = 1$
# size = 1.5 = 1.5$
# size = 3 = 3$
# Inc value = 2.5$:
# size = 1 = 2.5$
# size = 1.5 = 3.75$
# size = 3 = 7.5$
function getSizeIncrease(i: item, s: number) :: number:
broadcast "Fish5DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()% %{_s}%"
if name of {_i} contains "&7Common Herring":
return (1 * {_s})
else if name of {_i} contains "&7Common Crab":
return (10 * {_s})
else:
return 0
function getSize(i: item) :: number:
set {_s} to line 1 of lore of {_i}
set {_s::*} to {_s} split at "&8* &aSize: "
set {_s} to {_s::2}
replace every "cm" with "" in {_s}
set {_s} to {_s} parsed as a number
return {_s}
function getPriceOfFish(i: items) :: number:
broadcast "FishPriceTrigger"
set {_t} to 0
loop {_i::*}:
delete {_p::*}
set {_p::w} to getWorthOfFish(loop-value)
set {_p::s} to getSize(loop-value)
set {_p::i} to getSizeIncrease(loop-value,{_p::s})
set {_p::p} to {_p::w} + {_p::i}
set {_p::a} to item amount of loop-value
set {_p::t} to {_p::a} * {_p::p}
add {_p::t} to {_t}
broadcast "Fish3DATA: %loop-value%"
broadcast "Fish2DATA: %{_p::w}% %{_p::s}% %{_p::i}% %{_p::p}% %{_p::a}% %{_p::t}%"
return {_t}
function getFish(p: player) :: items:
loop all items in {_p}'s current inventory:
if loop-value is raw cod, raw salmon or pufferfish:
if name of loop-value contains "&7Common Herring" or "&7Common Crab":
add loop-value to {_fish::*}
return {_fish::*}
function getLatestPrice(i: item) :: number:
set {_p} to name of {_i}
replace every "&aSell for: &a$&a" with "" in {_p}
set {_p} to {_p} parsed as a number
return {_p}
function fishAmount(i: items) :: number:
set {_t} to 0
loop {_i::*}:
add item amount of loop-value to {_t}
return {_t}
function updateFishPrice(p: player):
wait 1 tick
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set name of slot 31 of {_p}'s current inventory to "&aSell for: &a$&a%{_totalprice}%"
set line 1 of lore of slot 31 of {_p}'s current inventory to "&bAmount of fish: %{_fishamount}%"
function sellFish(p: player, i: item):
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set {_latestprice} to getLatestPrice({_i})
if {_latestprice} = {_totalprice}:
if {_totalprice} = 0:
send "&b[Mr. Boatwright] &cNothing to sell" to {_p}
stop
close {_p}'s inventory
add {_totalprice} to balance of {_p}
send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_totalprice}%" to {_p}
else:
send "&b[Mr. Boatwright] &cOops something went wrong. ##001 Price Not Matching" to {_p}
send "&b[Mr. Boatwright] &7Updating Price..." to {_p}
updateFishPrice({_p})
send "&b[Mr. Boatwright] &7##001 Pls try again." to {_p}
function openfish(p: player):
open virtual chest with size 4 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 "" to do nothing
format gui slot 31 of {_p} with diamond to run function sellFish({_p}, gui-clicked-item)
updateFishPrice({_p})
on InventoryClickEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on InventoryDragEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on right click on entity:
if name of clicked entity contains "&bMr. Boatwright":
openfish(player)
import:
org.bukkit.event.inventory.InventoryDragEvent
org.bukkit.event.inventory.InventoryClickEvent
function getWorthOfFish(i: Item Type) :: number:
broadcast "Fish4DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return 10
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return 100
else:
return 0
#Bonus money u get wenn a fish has a bigger size than 1.
# Example:
# Inc value = 1$:
# size = 1 = 1$
# size = 1.5 = 1.5$
# size = 3 = 3$
# Inc value = 2.5$:
# size = 1 = 2.5$
# size = 1.5 = 3.75$
# size = 3 = 7.5$
function getSizeIncrease(i: item, s: number) :: number:
broadcast "Fish5DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()% %{_s}%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return (1 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return (10 * {_s})
else:
return 0
function getSize(i: item) :: number:
set {_s} to line 1 of lore of {_i}
set {_s::*} to {_s} split at "&8* &aSize: "
set {_s} to {_s::2}
replace every "cm" with "" in {_s}
set {_s} to {_s} parsed as a number
return {_s}
function getPriceOfFish(i: items) :: number:
broadcast "FishPriceTrigger"
set {_t} to 0
loop {_i::*}:
delete {_p::*}
set {_p::w} to getWorthOfFish(loop-value)
set {_p::s} to getSize(loop-value)
set {_p::i} to getSizeIncrease(loop-value,{_p::s})
set {_p::p} to {_p::w} + {_p::i}
set {_p::a} to item amount of loop-value
set {_p::t} to {_p::a} * {_p::p}
add {_p::t} to {_t}
broadcast "Fish3DATA: %loop-value%"
broadcast "Fish2DATA: %{_p::w}% %{_p::s}% %{_p::i}% %{_p::p}% %{_p::a}% %{_p::t}%"
return {_t}
function getFish(p: player) :: items:
loop all items in {_p}'s current inventory:
if loop-value is raw cod, raw salmon or pufferfish:
if name of loop-value contains "&7Common Herring" or "&7Common Crab":
add loop-value to {_fish::*}
return {_fish::*}
function getLatestPrice(i: item) :: number:
set {_p} to name of {_i}
replace every "&aSell for: &a$&a" with "" in {_p}
set {_p} to {_p} parsed as a number
return {_p}
function fishAmount(i: items) :: number:
set {_t} to 0
loop {_i::*}:
add item amount of loop-value to {_t}
return {_t}
function updateFishPrice(p: player):
wait 1 tick
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set name of slot 31 of {_p}'s current inventory to "&aSell for: &a$&a%{_totalprice}%"
set line 1 of lore of slot 31 of {_p}'s current inventory to "&bAmount of fish: %{_fishamount}%"
function sellFish(p: player, i: item):
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set {_latestprice} to getLatestPrice({_i})
if {_latestprice} = {_totalprice}:
if {_totalprice} = 0:
send "&b[Mr. Boatwright] &cNothing to sell" to {_p}
stop
close {_p}'s inventory
add {_totalprice} to balance of {_p}
send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_totalprice}%" to {_p}
else:
send "&b[Mr. Boatwright] &cOops something went wrong. ##001 Price Not Matching" to {_p}
send "&b[Mr. Boatwright] &7Updating Price..." to {_p}
updateFishPrice({_p})
send "&b[Mr. Boatwright] &7##001 Pls try again." to {_p}
function openfish(p: player):
open virtual chest with size 4 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 "" to do nothing
format gui slot 31 of {_p} with diamond to run function sellFish({_p}, gui-clicked-item)
updateFishPrice({_p})
on InventoryClickEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on InventoryDragEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on right click on entity:
if name of clicked entity contains "&bMr. Boatwright":
openfish(player)
Now it shows the amount of fish, and the amount i will get. But i cant click the diamond to sell it. When i click the diamond, it doesnt do anything.
https://gyazo.com/8c3c8e9d008b899e37507b790015b672
import:
org.bukkit.event.inventory.InventoryDragEvent
org.bukkit.event.inventory.InventoryClickEvent
function getWorthOfFish(i: Item Type) :: number:
broadcast "Fish4DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return 10
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return 100
else:
return 0
#Bonus money u get wenn a fish has a bigger size than 1.
# Example:
# Inc value = 1$:
# size = 1 = 1$
# size = 1.5 = 1.5$
# size = 3 = 3$
# Inc value = 2.5$:
# size = 1 = 2.5$
# size = 1.5 = 3.75$
# size = 3 = 7.5$
function getSizeIncrease(i: item, s: number) :: number:
broadcast "Fish5DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()% %{_s}%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return (1 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return (10 * {_s})
else:
return 0
function getSize(i: item) :: number:
set {_s} to line 1 of lore of {_i}
set {_s::*} to {_s} split at "&8* &aSize: "
set {_s} to {_s::2}
replace every "cm" with "" in {_s}
set {_s} to {_s} parsed as a number
return {_s}
function getPriceOfFish(i: items) :: number:
broadcast "FishPriceTrigger"
set {_t} to 0
loop {_i::*}:
delete {_p::*}
set {_p::w} to getWorthOfFish(loop-value)
set {_p::s} to getSize(loop-value)
set {_p::i} to getSizeIncrease(loop-value,{_p::s})
set {_p::p} to {_p::w} + {_p::i}
set {_p::a} to item amount of loop-value
set {_p::t} to {_p::a} * {_p::p}
add {_p::t} to {_t}
broadcast "Fish3DATA: %loop-value%"
broadcast "Fish2DATA: %{_p::w}% %{_p::s}% %{_p::i}% %{_p::p}% %{_p::a}% %{_p::t}%"
return {_t}
function getFish(p: player) :: items:
loop all items in {_p}'s current inventory:
if loop-value is raw cod, raw salmon or pufferfish:
if name of loop-value contains "&7Common Herring" or "&7Common Crab":
add loop-value to {_fish::*}
return {_fish::*}
function getLatestPrice(i: item) :: number:
set {_p} to name of {_i}
replace every "&aSell for: &a$&a" with "" in {_p}
set {_p} to {_p} parsed as a number
return {_p}
function fishAmount(i: items) :: number:
set {_t} to 0
loop {_i::*}:
add item amount of loop-value to {_t}
return {_t}
function updateFishPrice(p: player):
wait 1 tick
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set name of slot 31 of {_p}'s current inventory to "&aSell for: &a$&a%{_totalprice}%"
set line 1 of lore of slot 31 of {_p}'s current inventory to "&bAmount of fish: %{_fishamount}%"
function sellFish(p: player):
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set {_latestprice} to getLatestPrice(slot 31 of {_p}'s current inventory)
if {_latestprice} = {_totalprice}:
if {_totalprice} = 0:
send "&b[Mr. Boatwright] &cNothing to sell" to {_p}
stop
close {_p}'s inventory
add {_totalprice} to balance of {_p}
send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_totalprice}%" to {_p}
else:
send "&b[Mr. Boatwright] &cOops something went wrong. ##001 Price Not Matching" to {_p}
send "&b[Mr. Boatwright] &7Updating Price..." to {_p}
updateFishPrice({_p})
send "&b[Mr. Boatwright] &7##001 Pls try again." to {_p}
function openfish(p: player):
open virtual chest with size 4 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 "" to do nothing
format gui slot 31 of {_p} with diamond to run function sellFish({_p})
updateFishPrice({_p})
on InventoryClickEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on InventoryDragEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on right click on entity:
if name of clicked entity contains "&bMr. Boatwright":
openfish(player)
Ok, not some crazy new stuff is happening.
https://gyazo.com/dee89971cadd385b0846624514085336
import:
org.bukkit.event.inventory.InventoryDragEvent
org.bukkit.event.inventory.InventoryClickEvent
function getWorthOfFish(i: item) :: number:
broadcast "Fish4DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return 10
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return 100
else:
return 0
#Bonus money u get wenn a fish has a bigger size than 1.
# Example:
# Inc value = 1$:
# size = 1 = 1$
# size = 1.5 = 1.5$
# size = 3 = 3$
# Inc value = 2.5$:
# size = 1 = 2.5$
# size = 1.5 = 3.75$
# size = 3 = 7.5$
function getSizeIncrease(i: item, s: number) :: number:
broadcast "Fish5DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()% %{_s}%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return (1 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return (10 * {_s})
else:
return 0
function getSize(i: item) :: number:
set {_s} to line 1 of lore of {_i}
set {_s::*} to {_s} split at "&8* &aSize: "
set {_s} to {_s::2}
replace every "cm" with "" in {_s}
set {_s} to {_s} parsed as a number
return {_s}
function getPriceOfFish(i: items) :: number:
broadcast "FishPriceTrigger"
set {_t} to 0
loop {_i::*}:
delete {_p::*}
set {_p::w} to getWorthOfFish(loop-value)
set {_p::s} to getSize(loop-value)
set {_p::i} to getSizeIncrease(loop-value,{_p::s})
set {_p::p} to {_p::w} + {_p::i}
set {_p::a} to item amount of loop-value
set {_p::t} to {_p::a} * {_p::p}
add {_p::t} to {_t}
broadcast "Fish3DATA: %loop-value%"
broadcast "Fish2DATA: %{_p::w}% %{_p::s}% %{_p::i}% %{_p::p}% %{_p::a}% %{_p::t}%"
return {_t}
function getFish(p: player) :: items:
loop all items in {_p}'s current inventory:
if loop-value is raw cod, raw salmon or pufferfish:
if name of loop-value contains "&7Common Herring" or "&7Common Crab":
add loop-value to {_fish::*}
return {_fish::*}
function getLatestPrice(i: item) :: number:
set {_p} to {_i}.getItemMeta().getDisplayName()
replace every "&aSell for: &a$&a" with "" in {_p}
set {_p} to {_p} parsed as a number
return {_p}
function fishAmount(i: items) :: number:
set {_t} to 0
loop {_i::*}:
add item amount of loop-value to {_t}
return {_t}
function updateFishPrice(p: player):
wait 1 tick
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set name of slot 31 of {_p}'s current inventory to "&aSell for: &a$&a%{_totalprice}%"
set line 1 of lore of slot 31 of {_p}'s current inventory to "&bAmount of fish: %{_fishamount}%"
function sellFish(p: player):
set {_fish::*} to getFish({_p})
set {_fishamount} to fishAmount({_fish::*})
set {_totalprice} to getPriceOfFish({_fish::*})
set {_latestprice} to getLatestPrice(slot 31 of {_p}'s current inventory)
if {_latestprice} = {_totalprice}:
if {_totalprice} = 0:
send "&b[Mr. Boatwright] &cNothing to sell" to {_p}
stop
close {_p}'s inventory
add {_totalprice} to balance of {_p}
send "&b[Mr. Boatwright] &7You sold all your fish for &a$%{_totalprice}%" to {_p}
else:
send "&b[Mr. Boatwright] &cOops something went wrong. ##001 Price Not Matching" to {_p}
send "&b[Mr. Boatwright] &7Updating Price..." to {_p}
updateFishPrice({_p})
send "&b[Mr. Boatwright] &7##001 Pls try again." to {_p}
function openfish(p: player):
open virtual chest with size 4 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 "" to do nothing
format gui slot 31 of {_p} with diamond to run function sellFish({_p})
updateFishPrice({_p})
on InventoryClickEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on InventoryDragEvent:
if "%event.getView().getTitle()%" = "&bMr. Boatwright":
updateFishPrice(event.getWhoClicked())
on right click on entity:
if name of clicked entity contains "&bMr. Boatwright":
openfish(player)
Ok, i finally think its working now!!! xD But how does the whole checking the money for the fish cost thing work?
Ok, i finally think its working now!!! xD But how does the whole checking the money you get for selling the fish thing work?
function getSizeIncrease(i: item, s: number) :: number:
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return (1 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return (10 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7ANOTHER FISH":
return (100 * {_s})
else if {_i}.getItemMeta().getDisplayName() contains "&7ANOTHER FISH2":
return (50 * {_s})
else:
return 0
function getWorthOfFish(i: item) :: number:
broadcast "Fish4DATA: %{_i}% %{_i}.getItemMeta().getDisplayName()%"
if {_i}.getItemMeta().getDisplayName() contains "&7Common Herring":
return 10
else if {_i}.getItemMeta().getDisplayName() contains "&7Common Crab":
return 100
else if {_i}.getItemMeta().getDisplayName() contains "&7ANOTHER FISH":
return 1000
else if {_i}.getItemMeta().getDisplayName() contains "&7ANOTHER FISH2":
return 50
else:
return 0
Ok, ill give this a shot on setting it up. Thank you very very much for all your help! I really appreciate it!
Will do. Thank you!Np can u put as solved and u can send a dm or on discord if u stuck with this