• 🏆 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!

I get crash with trigger. Help

Status
Not open for further replies.
Level 12
Joined
Apr 16, 2010
Messages
584
Hello. Today i uploaded system but user mnib noticed a crash when you type -duel and color of player or any other number where are no players. So if you type -duel 17 it'll crash, same as you'll type -duel red.
Any suggestions??
Here's the trigger:
  • CDS Ask for Duel
    • Events
      • Player - Player 1 (Red) types a chat message containing -duel as A substring
      • Player - Player 2 (Blue) types a chat message containing -duel as A substring
      • Player - Player 3 (Teal) types a chat message containing -duel as A substring
      • Player - Player 4 (Purple) types a chat message containing -duel as A substring
      • Player - Player 5 (Yellow) types a chat message containing -duel as A substring
      • Player - Player 6 (Orange) types a chat message containing -duel as A substring
      • Player - Player 7 (Green) types a chat message containing -duel as A substring
      • Player - Player 8 (Pink) types a chat message containing -duel as A substring
      • Player - Player 9 (Gray) types a chat message containing -duel as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -duel as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -duel as A substring
      • Player - Player 12 (Brown) types a chat message containing -duel as A substring
    • Conditions
    • Actions
      • -------- Start the timer --------
      • Countdown Timer - Start CDS_Timer as a One-shot timer that will expire in CDS_Seconds seconds
      • -------- If duel is in progress inform the player --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CDS_On Equal to True
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: |cfffed312Duel is i...
        • Else - Actions
          • -------- Setting variables --------
      • Trigger - Turn on CDS Vote Yes <gen>
      • Trigger - Turn on CDS Vote No <gen>
      • Set CDS_Player[1] = (Integer((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
      • Set CDS_Player[2] = (Player number of (Triggering player))
      • -------- Chek if both players are enemies --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • CDS_On Equal to False
              • ((Player(CDS_Player[1])) is an enemy of (Player(CDS_Player[2]))) Equal to True
        • Then - Actions
          • -------- If they are enemies we turn on the duel --------
          • Set CDS_On = True
          • Game - Display to (Player group((Player(CDS_Player[1])))) the text: (|cfffed312 + ((String(CDS_Player[1])) + wants to fight with you in duel. If you want to fight type "-accept" or "-reject' to give up.))
          • Game - Display to (Player group((Player(CDS_Player[2])))) the text: (|cfffed312You asked for duel with player + (Name of (Player(CDS_Player[1]))))
          • -------- Now we must wait until second player accepts the duel offer or rejects --------
          • Wait until (CDS_Accept Equal to True), checking every 1.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CDS_Accept Equal to True
            • Then - Actions
              • -------- If he accepted we set both units and move them to the Duel region. --------
              • -------- We also set the life and mana before duel, so the winner will come out with previous life and mana. --------
              • Unit Group - Pick every unit in (Units owned by (Player(CDS_Player[1])) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
                • Loop - Actions
                  • Set CDS_Unit[1] = (Picked unit)
                  • Set CDS_Unit_Life[1] = (Life of CDS_Unit[1])
                  • Set CDS_Unit_Mana[1] = (Mana of CDS_Unit[1])
                  • Set CDS_Positions[1] = (Position of (Picked unit))
                  • Unit - Move CDS_Unit[1] instantly to ((Center of CDS_Region) offset by 300.00 towards 300.00 degrees)
                  • Unit Group - Add CDS_Unit[1] to CDS_Unit_Group
                  • Unit - Unpause CDS_Unit[1]
              • Unit Group - Pick every unit in (Units owned by (Player(CDS_Player[2])) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
                • Loop - Actions
                  • Set CDS_Unit[2] = (Picked unit)
                  • Set CDS_Unit_Life[2] = (Life of CDS_Unit[2])
                  • Set CDS_Unit_Mana[2] = (Mana of CDS_Unit[2])
                  • Set CDS_Positions[2] = (Position of (Picked unit))
                  • Unit - Move CDS_Unit[2] instantly to ((Center of CDS_Region) offset by 300.00 towards 150.00 degrees)
                  • Unit Group - Add CDS_Unit[2] to CDS_Unit_Group
                  • Unit - Unpause CDS_Unit[2]
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • -------- Now we make other players to watch the duel so no one will cheat. --------
                  • Game - Display to (Player group((Picked player))) the text: (|cfffed312The duel between + ((Name of (Owner of CDS_Unit[1])) + ( and + ((Name of (Owner of CDS_Unit[2])) + has started.))))
                  • Camera - Pan camera for (Picked player) to (Center of CDS_Region) over 0.00 seconds
                  • Camera - Lock camera target for (Picked player) to (Random unit from (Units of type CDS_Dummy)), offset by (0.00, 0.00) using Default rotation
                  • Unit - Pause all units
                  • Unit - Unpause CDS_Unit[1]
                  • Unit - Unpause CDS_Unit[2]
            • Else - Actions
        • Else - Actions
          • -------- If the player picked fight with ally he won't be able to fight with him. --------
          • Game - Display to (Player group((Player(CDS_Player[2])))) the text: |cfffed312You can o...
 
Level 12
Joined
Apr 16, 2010
Messages
584
Could you show what exactly? I tried almost everything and no positive result(
Almost near to give you +rep xDD

Oh yeah i added this condition (
  • (Length of (Entered chat string)) Less than or equal to 8
) so now only you can type less then 100 but still if you type 17, 18, 19... it crashes.
So i need to make the biggest amount 12. But have no idea how.
 
Guys one more problem how do i check if the next typed symbols after "-duel " are numbers?? Cuz it crashes when i type -duel and something with words.


Sorry i forgot(

Here, all fresh for you :]
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Trigger - Add to One <gen> the event (Player - (Player((Integer A))) types a chat message containing -duel as A substring)
            • Else - Actions
  • One
    • Events
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -duel
    • Actions
      • Set Exu = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Integer(Exu)) / (Length of Exu)) Not equal to (Integer A)
            • Then - Actions
              • Game - Display to (All players) the text: The text you've ent...
              • Skip remaining actions
            • Else - Actions
              • Game - Display to (All players) the text: The text you've ent...
              • Skip remaining actions
So basically, it checks if each character of the entered chat string (except for the "-duel " part) is all numeric. If it is full of numbers, it will tell you that it has numbers; if it has no numbers (E.g. "house") or it has numbers combined with text (E.g. "asd123"), it will tell you that it doesn't have numbers or it is text combined with numbers, something you obviously wouldn't like for your -duel system.

Test Map:
 

Attachments

  • Numeric Detection.w3x
    17.2 KB · Views: 56
Status
Not open for further replies.
Top