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

Display error message

Status
Not open for further replies.
Level 4
Joined
Dec 25, 2012
Messages
66
Is there a way to display a message in a way that is 100% similar to default interface error messages (e.g. "Build a farm", "Must target flying unit", etc.). It is demonstrated in DotA when player tries to attack Roshan from outside the cave.

DisplayTextToPlayer(<player>,1,1, "Message") sort of works, but as soon as there is another message displayed at different screen coords, every text line jumps to that last message's location on screen.
 
Level 15
Joined
Sep 29, 2008
Messages
362
I've used this from Vexorian library.
Code:
function CS_Error takes player ForPlayer,string msg returns nothing
local sound error=CreateSoundFromLabel("InterfaceError", false, false, false, 10, 10)
  if ( GetLocalPlayer() == ForPlayer ) then
  if ( msg != "" ) and ( msg != null ) then
  call ClearTextMessages()
  call DisplayTimedTextToPlayer(ForPlayer, 0.52, - 1.00, 2.00, "|cffffcc00" + msg + "|r")
  endif
  call StartSound(error)
  endif
call KillSoundWhenDone(error)
set error=null
endfunction

to prevent display other lines at same screen coords.
Use "call ClearTextMessages()" just before the display msg with new coords... put All instructions into local player scope.
 
Level 4
Joined
Dec 25, 2012
Messages
66
Thanks all! Though it buggers me to realize, that robust engine of WC3 is limited in such a basic area as displaying text :O
 
Level 4
Joined
Dec 25, 2012
Messages
66
P.S: It's not over yet! I've noticed, that there is a native error message, that reads "Must target non-decayed corpse" in the game interface editor (variable name: TargetCorpse). Since specific corpses can never be manually targeted by players, this message is effectively never shown in game, and only appears when targeting a spell with only permitted targets being "Corpses". Perhaps, there is a way to trigger this native errormessage via JASS?

If that is the case, "Must target corpse" can be changed into "<Custom error message>" in the interface editor and displayed to player.
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
I use these functions for displaying custom error messages to a specif player:
  • Trigger
    • Events
    • Conditions
    • Actions
      • Custom script: if udg_ErrorSound == null then
      • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
      • Custom script: endif
      • Set ErrorMessage = Your Message Goes Here
      • Set ErrorPlayer = (YourPlayerNumber)
      • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
      • Custom script: call ClearTextMessages()
      • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
      • Custom script: call StartSound(udg_ErrorSound)
      • Custom script: endif
You need to create a sound variable called "ErrorSound", a player variable called "ErrorPlayer" and an string variable called "ErrorMessage"
 
Status
Not open for further replies.
Top