Loop on offline players

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

kamilleon

Member
Nov 18, 2017
48
0
6
24
I want to make that this code works on offline players too: (I want to make a somewhat custom cookie clicked kind of game)

code_language.skript:
every 1 seconds:
  loop all players:
    if {f2.%loop-player%} is true:
      add 1 to {s.%loop-player%}
 
code_language.skript:
loop all offline players
However I would not recommend doing this every second. It would be better set a variable to ‘now’ when they leave then when they rejoin check the difference between ‘now’ and the variable. Then you can give them a certain amount of cookies based on this elapsed time.
 
code_language.skript:
loop all offline players
However I would not recommend doing this every second. It would be better set a variable to ‘now’ when they leave then when they rejoin check the difference between ‘now’ and the variable. Then you can give them a certain amount of cookies based on this elapsed time.
Im just started on skript, so i don't really know, how to do that, you know.
I know that much, that a good way of starting a "new language" by creating a minigame or playing with it.
 
Look at the example cooldown.sk that is generated. It’s the same concept. If you deleted it then you can google it and it’ll come up
 
Look at the example cooldown.sk that is generated. It’s the same concept. If you deleted it then you can google it and it’ll come up
I have it, but how do i make an offline player time checking contraption from a command cooldown?
[doublepost=1513700241,1513700068][/doublepost]Like do i need to get how many seconds have been bypassed, and give that number of cookies to the player? And if yes, how?
 
look at how they find the elapsed time but instead of checking if the elapsed time is greater than the cooldown length, you can convert it to seconds and give them cookies
 
code_language.skript:
on quit:
  set {_offlinetime} to now

 
on join:
  check the difference between {_offlinetime} and now
  add {_offlinetime} to {s.%player%}
Maybe this would work? (Checking)
 
No. Don’t use local variables (no underscore). Have a variable for each player I.e {time::%player%}. And line 6 isn’t right, look at the cooldown.sk, it’s the same concept but different application
 
No. Don’t use local variables (no underscore). Have a variable for each player I.e {time::%player%}. And line 6 isn’t right, look at the cooldown.sk, it’s the same concept but different application
I don't get it.. Sorry..
 
I don't get it.. Sorry..
Local variables are "{_test}", variables with an underscore at the start.

So, use a variable like {time.%player%.logout} on player quit, and call it back on player join with "set {_time.hasbeen.offline}" to difference between {time.%player%.logout} and now, then add {_time.hasbeen.offline} to {total.time.offline.%player%}. I don't know if you meant that.. :\

This should be the code

code_language.skript:
on quit:
  set {time.%player%.logout} to now
  stop
on join:
  set {_time.hasbeen.offline} to difference between {time.%player%.logout} and now
  add {_time.hasbeen.offline} to {total.time.offline.%player%}
  stop

#!Optional:
command /check [<offline player>]:
  trigger:
    send "%arg 1% has been %{total.time.offline.%arg 1%}% minutes/offline." to executor
    stop
 
Status
Not open for further replies.