Solved Bug with Offline Player Argument

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

Wynnevir

Well-Known Member
Jul 9, 2017
1,015
62
48
30
Elsewhere
Skript 2.2 dev 29
Author Bensku
MC 1.12.1

I've suddenly started running into instances where offline player will invalidate a command as a command.
To be more clear here, this command will work:
code_language.skript:
command /comtest [<offline player>]:
    trigger:
        broadcast "%arg-1%"
But this command returns the error "unknown command. Type /help for help"
code_language.skript:
command /comtest [<offline player>]:
    trigger:
        if player-argument is offline:
            broadcast "offline"
        else:
            broadcast "online"
8cbf66e02a.png

The above command will be recognized as a command with just [<player>]

The only parts changing are within the triggers, not the command itself. Any idea why this happens or how to fix it?

No addons used for either test command, but these are the ones I currently have if relevant.
-Skellet
-Tuske
-Skquery
-Sharpsk
-Skrayfall
 
I'm pretty sure there's a bug with <offline player> having a space so try this


code_language.skript:
command /comtest [<offlineplayer>]:
 
I'm pretty sure there's a bug with <offline player> having a space so try this


code_language.skript:
command /comtest [<offlineplayer>]:
No luck, I'm afraid. still "isn't a command". [<offline-player>] also doesn't work. It's especially odd since all of my commands before today used [<offline player>] and worked just fine.
 
Try just using [<player>] then parse the argument as offline player.
While that does work to make it recognized as a command, it will return the player as offline no matter what. My ultimate goal with this is to stop a player from executing a command with an offline player, but allow it for online players. Currently in my pvp script they still can initiate a bet with a player who is not online (using just <player>). It just changes that offline player's name to <none>.
 
code_language.skript:
on join:
    add player to {players::*}
    
    
on quit:
    remove player from {players::*}
    
    
on kick:
    remove player from {players::*}
    
    
on skript start:
    delete {players::*}
    
    
command /bet [<player>]:
    trigger:
        loop {players::*}:
            if loop-value = player-arg:
                send "Bet Sent."
            else:
                send "Player is offline."
 
I found a work around at least for my purposes. It doesn't fix it, but it does essentially do the same thing.
code_language.skript:
        set {_plList::*} to all players
        set {_pl} to "%arg 1%" parsed as text
        if {_plList::*} does not contain "% {_pl}%":
            stop
**Edit: Adding a space before the {_pl} in "% {_pl}%": ensures it won't accept partial names if users have similar names, and also avoids having to loop the list
 
Last edited by a moderator:
code_language.skript:
on join:
    add player to {players::*}
   
   
on quit:
    remove player from {players::*}
   
   
on kick:
    remove player from {players::*}
   
   
on skript start:
    delete {players::*}
   
   
command /bet [<player>]:
    trigger:
        loop {players::*}:
            if loop-value = player-arg:
                send "Bet Sent."
            else:
                send "Player is offline."

That's an inefficient way.
 
code_language.skript:
on join:
    add player to {players::*}
   
   
on quit:
    remove player from {players::*}
   
   
on kick:
    remove player from {players::*}
   
   
on skript start:
    delete {players::*}
   
   
command /bet [<player>]:
    trigger:
        loop {players::*}:
            if loop-value = player-arg:
                send "Bet Sent."
            else:
                send "Player is offline."
We came to the same conclusion at the same time here XD haha
 
code_language.skript:
on join:
    while player is online:
        wait 1 second
        if player is online:
            set {online.%uuid of player%} to true
        else:
            set {online.%uuid of player%} to false
  
  
command /bet [<player>]:
    trigger:
          if {online.%uuid of arg-1%} = true:
              send "Bet Sent."
          else:
              send "Player is offline."
 
I found a work around at least for my purposes. It doesn't fix it, but it does essentially do the same thing.
code_language.skript:
        set {_plList::*} to all players
        set {_pl} to "%arg 1%" parsed as text
        if {_plList::*} does not contain "%{_pl}%":
            stop
This could easily get screwed up because say you're checking if someone named 'donut' is online and they're not online but say someone named 'glaze_donut' is online it will still say 'donut' is online since the player list does indeed contain 'donut'

If that makes sense
 
This could easily get screwed up because say you're checking if someone named 'donut' is online and they're not online but say someone named 'glaze_donut' is online it will still say 'donut' is online since the player list does indeed contain 'donut'

If that makes sense
it does, hmm. I would be able to fix that by looping the list and just making sure the loop value is equal to the argument then correct?
 
I found a work around at least for my purposes. It doesn't fix it, but it does essentially do the same thing.
code_language.skript:
        set {_plList::*} to all players
        set {_pl} to "%arg 1%" parsed as text
        if {_plList::*} does not contain "% {_pl}%":
            stop
**Edit: Adding a space before the {_pl} in "% {_pl}%": ensures it won't accept partial names if users have similar names, and also avoids having to loop the list
If this bug persisted without addons, you should report it on Bensku's issue tracker. By the way, parsing as text is useless since in order to parse something it has to be a text anyway. The proper way to do this would be
code_language.skript:
if arg-1 parsed as a player is not set:
where arg-1 is of the text type. This works because in order to parse as a player the given player has to be online, so parsing will fail and it will not be set if they are offline
 
  • Like
Reactions: Wynnevir
Status
Not open for further replies.