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

Frux

Member
Apr 11, 2020
10
0
0
24
I am having an issue where I cant find a way to put variables inside of functions
Here's my code I can't find anyone that can help me in the discord



Code:
options:
    maxtokens: 2 #Maximum amount of tokens you can win from the crate
    version: 1.0



command /token [<text>]:
  trigger:
    if arg-1 is not set:
      open chest with 3 rows named "&b&lTOKENS" to player
      format gui slot 4 of player with paper named "&b&lTOKENS" with lore "&7This is where you can spend tokens!||&7You can get tokens from voting,||&7mining, crates, and mob farming||&7You have &b%{TOKEN::BALANCE::%player%} ? 0% &7token(s)"
      format gui slot 10 of player with player head with custom nbt "{display:{Name:""Miner""},SkullOwner:{Id:""97be7c90-34ed-4aaf-a020-477da5942e88"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWYzMTljZTYzNTVlMmI2M2NmZTExY2RlYmVmODU3MjAyMTFmYzAxODQ0YTdlMDRlZjU5ODc5NTIyMTI0ZGUifX19""}]}}}" named "&3&lPICKAXE" with lore "&8■ &7Pickaxe shop"
      format gui slot 12 of player with player head with custom nbt "{display:{Name:""Warrior""},SkullOwner:{Id:""618c1fc3-7c2f-4c9b-bb22-b7a3512fea34"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhhYzI3MzhjNDFkZjA3NWY3MmViYTljYTY1YTdmZjczM2I1MDFlNTQ1ZWNkZmU3YzU4ODZlZWY4OGQ5YTUifX19""}]}}}" named "&c&lPVP" with lore "&8■ &7Pvp shop"
      format gui slot 14 of player with player head with custom nbt "{display:{Name:""KEYS""},SkullOwner:{Id:""d86659fc-8389-4e51-b0e1-23f4cf3e6b80"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjYyMDUxOWI3NDUzNmMxZjg1YjdjN2U1ZTExY2U1YzA1OWMyZmY3NTljYjhkZjI1NGZjN2Y5Y2U3ODFkMjkifX19""}]}}}" named "&e&lCRATES" with lore "&8■ &7Crate shop" to run:
        open chest with 1 row named "&e&lCRATES" to player
        format gui slot 8 of player with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::%player%} ? 0% &7key(s)" to run:
          roll(player)
      format gui slot 16 of player with player head with custom nbt "{display:{Name:""PERKS""},SkullOwner:{Id:""b9a10734-8874-494c-a63e-9bfccb9a760d"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzExODhhNzYxYzM2OTU3ZGE2MzdjYjkxNDQyMzY3NGFkZTI5N2FkMTc0ODMwMWJkMmU0ODdlZjZhYzc0NTI3ZiJ9fX0=""}]}}}" named "&d&lPERKS" with lore "&8■ &7Perk shop"



function roll(p: player):
    set {_tokenwinnings} to a random integer between 1 and {@maxtokens}
    format gui slot 8 of {_p} with emerald named "&3&l%{_tokenwinnings}% Tokens"
    wait 5 ticks
    format gui slot 8 of {_p} with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::{_p}} ? 0% &7key(s)" to run:
        roll(player)
 
I am having an issue where I cant find a way to put variables inside of functions
Here's my code I can't find anyone that can help me in the discord



Code:
options:
    maxtokens: 2 #Maximum amount of tokens you can win from the crate
    version: 1.0



command /token [<text>]:
  trigger:
    if arg-1 is not set:
      open chest with 3 rows named "&b&lTOKENS" to player
      format gui slot 4 of player with paper named "&b&lTOKENS" with lore "&7This is where you can spend tokens!||&7You can get tokens from voting,||&7mining, crates, and mob farming||&7You have &b%{TOKEN::BALANCE::%player%} ? 0% &7token(s)"
      format gui slot 10 of player with player head with custom nbt "{display:{Name:""Miner""},SkullOwner:{Id:""97be7c90-34ed-4aaf-a020-477da5942e88"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWYzMTljZTYzNTVlMmI2M2NmZTExY2RlYmVmODU3MjAyMTFmYzAxODQ0YTdlMDRlZjU5ODc5NTIyMTI0ZGUifX19""}]}}}" named "&3&lPICKAXE" with lore "&8■ &7Pickaxe shop"
      format gui slot 12 of player with player head with custom nbt "{display:{Name:""Warrior""},SkullOwner:{Id:""618c1fc3-7c2f-4c9b-bb22-b7a3512fea34"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhhYzI3MzhjNDFkZjA3NWY3MmViYTljYTY1YTdmZjczM2I1MDFlNTQ1ZWNkZmU3YzU4ODZlZWY4OGQ5YTUifX19""}]}}}" named "&c&lPVP" with lore "&8■ &7Pvp shop"
      format gui slot 14 of player with player head with custom nbt "{display:{Name:""KEYS""},SkullOwner:{Id:""d86659fc-8389-4e51-b0e1-23f4cf3e6b80"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjYyMDUxOWI3NDUzNmMxZjg1YjdjN2U1ZTExY2U1YzA1OWMyZmY3NTljYjhkZjI1NGZjN2Y5Y2U3ODFkMjkifX19""}]}}}" named "&e&lCRATES" with lore "&8■ &7Crate shop" to run:
        open chest with 1 row named "&e&lCRATES" to player
        format gui slot 8 of player with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::%player%} ? 0% &7key(s)" to run:
          roll(player)
      format gui slot 16 of player with player head with custom nbt "{display:{Name:""PERKS""},SkullOwner:{Id:""b9a10734-8874-494c-a63e-9bfccb9a760d"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzExODhhNzYxYzM2OTU3ZGE2MzdjYjkxNDQyMzY3NGFkZTI5N2FkMTc0ODMwMWJkMmU0ODdlZjZhYzc0NTI3ZiJ9fX0=""}]}}}" named "&d&lPERKS" with lore "&8■ &7Perk shop"



function roll(p: player):
    set {_tokenwinnings} to a random integer between 1 and {@maxtokens}
    format gui slot 8 of {_p} with emerald named "&3&l%{_tokenwinnings}% Tokens"
    wait 5 ticks
    format gui slot 8 of {_p} with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::{_p}} ? 0% &7key(s)" to run:
        roll(player)
Wait... If you call the function within the same function, wouldn't a loop occur?

code_language.skript:
function roll(p: player):
    set {_tokenwinnings} to a random integer between 1 and {@maxtokens}
    format gui slot 8 of {_p} with emerald named "&3&l%{_tokenwinnings}% Tokens"
    wait 5 ticks
    format gui slot 8 of {_p} with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::{_p}} ? 0% &7key(s)" to run:
        roll(player)
 
Wait... If you call the function within the same function, wouldn't a loop occur?

code_language.skript:
function roll(p: player):
    set {_tokenwinnings} to a random integer between 1 and {@maxtokens}
    format gui slot 8 of {_p} with emerald named "&3&l%{_tokenwinnings}% Tokens"
    wait 5 ticks
    format gui slot 8 of {_p} with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::{_p}} ? 0% &7key(s)" to run:
        roll(player)
no because it happens when you click on it
 
no because it happens when you click on it
Oh, right. I looked it wrong.
[doublepost=1587172439,1587172078][/doublepost]
I am having an issue where I cant find a way to put variables inside of functions
Here's my code I can't find anyone that can help me in the discord



Code:
options:
    maxtokens: 2 #Maximum amount of tokens you can win from the crate
    version: 1.0



command /token [<text>]:
  trigger:
    if arg-1 is not set:
      open chest with 3 rows named "&b&lTOKENS" to player
      format gui slot 4 of player with paper named "&b&lTOKENS" with lore "&7This is where you can spend tokens!||&7You can get tokens from voting,||&7mining, crates, and mob farming||&7You have &b%{TOKEN::BALANCE::%player%} ? 0% &7token(s)"
      format gui slot 10 of player with player head with custom nbt "{display:{Name:""Miner""},SkullOwner:{Id:""97be7c90-34ed-4aaf-a020-477da5942e88"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWYzMTljZTYzNTVlMmI2M2NmZTExY2RlYmVmODU3MjAyMTFmYzAxODQ0YTdlMDRlZjU5ODc5NTIyMTI0ZGUifX19""}]}}}" named "&3&lPICKAXE" with lore "&8■ &7Pickaxe shop"
      format gui slot 12 of player with player head with custom nbt "{display:{Name:""Warrior""},SkullOwner:{Id:""618c1fc3-7c2f-4c9b-bb22-b7a3512fea34"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhhYzI3MzhjNDFkZjA3NWY3MmViYTljYTY1YTdmZjczM2I1MDFlNTQ1ZWNkZmU3YzU4ODZlZWY4OGQ5YTUifX19""}]}}}" named "&c&lPVP" with lore "&8■ &7Pvp shop"
      format gui slot 14 of player with player head with custom nbt "{display:{Name:""KEYS""},SkullOwner:{Id:""d86659fc-8389-4e51-b0e1-23f4cf3e6b80"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjYyMDUxOWI3NDUzNmMxZjg1YjdjN2U1ZTExY2U1YzA1OWMyZmY3NTljYjhkZjI1NGZjN2Y5Y2U3ODFkMjkifX19""}]}}}" named "&e&lCRATES" with lore "&8■ &7Crate shop" to run:
        open chest with 1 row named "&e&lCRATES" to player
        format gui slot 8 of player with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::%player%} ? 0% &7key(s)" to run:
          roll(player)
      format gui slot 16 of player with player head with custom nbt "{display:{Name:""PERKS""},SkullOwner:{Id:""b9a10734-8874-494c-a63e-9bfccb9a760d"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzExODhhNzYxYzM2OTU3ZGE2MzdjYjkxNDQyMzY3NGFkZTI5N2FkMTc0ODMwMWJkMmU0ODdlZjZhYzc0NTI3ZiJ9fX0=""}]}}}" named "&d&lPERKS" with lore "&8■ &7Perk shop"



function roll(p: player):
    set {_tokenwinnings} to a random integer between 1 and {@maxtokens}
    format gui slot 8 of {_p} with emerald named "&3&l%{_tokenwinnings}% Tokens"
    wait 5 ticks
    format gui slot 8 of {_p} with ender chest named "&e&lTOKEN CRATE" with lore "&7You have &6%{KEY::TOKEN::{_p}} ? 0% &7key(s)" to run:
        roll(player)
What is the error? What you want to do?
 
  • Like
Reactions: Frux
Oh, right. I looked it wrong.
[doublepost=1587172439,1587172078][/doublepost]
What is the error? What you want to do?
For some reason I cant use variables inside of my function
5X0wIKW.png
 
Status
Not open for further replies.