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

The famous -roll command.

Status
Not open for further replies.
Level 30
Joined
Jan 31, 2010
Messages
3,551
Hi there. I need help with a trigger. Apparently, it should look like this:

I part:
2 players are arguing which one of them will switch to other team. They propose the ,,Roll function". Each of them types a message containing ,,-roll". On the screen of each player, a message with next text will be displayed, if the player names are ,,Apheraz Lucent" and ,,LichPrince":

Apheraz Lucent has rolled X out of 100.
LichPrince has rolled Y out of 100.

Where the X and Y would be random numbers, from 1 to 100.

II part:
Again, two players are arguing which one of them will switch back to other team. They propose the ,,Roll function", but to the maximum captivity of 32. Each of them types a message containing ,,-roll 32". On the screen of each player, a message with next text will be displayed, if the player names are ,,Apheraz Lucent" and ,,LichPrince":

Apheraz Lucent has rolled X out of 32.
LichPrince has rolled Y out of 32.

Where the X and Y would be random numbers, from 1 to 32.

I will give +rep to anyone that can help me, and credits.
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
here this should work

  • roll
    • Events
      • Player - Player 1 (Red) types a chat message containing -roll as An exact match
  • ...ect other players
    • Conditions
    • Actions
      • Set roll = (Random integer number between 1 and 100)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has rolled + ((String(roll)) + ( out of + 100))))
ill up date for if roll is out of custom value

EDIT: here
  • roll custom
    • Events
      • Player - Player 1 (Red) types a chat message containing -roll as A substring
  • ...ect other players
    • Conditions
    • Actions
      • Set roll_custom = (Integer((Substring((Entered chat string), 7, 10))))
      • Set roll = (Random integer number between 1 and roll_custom)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has rolled + ((String(roll)) + ( out of + (String(roll_custom))))))
may need to work with the enterd chat string stuff i dont know how it will go for a 2 digit number.
i dont use it much
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
i dunno about number 1 but number 2
  • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has rolled + ((String(roll)) + ( out of + (String(roll_custom))))))
make sure its out of string(roll_custom)
not out of 100

as i said i havent messed around with enterd chat string so i cant help you with number 1 soz

edit:
soz mis understood number 1 the triggers are 2 different triggers one for roll one for custom roll
 
When you type "-roll", it also triggers the event with "as a substring".
I would do this like that :

  • roll
    • Events
      • Player - Player 1 (Red) types a chat message containing -roll as A substring
      • ...ect other players
    • Conditions
    • Actions
      • Set roll_custom = (Integer((Substring((Entered chat string), 7, 70))))
      • if (roll_custom is lesser or equal to 0) then
        • set roll_custom = 100
      • Set roll = (Random integer number between 1 and roll_custom)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has rolled + ((String(roll)) + ( out of + (String(roll_custom))))))
When you just type "-roll", the "Integer(SubString(Entered chat string,7, 70))" returns 0 so you use 100 as a default value. You can also put "String length of Entered chat string" instead of 70.
And you must have make a mystake with your second problem, as millzy said.
 
Status
Not open for further replies.
Top