Game crash/ non-existing substrings...

malfy

New Member
Reaction score
4
On my map I have the following trigger. It works just fine when I enter a player number (ex: -skills 3), but when I 'accidently' leave out a number and just type '-skills' the game crashes. How can I add in some protection for this?
Trigger:
  • skillrequest
    • Events
      • Player - Player 1 (Red) types a chat message containing -skills as A substring
      • Player - Player 2 (Blue) types a chat message containing -skills as A substring
      • Player - Player 3 (Teal) types a chat message containing -skills as A substring
      • Player - Player 4 (Purple) types a chat message containing -skills as A substring
      • Player - Player 5 (Yellow) types a chat message containing -skills as A substring
      • Player - Player 6 (Orange) types a chat message containing -skills as A substring
      • Player - Player 7 (Green) types a chat message containing -skills as A substring
      • Player - Player 8 (Pink) types a chat message containing -skills as A substring
      • Player - Player 9 (Gray) types a chat message containing -skills as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -skills as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -skills as A substring
      • Player - Player 12 (Brown) types a chat message containing -skills as A substring
    • Conditions
    • Actions
      • Set skillchk_playernum[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 9, 10))))
      • Game - Display to (All players) the text: ((Name of (Player(skillchk_playernum[(Player number of (Triggering player))]))) + &#039;s Skills<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />
      • For each (Integer A) from ((skillchk_playernum[(Player number of (Triggering player))] x 7) - 6) to (skillchk_playernum[(Player number of (Triggering player))] x 7), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • heroskills[(Integer A)] Not equal to Acid Bomb
            • Then - Actions
              • Game - Display to (All players) the text: ((String((Integer A))) + ( + (Name of heroskills[(Integer A)])))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Equal to ((skillchk_playernum[(Player number of (Triggering player))] x 7) - 6)
                • Then - Actions
                  • Game - Display to (All players) the text: None
                • Else - Actions
                  • Do nothing


skillchk_playernum...integer array (12)
heroskills...............ability array (84) initally assigned 'acid bomb'..................(7 skills/12 players)
 

werasd

New Member
Reaction score
14
maybe adding a condition to the trigger so that the actions are only activated when the user types more then 7 characters ("-skills" has 7 characters). Despite all of this... i guess it shouldn't be crashing, since you just didn't add any action for it.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
It's not so much because of a missing substring, as because you're trying to access a nonexistent player. (Typing -skills 20 should also crash.)

You need to limit it to a valid range: Set skillchk_playernum[(Player number of (Triggering player))] = Max(Min((Integer((Substring((Entered chat string), 9, 10)))),12),1)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top