Help with TriggerRegisterPlayerChatEvent

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
 
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!:)
 
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.
 
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
 
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.
  • Varine Varine:
    Turns out it wasn't me and it wasn't E Coli, which I was sure it wasn't. But still very stressful. Do not recommend fucking with the CDC.
  • Varine Varine:
    I think the worst was the IRS. We got audited once and they show up with like guns and shit, because I guess the IRS is technically a police force?
  • Varine Varine:
    They had a gun and it was very unnerving.
  • Varine Varine:
    I looked up why and it does make sense though. I forget they are the ones that deal with like mafias and shit, and not everyone is going to be very considerate about being told they need to explain and prove where their money comes from. We'
  • Varine Varine:
    We are pretty good about it I think. Not my job, but the people that do it are pretty one top of it.
  • The Helper The Helper:
    yeah I dont like the government. I am a total libertarian and what you are describing is what I am totally against when it comes to governing
  • Varine Varine:
    I mean I don't really like the government. But I would also prefer to have one than... not have any government. Like we need to have police forces and national welfare systems, but I don't think the cop that is pulling you over for speeding is the same cop that should also be responding to active terror events.
  • The Helper The Helper:
    I am talking about federal.
  • The Helper The Helper:
    State and local elections I believe in when it comes to governing. Of course the military
  • The Helper The Helper:
    Federal should do military
  • The Helper The Helper:
    The federal government should do the military not the police. I hope Trump gets rid of the income tax
  • The Helper The Helper:
    I hold no hope of Trump getting rid of income tax though.
  • jonas jonas:
    Trump is a wildcard, but in the end, it's the republican party that makes the laws, Trump can only do exec orders
  • jonas jonas:
    I don't think the Republicans will get rid of income tax, at most lower it a little, mostly for people with 6 figures+. But that's just my opinion
  • The Helper The Helper:
    one can dream
  • Ghan Ghan:
    FairTax would be nice.
  • Ghan Ghan:
    But the electorate would have to demand it and vote people in to do it.
  • Ghan Ghan:
    Government spending, foreign policy, and the southern border are all bigger issues than the income tax right now I'd say.
  • The Helper The Helper:
    For you those are the bigger issues. Cannabis legalization and get rid of Income tax are mine.
  • Ghan Ghan:
    We have so much cannabis up here in Oklahoma. Can't go a block without running into 3 dispensaries. xD
  • The Helper The Helper:
    if the demand is there
  • jonas jonas:
    I think the biggest issue in USA is how divided the country has become
  • Ghan Ghan:
    There's a big split happening in fundamental values that is very worrisome.
  • jonas jonas:
    I think there's always been a split in values. But now there's a split in what reality is. No matter whom you ask, they think a third of the country is insane and wants to destroy the country
  • The Helper The Helper:
    pretty big split

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top