#Using % Variables In Another Variable Skript

1 messages · Page 1 of 1 (latest)

smoky ember
#

Hello! I'm trying to make a system where people can set a command, then when another player executes it, it will replace %player% with their name in the command they set.

This is where is does the command:

                        set {_id} to arg 1
                        set {_command} to "%{code.%{_id}%}%"
                        if {code.%{_id}%.used} is true:
                                send "&cThis code has already been used." to player
                        else if {code.%{_id}%} is not set:
                                send "&cThis code isn't valid." to player
                        else:
                                set {code.%{_id}%.used} to true
                                execute console command "%{_command}%"
                                send "&a&lCode Redeemed!" to player
                                send "&7(&3%{_command}%&7)" to player

If the command I set was /say %player% and my username was GrantieYT, I want it to execute the command /say GrantieYT. Instead, it keeps executing the command /say %player%.

This is where you set the command:

set {_codeId} to random integer between 10000000000 and 99999999999
set {_command} to arg 1 # arg 1 is an optional text arg for the command
add {_codeId} to {codes::*} # this is a list for listing all the commands and such
set {code.%{_codeId}%} to {_command} # this sets the command

Any help is appreciated, thanks!

mental thicket
#

are you trying to use default arguments? or wdym

smoky ember
#

I made an argument.

#

It's a <text> arg

#

So basically I'm making a code system.

#

Staff can create a code with /createcode [<text> (command)]. If the command arg was /say %player%, when another player uses the code, I want it to use the player's username as %player%. For example, if my username was GrantieYT and I redeemed the code with the command /say %player%, I want the console to execute /say GrantieYT since that's my username. Instead, it doesn't put my name, it just tries to execute /say %player%. Thanks for responding!

#

@mental thicket ^^^

mental thicket
#

ya don't think skript evaluates expressions in text arguments like that. you would have to make it where it replaces all the %player% in the code with the executor's name

smoky ember
#

Do you know how to do that?

wintry vector
#

i think

#

idk

smoky ember
#

How do you replace something in a text var

smoky ember
#

Does anyone know how to replace texts in a variable with something else?

#

Got it figured it out