• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How do I create my own error message, such as "Need more gold.", but on spell cast?

Status
Not open for further replies.
Level 2
Joined
Jan 5, 2008
Messages
9
The title basically asks the main question of this thread; I'd like to be able to know how to create an error message when a spell is cast and doesnt meet up to the conditions. An example would be in dota; the Lone Druid's summon spirit bear ability. When you cast it while a spirit bear is already summoned, it shows an error message saying "Spirit Bear is already summoned"
 
Level 11
Joined
Feb 22, 2006
Messages
752
JASS:
function Error_Msg 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
 
Level 12
Joined
Mar 16, 2006
Messages
992
JASS:
function Error_Msg 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

Yes, there is this.

There's also the display error message trigger.
 
Level 11
Joined
Feb 22, 2006
Messages
752
There's a difference.

The simulated error script I put up actually simulates wc3's error messages, like those messages that go "Not enough resources" and stuff like that in melee games. (only of course these don't come with the voice speaking the message, though it does make the error sound) It's basically like SimError. Drawback: it erases all text messages on the screen - only way to get the error message in the center of the screen like with real blizz error messages.

Your way is more common and will simply display some text on the near bottom left-hand side of the screen where player chat text shows up.
 
Level 2
Joined
Jan 5, 2008
Messages
9
Ah thanks for that script, the only problem is, I'm still in the early stages of learning Jass and don't know how to manipulate this script to get the owner of the casting unit, or setup the events and conditions in Jass.

Sorry to ask but if its not too much trouble, I'd really appreciate if you could setup a full trigger for me with highlighted areas that I need to edit. It would need to detect when a unit begins casting a spell, then check to see what spell it is, then display the error message for the owner of the casting unit, and I'm pretty sure I know where to put in the string for the message itself. Or if you could give me a gui version of this if such a thing exsists.

Either or I'd really appreciate it, in the meantime I'm going to keep trying to figure it out lol
 
Level 12
Joined
Mar 16, 2006
Messages
992
There's a difference.

The simulated error script I put up actually simulates wc3's error messages, like those messages that go "Not enough resources" and stuff like that in melee games. (only of course these don't come with the voice speaking the message, though it does make the error sound) It's basically like SimError. Drawback: it erases all text messages on the screen - only way to get the error message in the center of the screen like with real blizz error messages.

Your way is more common and will simply display some text on the near bottom left-hand side of the screen where player chat text shows up.

Yeah, I prefer yours, but the whole clearing the screen is :(
 
Level 11
Joined
Feb 22, 2006
Messages
752
Aeline said:
Ah thanks for that script, the only problem is, I'm still in the early stages of learning Jass and don't know how to manipulate this script to get the owner of the casting unit, or setup the events and conditions in Jass.

Well, it's really simple. You don't need full JASS triggers to use the function. Treat it like a GUI action, and whenever you want to call it, simply make a GUI Custom Script Action (under Actions -> General) and type in something like:

Code:
call Error_Msg( GetOwningPlayer( GetTriggerUnit() ), "Your message" )

The above would result in a message with the text "Your message" (without the quotations) being displayed to the owning player of a triggering unit of some trigger event (presumably Unit Beings Casting an Ability from what you've described). Of course, you can make it display to any player and display any text. Just make sure text is within quotes.
 
Level 2
Joined
Jan 5, 2008
Messages
9
When I try to use that line, it turns off the trigger I used it in when I try to test the map, and says "Expected Function Name".. so I don't what the problem is lol, I don't know anything about Jass really so I'll just try to find a way to do it in gui, none of this stuff works for me lol, thanks though.
 
Status
Not open for further replies.
Top