• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Chat commands for teleportations. My triggers are messy.

Status
Not open for further replies.
Level 3
Joined
Apr 1, 2017
Messages
47
I’m making an RPG map (6 heroes and 6 players) and I want to allow players to teleport their hero by typing –Checkpoint (number)
I actually know how to do this, but my method will take way too much time.
Here is my working idea

I can just keep making that, but I want to have multiple checkpoints and I don’t want to make them accessible from the start. That’s why I turn them off, but that means I have to do smth like this:

Please help me simplify this mess.

Extra info:

I have set variables for each of my heroes (BeastM) and no, you can’t have multiples of the same heroes in one game (you select heroes by entering specific areas).
 
Level 20
Joined
Aug 29, 2012
Messages
826
Mmh, are you familiar with substrings? I'm pretty sure you can make a trigger that detects what number players type after "-checkpoint ", and if you store regions into variables with corresponding numbers, it would be then easy to send the unit to the right region just with one trigger.
 
Level 3
Joined
Apr 1, 2017
Messages
47
Mmh, are you familiar with substrings? I'm pretty sure you can make a trigger that detects what number players type after "-checkpoint ", and if you store regions into variables with corresponding numbers, it would be then easy to send the unit to the right region just with one trigger.
No, I don't know how to do that. Can you give me an example?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
  • Checkpoint
    • Events
      • Player - Player 1 (Red) types a chat message containing -Checkpoint as A substring
    • Conditions
    • Actions
      • Set CheckpointNumber = (Integer((Substring((Entered chat string), 13, 16))))
      • Game - Display to (All players) the text: (String(CheckpointNumber))
Substring only uses a certain part of the string. You first check, if the first part is "-Checkpoint " (including the space at the end).
Then you convert the rest of the string into a number. I used 13-16 which are 4 digits, so you can have numbers up to 9999. Also negative numbers are possible (-Checkpoint -4).
 
Level 3
Joined
Apr 1, 2017
Messages
47
  • Checkpoint
    • Events
      • Player - Player 1 (Red) types a chat message containing -Checkpoint as A substring
    • Conditions
    • Actions
      • Set CheckpointNumber = (Integer((Substring((Entered chat string), 13, 16))))
      • Game - Display to (All players) the text: (String(CheckpointNumber))
Substring only uses a certain part of the string. You first check, if the first part is "-Checkpoint " (including the space at the end).
Then you convert the rest of the string into a number. I used 13-16 which are 4 digits, so you can have numbers up to 9999. Also negative numbers are possible (-Checkpoint -4).
What kind of variable is this?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Substring is a part of a string. The two numbers indicate first and last letter.

"-Checkpoint " is:

edit: the dots don't mean anything. They are just place holders. Apparently Hive does not allow multiple spaces next to each other. :(

- C h e c k p o. i .n . t . _
1 2 3 4 5 6 7 8 9 10 11 12

the number after it is:

.x . x . x . x
13 14 15 16

Substring(entered chat string,13,16) is the number after "-Checkpoint".

You should also add a condition:
substring(entered chat string,1,12) equal to "-Checkpoint "
this makes sure, that "-Checkpoint " is actually the beginning of the entered chat string.

Once you have got the number entered it should be easy. You will have an array if checkpoints.
Something like checkpoint[3] = center of region (checkpointregion03)

In your trigger you use: move instantly to checkpoint[CheckpointNumber]

You should make sure first that the entered number (CheckpointNumber) is actually the number of a checkpoint you already activated.
 
Level 12
Joined
Dec 11, 2014
Messages
662
Well first of it's hard to see what you already have done because it's not in English. You should post triggers in the trigger tags. Here's the tutorial
You can simplify by putting all events that are similar (player 1 types bla, player 2 types bla....etc) in one trigger, and then through conditions and actions you regulate what should happen.
To simplify even more you can use a loop and "Trigger - Add event" action to add events to triggers when the map starts.
 
Level 20
Joined
Aug 29, 2012
Messages
826
I've made your trigger, but I still don't really understand how this is going to help me :|

You should now create a region variable with an array and store all your regions. For instance, checkpoint 1 = YourRegionVariable[1]

Then you should be able to move your unit with "Unit - Move to Center of YourRegionVariable[(Entered chat string, 13, 16)]"
 
Level 3
Joined
Apr 1, 2017
Messages
47
You should now create a region variable with an array and store all your regions. For instance, checkpoint 1 = YourRegionVariable[1]

Then you should be able to move your unit with "Unit - Move to Center of YourRegionVariable[(Entered chat string, 13, 16)]"
Can't find "Entered chat string", can only see String lenght and only then I can find Entered chat string. So its like "Unit-Move to Center of Variable[Lenght of (Entered chat string)]
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
you need to use conversion String to integer and then you can choose strings
 
Level 3
Joined
Apr 1, 2017
Messages
47
  • Checkpoint
    • Events
      • Player - Player 1 (Red) types a chat message containing -Checkpoint as A substring
    • Conditions
    • Actions
      • Set CheckpointNumber = (Integer((Substring((Entered chat string), 13, 16))))
      • Game - Display to (All players) the text: (String(CheckpointNumber))
Substring only uses a certain part of the string. You first check, if the first part is "-Checkpoint " (including the space at the end).
Then you convert the rest of the string into a number. I used 13-16 which are 4 digits, so you can have numbers up to 9999. Also negative numbers are possible (-Checkpoint -4).
You means this?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I am going to make a map in about 10 minutes showing how to do it. It's actually quite simple, but hard to explain.:)

Edit: map uploaded.
 

Attachments

  • checkpoints.w3m
    16.9 KB · Views: 32
Last edited:
Status
Not open for further replies.
Top