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

Timer: make repeating Text MUI

Status
Not open for further replies.
Level 2
Joined
Mar 14, 2011
Messages
9
Heho,
short and simple: can you tell me how to make this MUI?

JASS:
library TimedText initializer Init

globals
    private timer Timer1
    private timer Timer2
    private string String
    private player OwningPlayer
endglobals

private function Destroy takes nothing returns nothing

    call PauseTimer(Timer2)
    set Timer1 = null
    set Timer2 = null
    
endfunction

private function Callback takes nothing returns nothing

    call DisplayTimedTextToPlayer(OwningPlayer, 0, 0, 0.75, String) 
    
endfunction

public function Start takes string TEXT, real DURATION, player OWNINGPLAYER returns nothing
    set Timer1 = CreateTimer()
    set Timer2 = CreateTimer()

    set String = TEXT
    set OwningPlayer = OWNINGPLAYER
    
    call TimerStart(Timer1, DURATION, false, function Destroy)
    call TimerStart(Timer2, 1.0, true, function Callback)
    
endfunction

private function Init takes nothing returns nothing
endfunction

endlibrary

Thanks
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You're asking how to make a player-based function MUI... that doesn't make any sense.

Note the DisplayTimedTextToPlayer...what are you looking for a DisplayTimedTextToUnit?

Not to mention you leak two timers every time you call the Start function because you create two handles but do not destroy them.

This just doesn't make any sense to me. You have to elaborate immensely.

DarcRanger said:
Can you make this function MUI for me?

JASS:
native SetPlayerName takes player whichPlayer, string name returns nothing
 
The easiest way is to create dummy unit and use it's handle as hashtable father key.
It's safe but not so fast like some indexing system.

Also you have some unuseed functions and you should use UPPERCASE for globals :)
Last thing is TAB, inline code :)

+

Horrible example for your question, I guess that you want to learn how to use local variables from 1 function in another that can't take them but it's called like for ForGroup or TimerStart functions.
 
Level 2
Joined
Mar 14, 2011
Messages
9
The problem is, when I call this function again within the duration of the first call, the second call will not work or rather pause the Timer2

I dont want to learn how to use locals in TimerStart functions.

Is this possible with structs? The problem is that I cant operate with structs ...

I read many guides about Timers, and always they say, that you not have to destroy Timers anymore
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Ohhhhhhhhhhhhhhhhhh.

I read many guides about Timers, and always they say, that you not have to destroy Timers anymore

That is nonsense.

On to the problem, you're actually looking for MPI (multi-player instantiability) because only palyers can have the messages displayed to them. Anyhow, in order to that you're going to need an array of timers. Then just use the Player's ID as an index for the array and bam, you're done.

If you need to have multiple timers per player, then you would have to use this EQUATION:

JASS:
INDEX = PLAYER ID (multiplied by) TIMERS PER PLAYER (plus) WHICH TIMER
 
JASS:
library TimedTextYeah initializer BitchPlease

    globals
        private timer array    T
        private string array   MSG
        private boolean array  B
        
        private real array     LOOP           //Defaul timer loop
        private real array     MAX_LOOP       //MAX_LOOP/LOOP = How many times we show msg
    endglobals

    private function UMad takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i>12
            if B[i] then
                call DisplayTimedTextToPlayer(Player(i),0,0,3,MSG[i])
                set MAX_LOOP[i] = MAX_LOOP[i] - LOOP[i]
                if MAX_LOOP[i] < 0 then
                    set B[i] = false
                    set MAX_LOOP[i] = 5.
                endif
            endif
            set i=i+1
        endloop
    endfunction

    function DisplayShitz takes string s, real d, player p returns nothing
        local integer id = GetPlayerId(p)
        if B[id] then
            call DisplayTimedTextToPlayer(p,0,0,3,"Trigger is already ON, you blind?")
            return
        endif
        
        set MSG[id]      = s
        set B[id]        = true
        set MAX_LOOP[id] = 5.
        set LOOP[id]     = d
        call TimerStart(T[id], d, true, function UMad)
    endfunction

    private function BitchPlease takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i>12
            set T[i]        = CreateTimer()
            set B[i]        = false
            set MAX_LOOP[i] = 5
            set i=i+1
        endloop
        call BJDebugMsg("Hi there you silly one :P")
    endfunction

endlibrary
  • Sex
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: call DisplayShitz("DEFAULT STRING YOU TURD: Are you " + GetPlayerName(GetTriggerPlayer()) + " insane, WTF IS THIS SHIT?", 1., Player(0))
There you go, work like a charm :)
 

Attachments

  • aaa.w3x
    16.9 KB · Views: 49
Level 2
Joined
Mar 14, 2011
Messages
9
This is really cool .. but with that i can't show 2 or more loops of texts at the same time ;(
Ingame it should look like:


[Sec 1.0] text1
[Sec 1.0] text2
[Sec 2.0] text1
[Sec 2.0] text2
[Sec 3.0] text1
[Sec 3.0] text2
and so on

I could merge text1 and text2 if it is too difficult. I thought it would be easier -.-
 
Well because this if B[i] then won't allow same player to run function 2 times at same time, remove B variable and it will work.
Oh and it's possible for 2 players to run this at same time, yes yes.

Try with:

  • Sex
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: call DisplayShitz("DEFAULT STRING YOU TURD: Are you " + GetPlayerName(GetTriggerPlayer()) + " insane, WTF IS THIS SHIT?", 1., Player(0))
      • Custom script: call DisplayShitz("DEFAULT STRING YOU TURD: Are you " + "Player 2" + " insane, WTF IS THIS SHIT?", 1., Player(1))
      • Custom script: call DisplayShitz("DEFAULT STRING YOU TURD: Are you " + "Player 3" + " insane, WTF IS THIS SHIT?", 1., Player(2))
if you see 3 messages at once it work for first 3 players.
 
Status
Not open for further replies.
Top