#Variable in title

1 messages · Page 1 of 1 (latest)

unkempt topaz
#

Ok, i know this is gonna look really stupid but im bad a skript. Anyone have an idea as to why the title is not sending the variable in it:

    send title "&a+1 Level" to player
    send subtitle "&oYou are now level {skriptexp}" to player
    add 1 to {skriptexp::%player%}
    send {skriptexp::%player%}```
light harbor
#

so %{skriptexp}%

#

but it would actually be %{skriptexp::%player%}%

unkempt topaz
#

ok

light harbor
#

since that's the variable you want

unkempt topaz
#

thx

#

@light harbor

#

i have a question

#

how would i add more items to this and make it actually remove the items:

    trigger:
        set {_s} to amount of wheat and stone in player's inventory
        add {_s}*10 to {money::%player's uuid%} and {_total}
        send "You have sold all your stuff for $%{_total}%"
light harbor
#

you should find a better sell system

unkempt topaz
#

im trying to code my own economy

#

so i can put all the stuff on a scoreboard

#

bc skript variables and others dont mix

light harbor
#
function sellable() :: itemtypes:
    return stone, diamond
        
function worth(item: itemtype) :: number:
    return 1 if {_item} is stone
    return 5 if {_item} is diamond

function sell(inventory: inventory, player: player, multi: number = 1, sendMessage: boolean = true):
    loop sellable():
        add (amount of loop-value in {_inventory} * (worth(loop-value) * {_multi})) to {_$}
        remove all loop-value from {_inventory}
    if {_$} is 0:
        send "&cThere are no items to sell." to {_player} if {_sendMessage} is true
    else:
        send "&aYou sold all items for $%{_$}%&a." to {_player} if {_sendMessage} is true
        add {_$} to {money::%{_player}'s uuid%}

command /sell:
  trigger:
    sell(player's inventory, player)

here's my old sell system from like a year ago

#

to add items just look at the code up top

unkempt topaz
#

ok

light harbor
#
function sellable() :: itemtypes:
    return stone, diamond
        
function worth(item: itemtype) :: number:
    return 1 if {_item} is stone
    return 5 if {_item} is diamond

change to

function sellable() :: itemtypes:
    return stone, diamond, emerald
        
function worth(item: itemtype) :: number:
    return 1 if {_item} is stone
    return 5 if {_item} is diamond
    return 7 if {_item} is emerald
#

that would add emeralds for $7

unkempt topaz
#

so return 10

#

would = $10

#

?

light harbor
#

right

unkempt topaz
#

any the varible

#

where it says money

#

like {money}

#

would i need to change that

light harbor
#

nah

unkempt topaz
#

to the one im using?

light harbor
#

it's already the one you're using

unkempt topaz
#

ok

#

thx

#

umm

#

@light harbor

light harbor
#

that yellow message is fine, you musta pasted the code weirdly

#

the functions are supposed to be their own thing

#

it's not in the command or anything

unkempt topaz
light harbor
#

get rid of your old sell command and just put my stuff

#

it's not supposed to be in an existing command

unkempt topaz
#

ok

#

i got rid off the other sell command

#

is it supposed to be in a file with .sk?

light harbor
#

...yes?

unkempt topaz
#
    return stone, diamond, emerald
    
function worth(item: itemtype) :: number:
    return 1 if {_item} is stone
    return 5 if {_item} is diamond
    return 7 if {_item} is emerald

function sell(inventory: inventory, player: player, multi: number = 1, sendMessage: boolean = true):
    loop sellable():
        add (amount of loop-value in {_inventory} * (worth(loop-value) * {_multi})) to {_$}
        remove all loop-value from {_inventory}
    if {_$} is 0:
        send "&cThere are no items to sell." to {_player} if {_sendMessage} is true
    else:
        send "&aYou sold all items for $%{_$}%&a." to {_player} if {_sendMessage} is true
        add {_$} to {money::%{_player}'s uuid%}

command /sell:
    trigger:
    sell(player's inventory, player)
light harbor
#

it's because sell isn't indented

#

put 4 spaces / a tab before sell(player's inventory, player)

#

whatever you use

unkempt topaz
#

i did

light harbor
#

4 more I mean

unkempt topaz
#

oh mb

light harbor
#

in skript after every : you have to indent another level in the next line

unkempt topaz
#

the :

#

yea

#

and i can change the bit where it says send

#

to send title

#

right?

light harbor
#

yeah

#

you might have to change the line up a bit though

unkempt topaz
#

i did it

unkempt topaz
#

set score "&a&lBalance: &f{money::%player%}" in sidebar of loop-player to 5

#

@light harbor

quiet owl
quiet owl
#

it does work

unkempt topaz
#

on both sides

#

?

quiet owl
#

read the error

unkempt topaz
quiet owl
#

it says there is no player in a periodical event

unkempt topaz
#

see

#

yea

#

what does that mean

quiet owl
#

it means you loop something for x minutes/seconds/hours etc. To be able to add players there too you need to loop the players. To loop players you would need to add a line that goes like this loop all players:. But that is not efficient neither good for your server. I'd recommend using skbee and a while loop instead for a scoreboard.

unkempt topaz
#

i already have

quiet owl
#

okay

unkempt topaz
#

so what i do?

quiet owl
#

do you have the addon skrayfall, i believe that will fix it. There is one thing about rayfall scoreboards that no one likes. They are flickery, which means every time the loop goes again the scoreboard goes away and comes back.

unkempt topaz
#

yea i do

#

do i need to uninstall it?

quiet owl
#

no

unkempt topaz
#

then what?

quiet owl
#

use skbee scoreboards instead

unkempt topaz
#

do you have a link?

#

wait

#

nvm

#

i got it

#

wait

#

but this one

#

only refreshes on join

#

do i change it to every 5 seconds?

quiet owl
#

No, when a player joins the scoreboard comes the wait on the bottom is the time until it refreshes. So if the wait is 1 minute then it would refresh every 1 minute

on join:
  while player is online:
   set title of player's scoreboard to "&eMy Server"
   set line 4 of player's scoreboard to "&a " #set a random color code and a space to set the line to a blank space. PS: You need to set different color codes or add more spaces for each blank line, there can't be 2 lines with the same exact name.
   set line 3 of player's scoreboard to "&fPlayer: "
   set line 2 of player's scoreboard to "&fKills: "
   set line 1 of player's scoreboard to "&7Server Ip:"
   wait 1 second```
unkempt topaz
#

thx

quiet owl
#

you're welcome!

unkempt topaz
#

and the variable should be put in how you said?

#

with %% around it?

quiet owl
#

to show the content of a variable you need to wrap it around with %% so %{var}%

unkempt topaz
#

k

#

btw

#

1 last question

#

for the variables to update

#

on the scoreboard

#

will they need to rejoin?

quiet owl
#

there is no need to rejoin to see the updated scoreboard, thats why there is that wait. As i said, if the wait is 1 minute then it would refresh every 1 minute.

#

also, the wait is the most crucial part of that scoreboard skript. If you wouldn't have a wait the server is just waiting to crash

unkempt topaz
#

uhh

#

i know this will sound stupid

#

but why is this not working:

    set {_online} to number of all players
    while player is online:
        set title of player's scoreboard to "&a&lSmooth&6&lFarms"
        set line 4 of player's scoreboard to "&7&m>>--------------------<< " 
        set line 3 of player's scoreboard to "&a "
        set line 2 of player's scoreboard to "&b&lOnline: &f {_online} "
        set line 1 of player's scoreboard to "&7Server Ip:"
        wait 1 second```
#

im talking about the {_online}

#

part

graceful eagle
unkempt topaz
#

thx

#

btw for the variable

#

will it just update automatically?

#

without having to rejoin?

graceful eagle
#

No

unkempt topaz
#

how can i make it auto update?

graceful eagle
#

you could do something like this:

  while player is online:
    # update scoreboard
    wait 1 second
unkempt topaz
#

so above

#

do i just add wait 1 second and thats it?

#

and remove the wait 1 second at the end?

graceful eagle
unkempt topaz
#

k

#

anywhere?

#

or just anywhere before where it comes up?

graceful eagle
unkempt topaz
#

this work?

graceful eagle
#

You could try it :p

unkempt topaz
#

could you

#

join for 2 seconds

#

so i could test

#

?

graceful eagle
#

test what?

unkempt topaz
#

if it updates

#

auto

graceful eagle
#

ip