Convert timespan to number to be added to balance

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

martinn112

Member
Jan 21, 2018
23
0
1
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:
on join:
    if player has permission "Skript.Vagt":
        set {Vagtløn.%uuid of player%} to now
on quit:
    if player has permission "Skript.Vagt":
        delete {Vagtløn.%uuid of player%}
command /løntest:
    trigger:
        if player has permission "Skript.Vagt":
            set {_waited} to difference between {Vagtløn.%uuid of player%} and now
            add {_waited} parsed as a number to player's balance
            set {Vagtløn.%uuid of player%} to now
            if {Vagtløn.Total.%uuid of player%} is not set:
                set {Vagtløn.Total.%uuid of player%} to 0
            add {_waited} parsed as a number to {Vagtløn.Total.%uuid of player%}
            send "%{_waited} parsed as a number%" to player
But the variable {_waited} is just none
How can i do this ?
 
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:
on join:
    if player has permission "Skript.Vagt":
        while true:
            wait 10 minutes
            send "&5Super fed prison&d>> &a DU FIK LØN!!!!!" to player
 
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
 
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:
({_Time}.getTicks()/20)
 
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
 
Status
Not open for further replies.