get last message trigger?

Status
Not open for further replies.
Level 4
Joined
Sep 8, 2008
Messages
73
I have a small problem.
First, i'm using a trigger with "a player sends a message" as a event, which is a WEU exclusive event, yet i dont want the 200kb filesize that the entire code uses.
Since this is the only thing i need from it, i would really like to just use a custom script version of it if possible (if anyone can find the specific code snippet and post it that would be great too).

And second, the damn trigger doesent work.
It looks pretty much like this:

EVENT:
Player 1 sends a message
-------And then the same for every other player-------
ACTIONS:
Set "message[Temp_integer]" = Entered Chat String

Thing is, it doesent save the message.
And i also have an integer storing the player that writes every message, called "player_integer[Item_integer]" that is set to the player number of triggering player, yet when i try to convert the number into the players name through "name of player - convert player index to player - "player[(and here goes my array reference)]", WC3 crashes when i try to call it.

SO basically, how do i implement some "getlastchatmessage"-jass function instead of stupid get last entered chat string? I dont know the name of it, you see.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
And what is wrong with:
  • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
P.s. For <Empty String> you just enter nothing or a single space ( " " ).
 
Level 4
Joined
Sep 8, 2008
Messages
73
And what is wrong with:
  • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
P.s. For <Empty String> you just enter nothing or a single space ( " " ).

Oh, well that's true! I didnt know the event supported substrings.
I'm gonna have to check if this copes with "entered chat message", but i guess there will be no problem.

Still, wc3 crashes when i try to obtain a players name from an integer array and convert it to a string, whats up with that?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I am sorry, but you are confusing me.
Anyways, what about:
Player - Player Name -> Triggering Player:
Name of (Triggering Player)
 
Level 4
Joined
Sep 8, 2008
Messages
73
I am sorry, but you are confusing me.
Anyways, what about:
Player - Player Name -> Triggering Player:
Name of (Triggering Player)

Well.. triggering player wont work, i want to use the name of the person who wrote the chat string to appear after the string itself to whoever inwokes the trigger. The player (or author, if you want) array index is decided by an item custom number.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
The player who wrote the message is the player who triggered the trigger if the event is, Player types a chat message.

How do you want us to help you if you do not explain what you you want.
 
Level 4
Joined
Sep 8, 2008
Messages
73
The player who wrote the message is the player who triggered the trigger if the event is, Player types a chat message.

How do you want us to help you if you do not explain what you you want.

Well, ok, i have three triggers, the first looks like this:

EVENT:
a unit uses an item.
CONDITION:
item being used equal to "storage item"
ACTION:
set IsWriting[player number of owner of triggering unit] = true.

Next trigger looks like this:

EVENT:
Player (and then the number of every player) types a chat message containing "" as a substring.
CONDITION:
IsWriting[Player number of triggering player] = True
ACTIONS:
IsWriting[Player number of triggering player] = False
Create Projector Item to Player_unit[Team Nuber of Triggering Player] //this is a variable that keeps the character of every player stored
Set Message[Item_Integer] = Entered Chat string
Set Custom Value of [last created item] = Item Integer
Set Item_Integer = Item Integer++
Set Author[Item Intger] = Triggering Player

And the last one looks like this:

EVENT:
A unit uses an item.
CONDITION:
Item(type of item) = "Storage item"

Display to (Owner of triggering unit) the text: "message[custom calue of item being manipulated]" +"|n//"+Author[Name of player(Convert player index to player(Custom Value of Item))]

And here i have two problems:

1. The string is not saved into the "message" variable!!!
2. The game crashes when i try to ad the layer name of "author" to the message displayed.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
First of all switch the lines:
  • Set Item_Integer = Item Integer+1
  • Set Author[Item Intger] = Triggering Player
With each other:

  • Set Author[Item Intger] = Triggering Player
  • Set Item_Integer = Item Integer+1
Naturally you do not have a message variable - you have a Message one. So the actions of the last trigger should be:
  • Game - Display to (Owner of triggering unit) the text: Message[(Custom Value of (Item being manipulated))] +"\n"+Name of player(Author[Custom Value of (Item being manipulated)])
I think those are not your exact triggers, so it will be kinda hard to find your problem this way.

And more efficient way would be:
Substitute the line
  • Set Author[Item Integer] = Player Number of (Triggering Player)
And then the last trigger:
  • Display to (Owner of triggering unit) the text: Message[(Custom Value of (Item being manipulated))] +"\n"+Name of player(Convert Player index to player(Author[Custom Value of (Item being manipulated)]))
But in this case, Author should be an integer array.

P.s. Use [ trigger][ /trigger] tags and copy the triggers as text - right click on the first line of any GUI trigger and then click copy as text
 
Level 4
Joined
Sep 8, 2008
Messages
73
First of all switch the lines:
  • Set Item_Integer = Item Integer+1
  • Set Author[Item Intger] = Triggering Player
With each other:

  • Set Author[Item Intger] = Triggering Player
  • Set Item_Integer = Item Integer+1
Naturally you do not have a message variable - you have a Message one. So the actions of the last trigger should be:
  • Game - Display to (Owner of triggering unit) the text: Message[(Custom Value of (Item being manipulated))] +"\n"+Name of player(Author[Custom Value of (Item being manipulated)])
I think those are not your exact triggers, so it will be kinda hard to find your problem this way.

And more efficient way would be:
Substitute the line
  • Set Author[Item Integer] = Player Number of (Triggering Player)
And then the last trigger:
  • Display to (Owner of triggering unit) the text: Message[(Custom Value of (Item being manipulated))] +"\n"+Name of player(Convert Player index to player(Author[Custom Value of (Item being manipulated)]))
But in this case, Author should be an integer array.

P.s. Use [ trigger][ /trigger] tags and copy the triggers as text - right click on the first line of any GUI trigger and then click copy as text

Well, all that i knew i could do was to swap the places between the variables as you told me, and, "author" is a variable in my trigger aswell, but in every other way, my trigger looks just the same. Except now that i changed to
  • Player - Player 1 (Red) types a chat message containing "" as A substring
, the unit is not even given an item.

Well, i'll just post the entire trigger here then:

  • Write Letter Finish
    • Events
      • Player - Player 1 (Red) types a chat message containing "" as A substring
      • Player - Player 2 (Blue) types a chat message containing "" as A substring
      • Player - Player 3 (Teal) types a chat message containing "" as A substring
      • Player - Player 4 (Purple) types a chat message containing "" as A substring
      • Player - Player 5 (Yellow) types a chat message containing "" as A substring
      • Player - Player 6 (Orange) types a chat message containing "" as A substring
      • Player - Player 7 (Green) types a chat message containing "" as A substring
      • Player - Player 8 (Pink) types a chat message containing "" as A substring
    • Conditions
      • Player_IsWriting[(Team number of (Triggering player))] Equal to True
    • Actions
      • Set Item_Integer = (Item_Integer + 1)
      • Hero - Create Letter and give it to Player_Unit[(Team number of (Triggering player))]
      • Item - Set the custom value of (Last created item) to Item_Integer
      • Set Letter[Item_Integer] = (Entered chat string)
      • Set Author[Item_Integer] = (Team number of (Triggering player))
      • Set Player_IsWriting[(Team number of (Triggering player))] = False
And fot the showing i have:

  • Letter Show
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Letter
    • Actions
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: (Letter[(Custom value of (Item being manipulated))] + (|n|n// + (Name of (Player(Author[(Custom value of (Item being manipulated))])))))
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: (String((Custom value of (Item being manipulated))))
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: Letter[(Custom value of (Item being manipulated))]
EDIT: The last two lines are just for debug purpouses, and are disabled. Ignore them.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • Write Letter Finish
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
      • Player - Player 2 (Blue) types a chat message containing <Empty String> as A substring
      • Player - Player 3 (Teal) types a chat message containing <Empty String> as A substring
      • Player - Player 4 (Purple) types a chat message containing <Empty String> as A substring
      • Player - Player 5 (Yellow) types a chat message containing <Empty String> as A substring
      • Player - Player 6 (Orange) types a chat message containing <Empty String> as A substring
      • Player - Player 7 (Green) types a chat message containing <Empty String> as A substring
      • Player - Player 8 (Pink) types a chat message containing <Empty String> as A substring
    • Conditions
      • Player_IsWriting[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set Item_Integer = (Item_Integer + 1)
      • Hero - Create Letter and give it to Player_Unit[(Player number of (Triggering player))]
      • Item - Set the custom value of (Last created item) to Item_Integer
      • Set Letter[Item_Integer] = (Entered chat string)
      • Set Author[Item_Integer] = (Player number of (Triggering player))
      • Set Player_IsWriting[(Player number of (Triggering player))] = False
Hm, when I enter an empty string in the event, it is displayed as <Empty String>. So I reckon yours isn't empty.
Also I reckon you want to use "Player Number of" instead of "Team Number"

  • Letter Show
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Letter
    • Actions
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: (Letter[(Custom value of (Item being manipulated))] + ("\n\n" + (Name of (Player(Author[(Custom value of (Item being manipulated))])))))
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: (String((Custom value of (Item being manipulated))))
      • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 15.00 seconds the text: Letter[(Custom value of (Item being manipulated))]
 
Level 4
Joined
Sep 8, 2008
Messages
73
Oh, thanks! For some reason i had apparently entered simply two quote marks instead of just nothing (wonder what i was thinking)

And about player team, it works pretty much the same as player number, or am i wrong?
I mean, i beilive it works in all my other functions.
Thanks however! I'm gonna test it right away.


EDIT: I have noticed that tags like |n does not work with triggers, so how do you add a linebreak?
Just as a final quiestion. The rest worked real smooth, thanks a lot.
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
slash n - \n in the string.
See my previous posts for examples.
Team number of players is the same for allies, but if there are no allies it should not be a problem.
 
Status
Not open for further replies.
Top