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

[Solved] Message does not display

Status
Not open for further replies.
Level 16
Joined
Jul 31, 2012
Messages
2,217
Hello guys, my problem is simple, this function:
JASS:
call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: " + LoadStringBJ(1, GetRandomInt(1, 5), udg_Chat_Data) ) )
Does not display any text, weirdly other calls of the function in other places in the trigger does display text normally, i tried to change the text displayed, but there was no clue
The function is at the end of this trigger:
JASS:
function Chat_is_String_in_Library takes string S, integer x returns boolean
    return ( SubString(S, 0, StringLength(LoadStringBJ(x, 0, udg_Chat_Library))) == LoadStringBJ(x, 0, udg_Chat_Library) )
    endfunction

function GetSlengthRatio takes integer x returns real
    local real y = ( I2R(x) / 12.5 )
    if ( y > 2.00 ) == true then
        set y = 2.00
    endif
    return y
endfunction

function Trig_Chat_Actions takes nothing returns nothing
    local integer x = 1
    local integer x1
    local string S = GetEventPlayerChatString()
    local boolean Answered = false
    call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cffffffff" + LoadStringBJ(0, 0, udg_Chat_Data) + ":|r " + S ) )
    loop
        exitwhen x > LoadIntegerBJ(0, 0, udg_Chat_Library)
        if ( Chat_is_String_in_Library(S, x) ) then
            if ( GetBooleanOr( LoadIntegerBJ(1, 0, udg_Chat_Data) == LoadIntegerBJ(x, 99, udg_Chat_Library), 0 == LoadIntegerBJ(x, 99, udg_Chat_Library) ) ) then
                call TriggerSleepAction( GetRandomReal(0.5, ( GetSlengthRatio(StringLength(S)) - 0.5 )) )
                call SaveIntegerBJ(x, 1, 0, udg_Chat_Data)
                call StartSound( gg_snd_Tri_Tone )
                set x1 = GetRandomInt(2, 1 + LoadIntegerBJ(x, 1, udg_Chat_Library))
                if not ( LoadStringBJ(x, GetRandomInt(2, 1 + LoadIntegerBJ(x, 1, udg_Chat_Library)), udg_Chat_Library) == "") then
                    call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: " + LoadStringBJ(x, x1, udg_Chat_Library) ) )
                endif
                set Answered = true
                if ( x == 5 ) then
                    if not ( SubString(S, 11, 50) == "" ) then
                        call SaveStringBJ( SubString(S, 11, 50), 0, 0, udg_Chat_Data )
                    endif
                endif
                if ( x == 17 ) then
                    if not ( LoadStringBJ(0, 0, udg_Chat_Data) == "You" ) then
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Yes, you are " + LoadStringBJ(0, 0, udg_Chat_Data) ) )
                    else
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Actually;.. No" ) )
                    endif
                endif
                if ( GetBooleanOr( x == 20, x == 21 ) ) then
                    if not ( LoadStringBJ(0, 0, udg_Chat_Data) == "You" ) then
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Yes, you are " + LoadStringBJ(0, 0, udg_Chat_Data) ) )
                    else
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Sorry, I don't know :(" ) )
                    endif
                endif
                if ( x == 25 ) then
                    call TriggerSleepAction( 1.0 )
                    call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Bye!" ) )
                    call StartSound( gg_snd_Tri_Tone )
                    call TriggerSleepAction( 0.1 )
                    call TriggerExecute( gg_trg_End_Chat )
                endif
                if ( x == 26 ) then
                    call DisableTrigger( GetTriggeringTrigger() )
                endif
                if ( x == 27 ) then
                    if not ( SubString(S, 11, 50) == "" ) then
                        call SaveStringBJ( SubString(S, 10, 50), 0, 1, udg_Chat_Data )
                    endif
                endif
                if ( x == 40 ) then
                    if not ( LoadStringBJ(0, 1, udg_Chat_Data) == "" ) then
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: You are in " + LoadStringBJ(0, 1, udg_Chat_Data) ) )
                    else
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Sorry, I don't know :(" ) )
                    endif
                endif
                if ( x == 41 ) then
                    if not ( LoadStringBJ(0, 1, udg_Chat_Data) == "" ) then
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: You live in " + LoadStringBJ(0, 1, udg_Chat_Data) ) )
                    else
                        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: Sorry, I don't know where :(" ) )
                    endif
                endif
                set x = x + LoadIntegerBJ(0, 0, udg_Chat_Library)
            endif
        endif
        set x = x + 1
    endloop
    if ( Answered ) == false then
        call TriggerSleepAction( GetRandomReal(1.0, ( GetSlengthRatio(StringLength(S)) + 1 )) )
        call StartSound( gg_snd_Tri_Tone )
        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: " + LoadStringBJ(1, GetRandomInt(1, 5), udg_Chat_Data) ) )
    endif
    set S = ""
endfunction

//===========================================================================
function InitTrig_Chat takes nothing returns nothing
    local trigger Chat = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( Chat, Player(0), "", false )
    call TriggerAddAction( Chat, function Trig_Chat_Actions )
    set Chat = null
endfunction
 
Last edited by a moderator:
Change this:
JASS:
if ( Answered ) == false then
        call TriggerSleepAction( GetRandomReal(1.0, ( GetSlengthRatio(StringLength(S)) + 1 )) )
        call StartSound( gg_snd_Tri_Tone )
        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: " + LoadStringBJ(1, GetRandomInt(1, 5), udg_Chat_Data) ) )
    endif
To this:
JASS:
    call BJDebugMsg("-- Evaluating Answered --")
    if ( Answered ) == false then
        call BJDebugMsg("-- Answered is false --")
        call TriggerSleepAction( GetRandomReal(1.0, ( GetSlengthRatio(StringLength(S)) + 1 )) )
        call StartSound( gg_snd_Tri_Tone )
        call DisplayTimedTextToForce( GetPlayersAll(), 99999, ( "|cff00ff00AI: " + LoadStringBJ(1, GetRandomInt(1, 5), udg_Chat_Data) ) )
        call BJDebugMsg("-- Message displayed --")
    endif
    call BJDebugMsg("-- if block ended --")

And then report back with whatever messages are displayed. It might be that the code doesn't even reach the if-block.
 
Status
Not open for further replies.
Top