#2 ERRORS: Variable issues
1 messages · Page 1 of 1 (latest)
of the whole code?
ye
code
^ right click, then click copy text
edit the original
instead of sending a new one
#SCOREBOARD
options:
server: &b&lSky&f&lLegends
every 1 second:
loop all players:
set {_online} to number of all players
wipe loop-players's sidebar
set name of sidebar of loop-player to "{@server}"
set score "" in sidebar of loop-player to 8
set score "" in sidebar of loop-player to 7
set score "&7&m-------------------" in sidebar of loop-player to 6
set score "&9Player: &f%loop-player%" in sidebar of loop-player to 5
set score "&3XP: &b%{xp::%player%}% &7/ &9%{level::%player%}%" in sidebar of loop-player to 4
set score "&bPlayers Online: &f%{_online}%" in sidebar of loop-player to 3
set score "&7&m--------------------" in sidebar of loop-player to 2
set score "&7SkyLegendsMc.minehut.gg" in sidebar of loop-player to 1
#XPSYSTEM
variables:
{xp::%player%} = 0
{level::%player%} = 0
on player pickup:
if event-item is dirt:
add 1 to {xp::%player%}
send action bar "&3[&b✧XP&3] &71+" to player
on death of player:
if attacker is a player:
add 1 to {xp::%attacker%}
send action bar "&3[&b✧XP&3] &71+" to attacker
#LEVELS
on load:
every 0.5 seconds:
if {xp::%player%} => 500:
add 1 to {level::%player%}
#COMMANDS
command /xp:
trigger:
send "&3XP Total: &7%{xp::%player%}%" to player
command /xpclear:
trigger:
clear {xp::%player%}
Also, do you have the uuid option enabled in the config?
yes i do
i was trying player's uuid earlier and it was not making individual varibles for players in game
I would also instead of doing a periodical event to change a players level, to call a function whenever you give someone xp
can u give me an example of a function?
function Name(id: type):
Detailed
function CheckXP(p: player):
if {_p} is online:
add 1 to {xp::%player%}
CheckXP(player)
so Name can be whatever you want it to be
id can be whatever you want it to be, its like basically having a local variable set for you
type has to equal the type of data youre sending
I would also strongly advise against looping all players every second
use on join: while player is online: wait 10 seconds #update scoreboard
so put this at the very start of the code
or should i replace it with the every 0.5 seconds
so the on join code u just sent should be the very first event going
but for that, yeah, its also inefficent to check. just call a function or something whenever you give the player xp (like on break: in this case)
counter argument
on join:
while player is online:
wait 10 seconds
#update scoreboard function
Reason I say do a function, is because if you make any changes to the scoreboard. and reload it wont update for players, and theyll have to relog
^
right now, you have every 1 second: loop all players: #update scorebaord you should change it to on join: while player is online: wait 10 seconds #update scoreboard
will that mess with the scoreboard updating at all?
for example the scorboard will have a XP: 0 / 1 tab in it
It'll just be every 10 seconds instead of 1. But thats shouldnt really matter tbh
ok
can i set the wait 10 seconds to 2 seconds instead or does that mess with my code a little bit
no, its whatever interval you want
I mean, you can, but the more players you have, the laggier it will become
i see