Zrips / CMI

114 stars 97 forks source link

Custom Aliases - Execute random command from the list? #4409

Closed bobhenl closed 3 years ago

bobhenl commented 3 years ago

Description of feature/improvement request:


Detailed explanation of what it should do, when and in what situation:

Hi, could you add option to make list of commands in one custom alias and there add something like Random! and then one of the commands listed below will be executed? Can't be just commands, could be also just one words or texts.

Basic explanation as to why this feature is needed and/or useful to have:

For ex. if we wanna make custom alias to give random reward from event, this could be useful, then when we'll have custom alias to transform to youtuber, we'll want choose just one word from the list, where will be names of youtubers. There could be for ex. command to set player's name, like name [playerName] and then random![name,name,name] for ex. in this format, also will be acceptable for commands, if we use - random![give [playerName] xxx xxx xxx, give [playerName] yyy yyy] etc.

CloudeLecaw commented 3 years ago

You can do this allready with a work arround First you create a little msg with a randomnumber from let say 1 to 5 After that you create 5 check if it 1 2 3 45 command and if this is true then execute the command

Here a little example inside a customalias. first it used a command with a random number between 1 and 5 after it it checks if the random number was 1,2,3,4,5 and execute the command after it if the condition is true (so it execute allways one of the 5 command after depending of what was your number in %cmi_random_1_5%)

  testcommand:
    Cmds:
    - msg! [playerName] Your Lucky Rewardnumber is the &e&l%cmi_random_1_5% of 5.
    - check:%cmi_lastrandom_[playerName]%==1! msg! 8[playerName] Your Number is 1
    - check:%cmi_lastrandom_[playerName]%==2! msg! 8[playerName] Your Number is 2
    - check:%cmi_lastrandom_[playerName]%==3! msg! 8[playerName] Your Number is 3
    - check:%cmi_lastrandom_[playerName]%==4! msg! 8[playerName] Your Number is 4
    - check:%cmi_lastrandom_[playerName]%==5! msg! 8[playerName] Your Number is 5

Now you can setup your 5 different give commands instead of the msg! and its random because noone knows if it is 1 or 2 or 3 or 4 or 5 before Maybe u find a way to generate this %cmi_random_1_5% number without needing a msg... just have no idea how :3

bobhenl commented 3 years ago

And how can for ex. I put there these commands?

1: /cmi give @p diamond_sword{display:{Name:'[{"text":"Unbreakable sword","italic":false,"color":"dark_aqua"}]',Lore:['[{"text":"Event reward","italic":false,"underlined":true,"color":"dark_red"}]']},Unbreakable:1} 1
2: /cmi give @p golden_sword{Damage:33,RepairCost:10,display:{Name:'[{"text":"One Hit Loot Sword","italic":false,"color":"dark_aqua"}]',Lore:['[{"text":"Event reward","italic":false,"underlined":true,"color":"dark_red"}]']},Enchantments:[{id:looting,lvl:6},{id:sharpness,lvl:20}]} 1

Is it possible somehow?

CloudeLecaw commented 3 years ago

You put your commands instead of the msg just without the / at beginning

  testcommand:
    Cmds:
    - msg! [playerName] Your Lucky Rewardnumber is the &e&l%cmi_random_1_2% of 2.
    - check:%cmi_lastrandom_[playerName]%==1! YourFirstCommand without the /
    - check:%cmi_lastrandom_[playerName]%==2! YourSecoundCommand without the /

I suggest instead of using @p using [playerName] Also you might should add a permission that is neededbat the beginning (before the first msg where it generate the random number) like perm:cmi.command.customalias.testcommand#! This wil check if player has the the wanted permission and if not it breaks up all commands of this custom alias (because of the #) instead of executing it. Usefull when just staff and console should be able to use this custom alais

bobhenl commented 3 years ago

Ok, works. thanks