Solved add variable to variable

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

blockminer

Member
Jun 22, 2021
4
0
1
23
I can't add variable to variable.. Am I have to add an addon? or I can solve it by other way?
Code:
if clicked slot is 4:
            set {_pay} to 0
            loop {NUM::%player%} times:
                add {STOCKPAY::%{BUY::%player%}%} to {_pay}
                message "%{_pay}%" to player
 
How is {STOCKPAY::%{BUY::%player%}%} set?

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

Code:
if clicked slot is 4:
    set {_pay} to 0
    formatNum({STOCKPAY::%{BUY::%player%}%}, player)

function formatNum(n:number, p: player) :: string:
    set {_anwser} to ({_n}*{NUM::%{_p}%})
    set {STOCKPAY::%{BUY::%{_p}%}%} to {_anwser}
    send "%{_anwser}%" to {_p}

Also you HAVE to make sure that {STOCKPAY::%{BUY::%player%}%} is NOT set as a text.

Examples:

Wrong way
Code:
set {STOCKPAY::%{BUY::%player%}%} to "123"

Right way
Code:
set {STOCKPAY::%{BUY::%player%}%} to 123
 
Last edited:
How is {STOCKPAY::%{BUY::%player%}%} set?

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

Code:
if clicked slot is 4:
    set {_pay} to 0
    formatNum({STOCKPAY::%{BUY::%player%}%}, player)

function formatNum(n:number, p: player) :: string:
    set {_anwser} to ({_n}*{NUM::%{_p}%})
    set {STOCKPAY::%{BUY::%{_p}%}%} to {_anwser}
    send "%{_anwser}%" to {_p}

Also you HAVE to make sure that {STOCKPAY::%{BUY::%player%}%} is NOT set as a text.

Examples:

Wrong way
Code:
set {STOCKPAY::%{BUY::%player%}%} to "123"

Right way
Code:
set {STOCKPAY::%{BUY::%player%}%} to 123


thanks! it solved,but function didn't work...
 
Status
Not open for further replies.