Help with TriggerRegisterPlayerChatEvent

DioD

New Member
Reaction score
57
you are missing private in your sample, without private keyword no scope or library apply.

after you fixed your sample, it wont work, cos A is now A__A
 

priest170234

New Member
Reaction score
0
I am still stuck. I checked my triggers, compiled correctly. When I type the correct string, the trigger does not execute my actions! Anyone help me check my script! Please! I know I am very close to getting it.

TRIGGER ONE [PW]
JASS:
scope pw initializer onInit

globals
    string STRING
    string array RANDOM_STRING[2]
    integer RANDOM_INTEGER
endglobals

private function pw_Conditions takes nothing returns boolean
    if ( not ( GetEnteringUnit() == udg_UNIT ) ) then
        return false
    endif
    return true
endfunction

function pw_Actions takes nothing returns nothing
    set RANDOM_STRING[1] = "lol"
    set RANDOM_STRING[2] = "lolol"
    set RANDOM_INTEGER = GetRandomInt(1,2)
    
    set STRING = RANDOM_STRING[RANDOM_INTEGER]
    
    call DisableTrigger( GetTriggeringTrigger() )
    call IssueImmediateOrder( udg_UNIT, "stop" )
    call CreateQuestBJ( bj_QUESTTYPE_REQ_DISCOVERED, "PASSWORD", ( "The password is : " + STRING ), "ReplaceableTextures\\WorldEditUI\\Editor-Random-Unit.blp" )
    call EnableTrigger( gg_trg_PWT )
    call DisplayTextToForce( GetPlayersAll(), STRING )
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

//===========================================================================
private function onInit takes nothing returns nothing

    local trigger t = CreateTrigger()

    call TriggerRegisterEnterRectSimple( t, gg_rct_PasswordQuest )
    call TriggerAddCondition( t, Condition( function pw_Conditions ) )
    call TriggerAddAction( t, function pw_Actions )
endfunction

endscope



TRIGGER TWO [PWT]
JASS:
scope pwt

function pwtactions takes nothing returns nothing
    call DisableTrigger( GetTriggeringTrigger() )
    set udg_TempPoint[1] = GetRectCenter(gg_rct_PaswordQuestTerain)
    call SetTerrainTypeBJ( udg_TempPoint[1], 'Ydrt', -1, 1, 0 )
    call DestroyQuest( GetLastCreatedQuestBJ() )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Correct" )
    call RemoveLocation(udg_TempPoint[1])
endfunction

function InitTrig_onInits takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i
    
    loop 
        exitwhen i>11
        call TriggerRegisterPlayerChatEvent(t, Player(i), STRING, true)   
        set i=i+1
    endloop
    
    call TriggerAddAction(t, function pwtactions)
endfunction

endscope


Okay, the quest in the first trigger shows the description properly.
The
JASS:

shows the exact thing as in shown in the quest description. I am quite sure there isn't a problem with TRIGGER ONE.

Someone help me, correct me and try to guide me as well, I am trying to learn JASS as soon as possible!:)
 

Laiev

Hey Listen!!
Reaction score
188
JassHelperManual said:
Private members

With the adition of libraries it was a good idea to add some scope control, private members are a great way of protecting users from themselves and to avoid collisions.

The scope keyword has this syntax: scope NAME [...script block...] endscope

So, functions and other declarations inside an scope can freely use the private members of the scope, but code outside won't be able to.

Also, its a example, not what he should do.
 

priest170234

New Member
Reaction score
0
YES! I got it at last! I re made the triggers. I have three triggers now, for easy editing and so on.

TRIGGER ONE [Global Declaration]
JASS:
scope global initializer init

globals
    string STRING
    integer RANDOM_INTEGER
    string array RANDOM_STRING[2]
endglobals

private function init takes nothing returns nothing
    set RANDOM_STRING[0] = "lol"
    set RANDOM_STRING[1] = "lolol"
    set RANDOM_INTEGER = GetRandomInt(0,1)
    set STRING = RANDOM_STRING[RANDOM_INTEGER]
endfunction

endscope


TRIGGER TWO[PW]
JASS:
scope pw initializer onInit

private function pw_Conditions takes nothing returns boolean
    if ( not ( GetEnteringUnit() == udg_ChosenHero ) ) then
        return false
    endif
    return true
endfunction

function pw_Actions takes nothing returns nothing
    
    call DisableTrigger( GetTriggeringTrigger() )
    call IssueImmediateOrder( udg_ChosenHero, "stop" )
    call CreateQuestBJ( bj_QUESTTYPE_REQ_DISCOVERED, "PASSWORD", ( "The password is : " + STRING ), "ReplaceableTextures\\WorldEditUI\\Editor-Random-Unit.blp" )
    call EnableTrigger(gg_trg_p)
    call DisplayTextToForce( GetPlayersAll(), STRING )
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

//===========================================================================
private function onInit takes nothing returns nothing

    local trigger t = CreateTrigger()

    call TriggerRegisterEnterRectSimple( t, gg_rct_PasswordQuest )
    call TriggerAddCondition( t, Condition( function pw_Conditions ) )
    call TriggerAddAction( t, function pw_Actions )
endfunction

endscope



TRIGGER THREE [p]
JASS:
function Trig_p_Actions takes nothing returns nothing
    call DisableTrigger( GetTriggeringTrigger() )
    set udg_TempPoint[1] = GetRectCenter(gg_rct_PaswordQuestTerain)
    call SetTerrainTypeBJ( udg_TempPoint[1], 'Ydrt', -1, 1, 0 )
    call DestroyQuest( GetLastCreatedQuestBJ() )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Correct" )
    call RemoveLocation(udg_TempPoint[1])
endfunction

//===========================================================================
function InitTrig_p takes nothing returns nothing
    set gg_trg_p = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent(gg_trg_p, Player(0), STRING, true) 
    call TriggerAddAction( gg_trg_p, function Trig_p_Actions )
endfunction



Thanks a whole bunch to all who helped me (directly or indirectly) and will give reputation to them!

Conclusion:
This is the first time I am using JASS in my maps, and is learning fast from examples!
Once again , thanks a lot! :D
 

Bribe

vJass errors are legion
Reaction score
67
JASS:

scope password initializer init
    
    globals
        private trigger Trigger = CreateTrigger()
        private region Region = CreateRegion()
        private quest Quest // Don't rely on something like GetLastCreatedQuest()
    endglobals
    
    private function onChat takes nothing returns boolean
        call SetTerrainType(GetRectCenterX(gg_rct_PaswordQuestTerain), GetRectCenterY(gg_rct_PaswordQuestTerain), 'Ydrt', -1, 1, 0)
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 5., "Correct")
        // ----
        // Clear leaks
        call DestroyTrigger(GetTriggeringTrigger())
        call DestroyQuest(Quest)
        call RemoveRect(gg_rct_PaswordQuestTerain)
        set gg_rct_PaswordQuestTerain = null
        set Quest = null
        return false
    endfunction
    
    private function onEnter takes nothing returns boolean
        local string s
        local trigger t
        if GetFilterUnit() == udg_ChosenHero then
            call IssueImmediateOrder(udg_ChosenHero, "stop")
            if GetRandomInt(1, 2) == 1 then
                set s = "lol"
            else
                set s = "lolol"
            endif
            call DisplayTextToPlayer(GetLocalPlayer(), 0., 0., s)
            set Quest = CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, "PASSWORD", "The password is : " + s, "ReplaceableTextures\\WorldEditUI\\Editor-Random-Unit.blp")
            set t = CreateTrigger()
            call TriggerRegisterPlayerChatEvent(t, Player(0), s, true) 
            call TriggerAddCondition(t, Condition(function onChat))
            // ----
            // Clear leaks
            call DestroyTrigger(Trigger)
            call RemoveRegion(Region)
            set Trigger = null
            set Region = null
            set t = null
        endif
        return false
    endfunction
    
    private function init takes nothing returns nothing
        call RegionAddRect(Region, gg_rct_PasswordQuest)
        call TriggerRegisterEnterRegion(Trigger, Region, Condition(function onEnter))
        // ----
        // Clear leaks
        call RemoveRect(gg_rct_PasswordQuest)
        set gg_rct_PasswordQuest = null
    endfunction
    
endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top