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 add variable to variable

Discussion in 'Skript' started by blockminer, Oct 18, 2021.

Tags:
  1. blockminer

    blockminer Member

    Joined:
    Jun 22, 2021
    Messages:
    4
    Likes Received:
    0
    I can't add variable to variable.. Am I have to add an addon? or I can solve it by other way?
    Code (Text):
    1. if clicked slot is 4:
    2.             set {_pay} to 0
    3.             loop {NUM::%player%} times:
    4.                 add {STOCKPAY::%{BUY::%player%}%} to {_pay}
    5.                 message "%{_pay}%" to player
     
  2. Best Answer:
    Post #2 by Flasser, Oct 20, 2021
  3. Flasser

    Flasser New Member

    Joined:
    Oct 19, 2021
    Messages:
    7
    Likes Received:
    0
    How is {STOCKPAY::%{BUY::%player%}%} set?

    But if you want to do a multiplication of numbers with skript, you can use this.

    Code (Text):
    1. if clicked slot is 4:
    2.     set {_pay} to 0
    3.     formatNum({STOCKPAY::%{BUY::%player%}%}, player)
    4.  
    5. function formatNum(n:number, p: player) :: string:
    6.     set {_anwser} to ({_n}*{NUM::%{_p}%})
    7.     set {STOCKPAY::%{BUY::%{_p}%}%} to {_anwser}
    8.     send "%{_anwser}%" to {_p}
    Also you HAVE to make sure that {STOCKPAY::%{BUY::%player%}%} is NOT set as a text.

    Examples:

    Wrong way
    Code (Text):
    1. set {STOCKPAY::%{BUY::%player%}%} to "123"
    Right way
    Code (Text):
    1. set {STOCKPAY::%{BUY::%player%}%} to 123
     
    #2 Flasser, Oct 20, 2021
    Last edited: Oct 20, 2021
  4. blockminer

    blockminer Member

    Joined:
    Jun 22, 2021
    Messages:
    4
    Likes Received:
    0

    thanks! it solved,but function didn't work...
     

Share This Page

Loading...