• 🏆 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] Which function clears Transmission Text Messages?

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Good evening everyone,

I couldnt find this problem anywhere, so I wanted to ask you, if one had the same problem before?

So I created a system, which clears video transmissions for my map. It works pretty good for transmissions, which hide the interface, but it will not clear text messages using
JASS:
call ForceCinematicSubtitles( FALSE)
            call ClearTextMessages()

Is it even possible to clear Transmission Text Messages, which have been added by
JASS:
"Transmission From Unit / Subtitle Override"
?

Here is the code, just in case you are interrested:

JASS:
// System Condition function, which only allows players to ESC cinematiks, when they are allowed to do
function PLAYER_CINEMATIK_CONDITION takes nothing returns boolean
    // find out, which player requests the ESC abbortion of cinematik scene. Look up at Layer 2 of CINEMATIK_DATA[], if player is allowed
    local integer playerId = GetPlayerId( GetTriggerPlayer())
    return udg_CINEMATIK_DATA[playerId+(2*udg_CINEMATIK_DATA[0])+1] == 1
endfunction

// System Action function, which triggers, when players ESC a cinematik and are allowed to do so (CONDITION function)
function PLAYER_CINEMATIK_SKIPP takes nothing returns nothing

     local player SkippingPlayer = GetTriggerPlayer()
     local integer playerId = GetPlayerId( SkippingPlayer)
     local integer MAXPLAYERS = udg_CINEMATIK_DATA[0]
     local integer InterfaceStatus = udg_CINEMATIK_DATA[playerId+MAXPLAYERS+1] // Which Type of transmission?
     local sound CinematikSound
     
     if GetLocalPlayer() == SkippingPlayer then
        
        // End the CinematicSound, if there is any!
        set CinematikSound = udg_GAMEPLAY_SOUND[udg_CINEMATIK_DATA[playerId+(4*MAXPLAYERS)+1]] // Layer 4 of array stored the sound handle for player
        if CinematikSound != null then // End Sound
           call StopSound( CinematikSound, FALSE, TRUE)
           set udg_CINEMATIK_DATA[playerId+(4*MAXPLAYERS)+1] = 0 // reset sound data for player
        endif
        call EndCinematicScene()
        
        if InterfaceStatus == 0 then // Subtitle style
            // Force subtitle transmission to behave as well
            call ForceCinematicSubtitles( FALSE)
            call ClearTextMessages()
        elseif InterfaceStatus == 1 then // normal cinematic style
            // if Player doesnt want to keep the interface for next Transmission
            call ShowInterface( TRUE, 0.00)
        elseif InterfaceStatus == 3 then // just end it now
            // Player wants to end multi transmissions
            call ShowInterface( TRUE, 0.00) 
        endif
        // STORE INTERFACE TO "BEING SKIPPED" in Array
        set udg_CINEMATIK_DATA[playerId+3*(MAXPLAYERS)+1] = 1
        
    endif
     
     // Remove Leaks
     set SkippingPlayer = null
     set CinematikSound = null  
     
endfunction

// Init function, which creates the trigger to skipp cinematiks made by this system via ESC
function INIT_CINEMATIK takes nothing returns nothing
    
    local integer index = 0
    local trigger cinematikTrigger = CreateTrigger()
    local player cinematikPlayer
    
    // create Cinematic Skip function
    loop
        exitwhen index > 3
        // if player is human and playing
        set cinematikPlayer = Player( index)
        if GetPlayerController( cinematikPlayer) == MAP_CONTROL_USER and GetPlayerSlotState( cinematikPlayer) == PLAYER_SLOT_STATE_PLAYING then        
           // increase Player Count udg_CineInteger_DataArray[0]
           set udg_CINEMATIK_DATA[0] = udg_CINEMATIK_DATA[0] + 1
           // Initialize the transmission ESC function 
           call TriggerRegisterPlayerEvent( cinematikTrigger, cinematikPlayer, EVENT_PLAYER_END_CINEMATIC)           
        endif
        set index = index + 1
    endloop
    // Add Trigger Condition, so that it only triggers, when player is in Cinematik Scene set up by this system
    call TriggerAddCondition( cinematikTrigger, function PLAYER_CINEMATIK_CONDITION)
    call TriggerAddAction( cinematikTrigger, function PLAYER_CINEMATIK_SKIPP)
    
    // Remove Leaks
    set cinematikTrigger = null
    set cinematikPlayer = null
    
endfunction

// Main function to call the system
function PLAYER_CINEMATIK takes player p, integer interfaceMod, real fadeDuration1, real fadeDuration2, unit transmissionUnit, string Title, string text, real wait, sound sounddat, integer soundPos, boolean skippable returns nothing
         
    local integer CinematikSkipped
    local integer playerId = GetPlayerId( p)
    local integer TransmissionOn = udg_CINEMATIK_DATA[playerId+1]
    local integer MAXPLAYERS = udg_CINEMATIK_DATA[0]
    local timer TRANSMISSION_WAITING = CreateTimer()
    
    if GetLocalPlayer() == p then
    
    // Do not allow more than one transmission for the same player. Store this in Data_Array
    if TransmissionOn == 0 then
        set udg_CINEMATIK_DATA[playerId+1] = 1 // Lock Transmission status directly after starting this
                
        // interfaceMod of requested transmission
        if interfaceMod == 0 then
            // Subtitles
            call ForceCinematicSubtitles( TRUE)               
            set udg_CINEMATIK_DATA[playerId+MAXPLAYERS+1] = 0
        elseif interfaceMod == 1 then
            // Standard Transmission
            call ShowInterface( FALSE, fadeDuration1)
            set udg_CINEMATIK_DATA[playerId+MAXPLAYERS+1] = 1
        elseif interfaceMod == 2 then
            // interfaceMod == 2 Player wants to keep the interface after the end of the transmission
            call ShowInterface( FALSE, fadeDuration1)
            set udg_CINEMATIK_DATA[playerId+MAXPLAYERS+1] = 2
        elseif interfaceMod == 3 then
            // interfaceMod == 3 dont show the interface, its already on, but hide after this one!
            set udg_CINEMATIK_DATA[playerId+MAXPLAYERS+1] = 3 
        endif
               
        // skippable means, transmission can be skipped entirely for this specific player!
        if skippable then
            set udg_CINEMATIK_DATA[playerId+(2*MAXPLAYERS)+1] = 1 // skippable
        else
            set udg_CINEMATIK_DATA[playerId+(2*MAXPLAYERS)+1] = 0 // not skippable
        endif
               
        // set the cinematic
        set bj_lastTransmissionDuration = wait 
        set bj_lastPlayedSound = sounddat
        set udg_CINEMATIK_DATA[playerId+(4*MAXPLAYERS)+1] = soundPos // Store Array Position in udg_GAMEPLAY_SOUND[] of played sound
        set bj_cineSceneLastSound = sounddat
            
        // action
        if sounddat != null then
            call StartSound( sounddat)
        endif 
        call SetCinematicScene( GetUnitTypeId( transmissionUnit), GetPlayerColor( p), Title, text, bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration)
        call PingMinimap( GetUnitX( transmissionUnit), GetUnitY( transmissionUnit), bj_TRANSMISSION_PING_TIME)
        if IsUnitHidden( transmissionUnit) == FALSE then
            call UnitAddIndicator( transmissionUnit, bj_TRANSMISSION_IND_RED, bj_TRANSMISSION_IND_BLUE, bj_TRANSMISSION_IND_GREEN, bj_TRANSMISSION_IND_ALPHA)
        endif
        
        // wait transmission time           
        call TimerStart( TRANSMISSION_WAITING, bj_lastTransmissionDuration, FALSE, null)
        loop
            set CinematikSkipped = udg_CINEMATIK_DATA[playerId+(3*MAXPLAYERS)+1]
            exitwhen TimerGetRemaining( TRANSMISSION_WAITING) == 0.00 or CinematikSkipped == 1
            call TriggerSleepAction(0.10)
        endloop 
            
        // handle interface Mods, and exit to game interface; dont exit if Mod == 2
        if CinematikSkipped == 0 then // if CinematikSkipped == 1, then transmission was skipped via CINEMATIK_SKIPP function
            if interfaceMod == 0 then
                // end subtitles
                call ForceCinematicSubtitles( FALSE)
                call ClearTextMessages()
            elseif ( interfaceMod == 1 or interfaceMod == 3 ) then 
                // end standard (1) and also final transmission style (3)
                call ShowInterface( TRUE, fadeDuration2)
            endif
        endif
               
        // reset the system for Array Layer 1 and 3 (keep the other values for more transmissions)
        set udg_CINEMATIK_DATA[playerId+1] = 0 // Release Transmission On to Off to allow new transmissions
        set udg_CINEMATIK_DATA[playerId+(3*MAXPLAYERS)+1] = 0 // Release Cinematik Skippable                 
    endif
    
    endif
            
    // Remove Leaks
    call DestroyTimer( TRANSMISSION_WAITING)
    set TRANSMISSION_WAITING = null   
    
endfunction

Thank heaps for any comments! :thumbs_up:
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Try:
call EndCinematicScene()

I actually added this already. The problem was somewhere else, I called the system as being unskippable in this case, so no wonder ... Silly me.

So, Problem solved. :eekani:

Just another short question: Do you think this might be a problem to manipulate global variables inside GetLocalPlayer(), if they are ONLY manipulated uniquly for each player and will never be overriden?

JASS:
if GetLocalPlayer() == SkippingPlayer then
       set udg_CINEMATIK_DATA[SkippingPlayerId+(4*MAXPLAYERS)+1] = 0 
endif


For the records, if anybody needs to end Text Transmissions, it works like this:
JASS:
if GetLocalPlayer() == Player( playerId) then
        call EndCinematicScene()
        call ForceCinematicSubtitles( FALSE)
        call ClearTextMessages()
    endif
 
Status
Not open for further replies.
Top