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.

Solved How do I check if a variable has reached a certain number

Discussion in 'Skript' started by Florin Krasnic, Aug 12, 2017.

Thread Status:
Not open for further replies.
  1. Florin Krasnic

    Joined:
    Jun 19, 2017
    Messages:
    12
    Likes Received:
    1
    I am Skripting a RP-System (similar to gta experience levels)
    I only got one problem, how do I create a variable that only contains a number which I can check (e.g. if a variable has reached "20" it should trigger something or when it has reached the count of "40")?

    If someone is able to improve this "skript" feel free to edit it!


    Code (Skript):
    1. on first join:
    2.     set {rplevelcount::%player%::*} to 20
    3.     add 1 to {rpcount::%player%::*}
    4.     set {rplevel::%player%::*} to 1
    5.    
    6. on join:
    7.     add 5 to {rpcount::%player%::*}
    8.     message "&7[&9RP&7] &7You got &9 5 RP-Points &7 for joining the server!"
    9.     message "           &7Your current level: &9{rplevel::%player%::*} {rpcount::%player%::*}/{rplevelcount::%player%::*}"
    10.  
    11.  
    12. if {rpcount::%player%::*} equals 20:
    13.     set {rplevelcount::%player%::*} to 100
    14.     set {rplevel::%player%::*} to 2


     
  2. Best Answer:
    Post #6 by ShaneBee, Aug 13, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Code (Skript):
    1. on join:
    2.     add 5 to {rpcount::%player%::*}
    3.     message "&7[&9RP&7] &7You got &9 5 RP-Points &7 for joining the server!"
    4.     message "           &7Your current level: &9{rplevel::%player%::*} {rpcount::%player%::*}/{rplevelcount::%player%::*}"
    5.     if {rpcount::%player%::*} equals 20:
    6.         set {rplevelcount::%player%::*} to 100
    7.         set {rplevel::%player%::*} to 2
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Still doesn´t work

    [13:51:30] [Server thread/ERROR]: can't understand this condition: '{rpcount::%player%::*} equals 20' (rpsys.sk, line 5: if {rpcount::%player%::*} equals 20:')
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    try
    Code (Skript):
    1. if {rpcount::%player%::*} is 20:
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Code (Skript):
    1. on join:
    2.     add 5 to {rpcount::%player%::*}
    3.     message "&7[&9RP&7] &7You got &9 5 RP-Points &7 for joining the server!"
    4.     message "           &7Your current level: &9{rplevel::%player%::*} {rpcount::%player%::*}/{rplevelcount::%player%::*}"
    5.     if {rpcount::%player%::*} >= 20:
    6.         set {rplevelcount::%player%::*} to 100
    7.         set {rplevel::%player%::*} to 2
    You should put if it is bigger or equal to 20, since if you have 18 points and you give 5 it would stay at 23 and it would not be 20 anymore.
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    good point but you would need to also make a variable or something to check if its the first time over 20 or else it would trigger everytime they get more points above 20 if that makes sense
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Thank you sooooooooo much!:emoji_nerd:

    Where did you learn that?
    --- Double Post Merged, Aug 13, 2017, Original Post Date: Aug 13, 2017 ---
    One more porblem the variables wont show the actual number in the chat, what should I do about this?
    --- Double Post Merged, Aug 13, 2017 ---
    The problem is: I dont know how to do that xD
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    what do you mean it doesnt show the actual number?

    for your second question heres a crude example:
    Code (Skript):
    1. on whatever:
    2.     if {first} is not set:
    3.         #do something
    4.         set {first} to true
     
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Thank you!



    Here´s the problem:

    If I login in minecraft the thing is doenst show the numbers the variables contain (e.g. "4") but it shows {rpcount::%player%::*}
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    to show the value of a variable in a message put in in percents like %{rpcount::%player%::*}%
     
    Florin Krasnic likes this.
  12. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Thanks man!
    --- Double Post Merged, Aug 14, 2017, Original Post Date: Aug 14, 2017 ---
    Can you help me? I doesnt level up because I am not able to use the variable in that way that it prevents the other variable from triggering another level
    Code (Skript):
    1. on first join:
    2.     set {rpcount.%player%} to 0
    3.     set {rplevelcount.%player%} to 20
    4.     set {rplevel.%player%} to 1            #LEVEL 1
    5.  
    6. on join:
    7.     add 500 to {rpcount.%player%}
    8.     message "&7[&9RP&7] &7Du bekommst &9 500 RP-Points &7für das betreten des Servers!"
    9.     message "           &7Derzeitiges Level: &9 %{rplevel.%player%}% &7|&9  %{rpcount.%player%}%/%{rplevelcount.%player%}%"
    10.     if {rpcount.%player%} >= 20:            #LEVEL 2
    11.         set {first20rp} to true
    12.         set {rpcount.%player%} to 0
    13.         set {rplevelcount.%player%} to 100
    14.         set {rplevel.%player%} to 2
    15.         if {first20rp} is true:
    16.             if {rpcount.%player%} >= 100:            #LEVEL 3
    17.                 set {first100rp} to true
    18.                 set {rpcount.%player%} to 0
    19.                 set {rplevelcount.%player%} to 500
    20.                 set {rplevel.%player%} to 3
    21.                 if {first100rp} is true:
    22.                     if {rpcount.%player%} >= 500:            #LEVEL 4
    23.                         set {first500rp} to true                      
    24.                         set {rpcount.%player%} to 0
    25.                         set {rplevelcount.%player%} to 1500
    26.                         set {rplevel.%player%} to 4
    27.                         if {first500rp} is true:
    28.                             if {rpcount.%player%} >= 1500:            #LEVEL 5
    29.                                 set {first1500rp} to true                      
    30.                                 set {rpcount.%player%} to 0
    31.                                 set {rplevelcount.%player%} to 3000
    32.                                 set {rplevel.%player%} to 5
     
  13. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    it would probably be better to do this like this (rough outline):
    Code (Skript):
    1. on first join:
    2.     set {level::%player%} to 1
    3.     set {pointsToLevelUp::%player%} to 20
    4.  
    5. on whatever:
    6.     if {points::%{_p}%} is greater than {pointsToLevelUp::%{_p}%}:    
    7.         add 1 to {level::%player%}
    8.         add 10 to {pointsToLevelUp::%player%}
    9.  
     
  14. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    how do I do the "is greater" ?
     
  15. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    wait what do you mean
     
    #14 ShaneBee, Aug 14, 2017
    Last edited by a moderator: Aug 14, 2017
  16. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Code (Skript):
    1. if {points::%{_p}%} is greater than {pointsToLevelUp::%{_p}%}:
    I mean this how do I do this?
     
  17. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Well you need to set a variable for the points needed to level up (looks like you want 20 to start). Then check if {rpcount::%player%::*} is greater than it.

    Sorry if I'm misunderstanding you're question
     
  18. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
Thread Status:
Not open for further replies.

Share This Page

Loading...