Solved [ 3/3 Fixed ] Variables not working with Skript

  • 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.
@Donut
So i added broadcast "test" after arg-1 is set:
then added broadcast "test2" after the perms

when i did /stats MyOfflineAlt "test" was shown in the chat

What do I do?
 
@Donut

Latest Code
When doing /stats MyOfflineAlt, it will say "test", In chat, but won't do anything after the perm stuff, so like broadcast "test2", and bring up the gui.


When doing /stats MeOnline, it will do the stuff, and will work.

code_language.skript:
on inventory click:
    if "%inventory name of player's current inventory%" is "            &0Player Stats":
        cancel event
        if clicked slot is 13:
            play sound "ITEM_BREAK" to player with volume 3 and pitch 1

on first join:
    set {Mysql._joined.%player%} to true
    set {Mysql._jtime.%player%} to now
    stop

command /stats [<offline player>]:
    usage: /stats
    trigger:
        arg-1 is not set:
            send "nop"
            stop
        set {_player} to "%player%"
        if {Mysql._joined.%arg-1%} is true:
            arg-1 is set:
                broadcast "test"
                if arg-1 has permission "tag.owner":
                    broadcast "test2"
                    open chest with 3 rows named "            &0Player Stats" to player
                    set slot 13 of player's current inventory to arg-1's skull named "&4&l&n%arg-1%" with lore "test"
                else if arg-1 has permission "tag.admin":
                    broadcast "test2"
                    open chest with 3 rows named "            &0Player Stats" to player
                    set slot 5 of player's current inventory to feather named "&c&l&n%arg-1%" with lore "test"

        else:
            open chest with 3 rows named "            &0&nPlayer Stats" to player
            set slot 5 of player's current inventory to feather named "&1%arg-1%" with lore "never joined!"
 
Same for me. You can just make fake perms instead, ex:
code_language.skript:
command /addperm <text> <offline player>:
    trigger:
        set {tag.%arg-1%.%arg-2%} to true

#then later on in the gui part replace "if arg-1 has permission "tag.owner" with
 
if  {tag.whatever.%arg 1%} is true:
    #the stuff after the permission check
 
Last edited by a moderator:
@Donut It works but it will say 0 for money.
(When the player is offline but it has been on the server at least once)

code_language.skript:
                if {mysql_.srt.%arg-1%} is true:
                    $ thread
                    set {_amount} to checkMoney(arg-1)
                    open chest with 3 rows named "            &0&nPlayer Stats" to player
                    set slot 13 of player's current inventory to arg-1's skull named "%arg-1%" with lore "%{_amount}%"

Also, Say My MC username is lolplayer, and i write /stats lolplaye, it will still display "lolplayer's stats not lolplaye, stats.

Here is the CheckMoney API if that helps...

code_language.skript:
function checkMoney(target: offline player) :: number:   
    set {_result::*} to objects in column "amount" from result of query "SELECT amount FROM money WHERE uuid = '%uuid of {_target}%'" and close
    set {_amount} to "%{_result::*}%" parsed as number
    "%{_result::*}%" is "<none>":
        update "INSERT INTO money (`uuid`, `amount`) VALUES ('%uuid of {_target}%', '0')"
        set {_amount} to 0
    return {_amount}
 
Last edited by a moderator:
Tbh I don't understand your check money function and it seems complicated for just checking someone's money ... can't you just use %player's money%?

As for the name problem, it should only do that for online players because the docs say, "You have two possibilities to use players as command arguments: <player> and <offline player>. The first requires that the player is online and also accepts only part of the name, while the latter doesn't require that the player is online, but the player's name has to be entered exactly.
 
Well since you said it only does this for offline people then when someone quits just run the function and set {variable.%player%} to {_amount} then show {variable.%player%} in the gui
[doublepost=1496083324,1496083238][/doublepost]Actually that might not work because they would be gone when the function runs
 
Idk why it wouldn't work with offline people.
The only workaround I can think of would to set a variable to the players balance every few seconds when they're online then display that variable in the GUI.
 
code_language.skript:
every 3 seconds:
    loop all players:
        set {money.%loop-player%} to checkMoney(loop-player)

then display {money.%arg-1%} in the gui
 
  • Like
Reactions: Offline
Status
Not open for further replies.