Solved Functions

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

Skill

New Member
Feb 5, 2017
5
0
0
Skript Version: Skript 2.2 (dev20c)
Skript Author: Bensku
Minecraft Version: 1.11
---
Full Code:

Code (Skript):
code_language.skript:
function getcardWorth(p: player, t: text):
    if {_t} is "1":
        set {_Worth} to 1
    if {_t} is "2":
        set {_Worth} to 2
    if {_t} is "3":
        set {_Worth} to 3
    if {_t} is "4":
        set {_Worth} to 4
    if {_t} is "5":
        set {_Worth} to 5
    if {_t} is "6":
        set {_Worth} to 6
    if {_t} is "7":
        set {_Worth} to 7
    if {_t} is "8":
        set {_Worth} to 8
    if {_t} is "9":
        set {_Worth} to 9
    if {_t} is "10" or "Jack" or "Queen" or "King":
        set {_Worth} to 10
    if {_t} is "Ace":
        set {_Worth} to 11
    add {_Worth} to {Worth} 
    return
and~
code_language.skript:
function startBlackjack(p: player, i: integer):
    open chest with 3 rows named "&c&lBlackjack" to {_p}
    set {CardsLeft.%{_p}%} to 64
    set {_cards} to {CardsLeft.%{_p}%}
    setCardsLeft({_p}, {_cards})
    set slot 12 of {_p}'s current inventory to a stick named "&c&lHit" with lore "||&cClick to gain a card!||&r" 
    set slot 14 of {_p}'s current inventory to a paper named "&a&lStay" with lore "||&rUse this to stay safe if you're within 3 of 21!||&r"   
    set {Blackjack.%{_p}%} to 18 
    set {Count.%{_p}%} to 0
    loop 2 times:
        set {_CardType} to random element out of {CardTypes::*}
        set {_CardSpecify} to random element out of {CardList::*}
        set {_CardGained} to "%{CardColor::%{_CardType}%}% %{_CardSpecify}% of %{_CardType}%"
        set {_s} to {Blackjack.%{_p}%}
        set slot {_s} of {_p}'s current inventory to a paper named "&a%{_CardGained}%" with lore "||&7Default Cards"
        add 1 to {Blackjack.%{_p}%} 
        subtract 1 from {CardsLeft.%{_p}%}
        set {_c} to {CardsLeft.%{_p}%}
        setCardsLeft({_p}, {_c})       
        set {_test} to {_CardSpecify}
        getcardWorth({_p}, "%{_c}%")
        add {_Worth} to {_TestWorth::*}

Errors on Reload:

Code (Skript):
  1. Return can only go in Functions (or something similar)
Console Errors: (if applicable)

Code (Skript):
  1. N/A



Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? Changing code around, to "soft" or "hard" return, etc.
 
You aren't returning anything on the function, putting just return wouldn't do anything, you have to put the return and what you want to return, and in that function you aren't returning anything, so, just remove it.

Also, this should be more efficient than what you're doing right now:
code_language.skript:
if {_t} parsed as int is between 1 and 10:
      set {_worth} to {_t} parsed as int
else if {_t} is "Jack", "Queen" or "King":
      set {_worth} to 10
else:
      set {_worth} to 11
add {_worth} to {Worth}
 
Last edited by a moderator:
Uh alright. I'm not too used to functions, other than basic stuff.
 
Status
Not open for further replies.