Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Hello everyone. Is there a way to set level as desired number via chat commands? Like -lvl 5
Is there a "easy way" to do that? Otherwise of course i can create 30 triggers for 30 levels but i believe there is easy solution..
I think this question has already been asked on this forum many times, so searching the forums may have given you some insights.
Anyway, you can work with something like this:
Set Level
Events
Player - Player 1 (Red) types a chat message containing -lvl as A substring
Conditions
(Length of (Entered chat string)) Greater than 6
(Length of (Entered chat string)) Less than or equal to 7
(Substring((Entered chat string), 1, 5)) Equal to -lvl
Actions
Set VariableSet Level = (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Level Equal to 0
Then - Actions
Game - Display to (Player group((Triggering player))) the text: Invalid value for c...
Skip remaining actions
Else - Actions
Set VariableSet Level = (Min((Max(1, Level)), 10))
Hero - Set Your_Hero Hero-level to Level, Show level-up graphics
You check that the text player entered contains '-lvl ' (including the empty space behind)
But that means the trigger would fire for example when player writes into chat something like 'abcdef -lvl xxx yyy'. Hence the conditions
The conditions check that
the string length is 6 or 7 characters (5 length for '-lvl ' + 1 or 2 characters representing the number)
check that the start of string is '-lvl '
The actions convert the 6 and 7 character into integer number
The if/then/else checks that the conversion was successful (e.g. this avoid issues if player entered string '-lvl AB')
The min/max functions are used to clamp the level number between 1 and 10 (i.e. if you enter '-lvl 99', it will not give level 99 but level 10. Same for entering '-lvl -5' which will give level 1)
You can add the same event into this trigger for the remaining player, but you will need to determine on your own which hero you should give the level to.
For example if in your map a player can only have a single hero, you can store those heroes in an array, where the array index corresponds to player's number.
Player - Player 1 (Red) types a chat message containing -lvl as A substring
Conditions
Actions
Set VariableSet NewLevel = (Integer((Substring((Entered chat string), 5, (Length of (Entered chat string))))))
Hero - Set Your_Hero Hero-level to NewLevel, Show level-up graphics
Nichilus added some nice features to avoid potential issues, but those aren't necessarily required for it to work.
The idea is simple, the player types "-lvl 5" for example. The (Entered chat string) is set to "-lvl 5". We then use the Substring() function to find the 5th -> Last character in that chat string, which means everything after the word "-lvl". We then convert those last few characters into an Integer (NewLevel) and Set our Hero level to NewLevel. If the user didn't type any Integers after -lvl then it will fail to work.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.