1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Convert timespan to number to be added to balance

Discussion in 'Skript' started by martinn112, May 1, 2020.

Thread Status:
Not open for further replies.
  1. martinn112

    martinn112 Member

    Joined:
    Jan 21, 2018
    Messages:
    23
    Likes Received:
    0
    Hello, i am trying to convert a time span into a number that can be added to a player's balance, sort of like a wage system.

    Code (Text):
    1. on join:
    2.     if player has permission "Skript.Vagt":
    3.         set {Vagtløn.%uuid of player%} to now
    4. on quit:
    5.     if player has permission "Skript.Vagt":
    6.         delete {Vagtløn.%uuid of player%}
    7. command /løntest:
    8.     trigger:
    9.         if player has permission "Skript.Vagt":
    10.             set {_waited} to difference between {Vagtløn.%uuid of player%} and now
    11.             add {_waited} parsed as a number to player's balance
    12.             set {Vagtløn.%uuid of player%} to now
    13.             if {Vagtløn.Total.%uuid of player%} is not set:
    14.                 set {Vagtløn.Total.%uuid of player%} to 0
    15.             add {_waited} parsed as a number to {Vagtløn.Total.%uuid of player%}
    16.             send "%{_waited} parsed as a number%" to player
    But the variable {_waited} is just none
    How can i do this ?
     
  2. Ierdyr

    Ierdyr Member

    Joined:
    Mar 18, 2019
    Messages:
    14
    Likes Received:
    0
    Hej jeg fandt på en virkelig dårlig måde at gøre noget i den stil du ville have men den virker da... lidt
    Dette er ikke et svar på dit spørgsmål men bare mig som prøver at løse løn-problemet på en anden måde.
    Code (Text):
    1. on join:
    2.     if player has permission "Skript.Vagt":
    3.         while true:
    4.             wait 10 minutes
    5.             send "&5Super fed prison&d>> &a DU FIK LØN!!!!!" to player
     
  3. martinn112

    martinn112 Member

    Joined:
    Jan 21, 2018
    Messages:
    23
    Likes Received:
    0
    Kan skam også få det til at virke med en every real second, men vil helst undgå det da kræver ret mange resourcer Men kan kigge lidt ind på det du har skrevet. Men mine tanker var at når man leavede ville man automatisk få sin løn udbetalt til total hvor man så kan claim den hvis der er nok til 1 time
     
  4. Killerz1243

    Killerz1243 Active Member

    Joined:
    Oct 31, 2019
    Messages:
    78
    Likes Received:
    7
    you could convert a timespan to an integer using skript-mirror

    the code bolow will give u the number of seconds in the time
    Code (Text):
    1. ({_Time}.getTicks()/20)
     
  5. martinn112

    martinn112 Member

    Joined:
    Jan 21, 2018
    Messages:
    23
    Likes Received:
    0
    How would i put this into my current code ? I have the idea of at join it will set a timestamp and whenever the player leaves or types a command, they will put the amount of time into a variable. Then there will be a second command, that can be executed whenever the variable is over 1 hour and then it will remove 1 hour and add money to the player executing the command
     
Thread Status:
Not open for further replies.

Share This Page

Loading...