Skript - "replace all ...." not working

Discussion in 'Skript' started by Miss_Wafffidooe, Jun 17, 2020.

  1. Why doesn't the (replace all "seconds" with "s" in ….) work? I tried to remove the space in " seconds" as well... doesn't work:


    Code (Text):
                        set {_waited::%{_p}%} to difference between {punchdelay::%{_p}%} and now
                        replace all " seconds" with "s" in {_waited::%{_p}%}
                        replace all " second" with "s" in {_waited::%{_p}%}
                        if {_waited::%{_p}%} is less than 59 seconds:
                            send "&c%{_p}% kan først blive slÃ¥et op i luften igen om %difference between 59 seconds and {_waited::%{_p}%}%" to player
                            stop
                        set {punchdelay::%{_p}%} to now
                        send "%colored player's prefix%%player% &7slog %colored {_p}'s suffix%%{_p}% &7op i luften!" to all players  
                        push {_p} upwards at speed 2  
                        create a fake explosion at {_p}  
     
     
    #1 Miss_Wafffidooe, Jun 17, 2020
    Last edited: Jun 18, 2020
  2. I just edited my message
     
  3. can you please use more informative titles? because I see you using the same "Skript not working" really often

    the issue here is that replace works only with strings, but you're trying to replace it in a timespan
     
  4. I will - sorry

    Is there another condition I can use for timespans then?
     
  5. convert timespan to string then use replace
     
  6. How do I do that in this case??
     
  7. set {_timestring} to "%{var}%"
     
  8. So, I tried this - still doesn't work:

    Code (Text):
                        set {_waited::%{_p}%} to difference between {punchdelay::%{_p}%} and now
                        set {_timestring} to "%{_waited::%{_p}%}%"
                        replace all " seconds" with "s" in {_timestring}
                        replace all " second" with "s" in {_timestring}
                        if {_waited::%{_p}%} is less than 59 seconds:
                            send "&c%{_p}% kan først blive slÃ¥et op i luften igen om %difference between 59 seconds and {_waited::%{_p}%}%" to player
                            stop
                        set {punchdelay::%{_p}%} to now
                        send "%colored player's prefix%%player% &7slog %colored {_p}'s suffix%%{_p}% &7op i luften!" to all players  
                        push {_p} upwards at speed 2  
                        create a fake explosion at {_p}  
     
     
  9. well you never used the variable, so what doesn't work..? xD
     
  10. Whenever I used the variable, it would return with "<none>"
     
  11. that means {punchdelay::%{_p}%} isn't set
     
  12. If I set {punchdelay::%{_p}%} to anything before {_timestring}, the delay/cooldown is not working at all
     
  13. sounds like you've used my advice wrongly, please show the code again, with the none problem you're having
     
  14. So, this is what I first did - but then the delay/cooldown did not work at all:

    Code (Text):
                        set {_waited::%{_p}%} to difference between {punchdelay::%{_p}%} and now
                        set {_timestring} to "%{_waited::%{_p}%}%"
                        replace all " seconds" with "s" in {_timestring}
                        replace all " second" with "s" in {_timestring}
                        if {_timestring} is less than 59 seconds:
                            send "&c%{_p}% kan først blive slÃ¥et op i luften igen om %difference between 59 seconds and {_timestring}%" to player
                            stop
                        set {punchdelay::%{_p}%} to now
                        send "%colored player's prefix%%player% &7slog %colored {_p}'s suffix%%{_p}% &7op i luften!" to all players
                        push {_p} upwards at speed 2
                        create a fake explosion at {_p}
     

    Then I did this, but it returned with "<none>" in "difference between 59 seconds and {_timestring}" :

    Code (Text):
                        set {_waited::%{_p}%} to difference between {punchdelay::%{_p}%} and now
                        set {_timestring} to "%{_waited::%{_p}%}%"
                        replace all " seconds" with "s" in {_timestring}
                        replace all " second" with "s" in {_timestring}
                        if {_waited::%{_p}%} is less than 59 seconds:
                            send "&c%{_p}% kan først blive slÃ¥et op i luften igen om %difference between 59 seconds and {_timestring}%" to player
                            stop
                        set {punchdelay::%{_p}%} to now
                        send "%colored player's prefix%%player% &7slog %colored {_p}'s suffix%%{_p}% &7op i luften!" to all players
                        push {_p} upwards at speed 2
                        create a fake explosion at {_p}
     


    THEN
    I tried setting the {punch....} to something
    (wasn't sure what you meant, so tried setting it to true, false, player and even 59). And the delay didn't work here either:

    Code (Text):
                        set {_waited::%{_p}%} to difference between {punchdelay::%{_p}%} and now
                        set {punchdelay::%{_p}%} to ???
                        set {_timestring} to "%{_waited::%{_p}%}%"
                        replace all " seconds" with "s" in {_timestring}
                        replace all " second" with "s" in {_timestring}
                        if {_waited::%{_p}%} is less than 59 seconds:
                            send "&c%{_p}% kan først blive slÃ¥et op i luften igen om %difference between 59 seconds and {_timestring}%" to player
                            stop
                        set {punchdelay::%{_p}%} to now
                        send "%colored player's prefix%%player% &7slog %colored {_p}'s suffix%%{_p}% &7op i luften!" to all players
                        push {_p} upwards at speed 2
                        create a fake explosion at {_p}
     



    So, I think the second code part is the one to use, but it's just how to to fix the "<none>" part
     
    #14 Miss_Wafffidooe, Jun 20, 2020
    Last edited: Jun 20, 2020
  15. why you're using time string in timespan calculations? it's a string, it can't be used for that, just use it directly don't do timespan stuff with it
     
  16. But then how do I make a delay? (Sorry)
     
  17. use timespan for delay
    string for display

    OR you can use WolvSK addon cooldowns, they're pretty great (but you'd need timespan to string conversion still)
     
  18. I have WolvSK 1.6.2 on my server, but it doesn't understand the condition:
    cooldown "punchdelay" (of player) is finish:


    And how would I convert a cooldown not made with a variable to a timestring then? Like in code?
     
  19. you'd do it same as you did it with the variable, just don't forget to use double quotes
    remove () and it'll work
     
  20. When reloading, it still doesn't understand the condition:
    cooldown "punchdelay" is finish:

    With or without double quotes didn't change anything
    No errors in log...