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

How to create quest to one player without using GetLocalPlayer?

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
Name Explains most
Im trying to create a quest to only one person and I tried GetLocalPlayer but when some1 got the quest everyone else desynced and got d/c

Anyone know a solution to my problem?
Many Thanks!

EDIT: I need to put this into my GUI code so can you guys explain it to me so I can make it custom text?
If it requires vJass tell me...
  • Actions
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
    • Quest - Create a Required quest titled TEST with the description TESTTT, using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
    • Custom script: endif
 
Level 13
Joined
Jun 23, 2009
Messages
300
Name Explains most
Im trying to create a quest to only one person and I tried GetLocalPlayer but when some1 got the quest everyone else desynced and got d/c

Anyone know a solution to my problem?
Many Thanks!

EDIT: I need to put this into my GUI code so can you guys explain it to me so I can make it custom text?
If it requires vJass tell me...

The trigger is fine, I'm sure the Custom script works and all, the desync is caused by the fact that you create the quest only for one player, thus... BOOM!

There is a way using GetLocalPlayer to avoid desyncs, but that method forces you to create a quest for each player, example:

Caution! This creates a quest with title, description and icon only for one player, I don't know what happens when you create a quest with no values for the other players (thing that happens here), so that may bring even more problems

JASS:
function Trig_Caution_Actions takes nothing returns nothing
local string TEST = ""
local string TESTTT = ""
local string TESTIcon = ""
    if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
        set TEST = "Your title"
        set TESTTT = "Your text"
        set TESTIcon = "ReplaceableTextures\\CommandButtons\\BTNAmbush.blp"
    endif
    call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, TEST, TESTTT, TESTIcon)
endfunction

//===========================================================================
function InitTrig_Caution takes nothing returns nothing
    set gg_trg_Caution = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Caution, EVENT_PLAYER_UNIT_SELL_ITEM)
    call TriggerAddAction(gg_trg_Caution, function Trig_Caution_Actions)
endfunction

Either paste it into your map or call all of these actions (and the actions only) using custom scripts if you want to test it.
 
Level 11
Joined
Jun 30, 2008
Messages
580
okay so I tried it on bnet. But it still only works for player red.
What is wrong with the code?
  • Actions
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
    • Quest - Enable Quest[(Player number of (Owner of (Buying unit)))]
    • Custom script: endif
and this is the int part

  • Actions
    • Quest - Create a Required quest titled Message with the description Bring it to the Bla..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
    • Quest - Disable (Last created quest)
    • Set Quest[(Player number of (Picked player))] = (Last created quest)

And yes, the Int is part of a Pick every player in all players trigger, Thats why
  • Set Quest[(Player number of (Picked player))]= (Last created quest)
 
Level 13
Joined
Jun 23, 2009
Messages
300
Wait... with "still works only for Player Red" do you mean it desyncs too or that the GetLocalPlayer thing doesn't work for the others?

If it desyncs, probably it's caused by the fact that you're calling a function (the "Enable Quest" one) only for a player, when the only way to not cause desyncs with GetLocalPlayer is to set values inside that If statement, like a boolean that may be used later to activate the quest or such.

If GetLocalPlayer doesn't work, then the problem must be elsewhere, the triggers you posted here seems fine.

Also... doesn't this enable the same quest to all the players, and not only for the Local player? Check this...
 
Level 13
Joined
Jun 23, 2009
Messages
300
I mean something like this:

  • Actions
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
    • Set QuestBoolean = True
    • Custom script: endif
    • If/Then/Else thingy
      • If - Conditions
        • QuestBoolean = True
      • Then - Actions
        • Quest - Enable Quest[(Player number of (Owner of (Buying unit)))]
      • Else - Actions
It's the only way to be sure it won't cause noticeable desyncs.

Can you post the whole trigger with Events and Conditions? The problem doesn't seem to be in the code you've shown.
 
Level 11
Joined
Jun 30, 2008
Messages
580
  • QuestInt
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Easy Quest Making S...
      • Set PlayerUnits[1] = Paladin 0001 <gen>
      • Set PlayerUnits[2] = Paladin 0023 <gen>
      • -------- ----- --------
      • -------- QuestCatalogStart --------
      • -------- ----- --------
      • Set Quest_Integer = (Quest_Integer + 1)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set A_ARRAY = ((Player number of (Picked player)) + (10 x Quest_Integer))
          • Quest - Create a Required quest titled Message with the description Bring it to the Bla..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
          • Quest - Disable (Last created quest)
          • Set Quest[A_ARRAY] = (Last created quest)

  • QuestOther
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Enquire Quest
    • Actions
      • For each (Integer Loop[1]) from 1 to Quest_Integer, do (Actions)
        • Loop - Actions
          • Set A_QuestOther_ARRAY = ((Player number of (Owner of (Buying unit))) + (10 x Loop[1]))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Quest_Level_Petty[A_QuestOther_ARRAY] Equal to Quest_Level_Petty_Player[(Player number of (Owner of (Buying unit)))]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Quest_Type_Other[A_QuestOther_ARRAY] Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Selling unit) Equal to Quest_Unit[A_QuestOther_ARRAY]
                      • Quest_Int[A_QuestOther_ARRAY] Not equal to Loop[1]
                    • Then - Actions
                      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
                      • Quest - Enable Quest[A_QuestOther_ARRAY]
                      • Custom script: endif
                      • Set Quest_Int[A_QuestOther_ARRAY] = Loop[1]
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Update message: Quest_Message[A_QuestOther_ARRAY]
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Selling unit)) Equal to (Unit-type of Quest_Target[A_QuestOther_ARRAY])
                      • Quest_Int_2[A_QuestOther_ARRAY] Not equal to Loop[1]
                      • Quest_Int[A_QuestOther_ARRAY] Equal to Loop[1]
                    • Then - Actions
                      • Set Quest_Int_2[A_QuestOther_ARRAY] = Loop[1]
                      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
                      • Quest - Disable Quest[A_QuestOther_ARRAY]
                      • Custom script: endif
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Completed message: Quest_Message_Complete[A_QuestOther_ARRAY]
                      • Player - Add Quest_Reward_Copper[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current gold
                      • Player - Add Quest_Reward_Silver[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current lumber
                      • Hero - Add Quest_Reward_Exp[A_QuestOther_ARRAY] experience to PlayerUnits[(Player number of (Owner of (Buying unit)))], Hide level-up graphics
                      • Hero - Create Quest_Reward_Item[A_QuestOther_ARRAY] and give it to PlayerUnits[(Player number of (Owner of (Buying unit)))]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the New Item Received message: ((String(Quest_Reward_Copper[A_QuestOther_ARRAY])) + (Gold, + ((String(Quest_Reward_Silver[A_QuestOther_ARRAY])) + (Lumber, + ((String(Quest_Reward_Exp[A_QuestOther_ARRAY])) + (Exp, and + ((Name of (Last created item)) + recieved!)))))))
                      • Set Quest_Level_Petty[A_QuestOther_ARRAY] = (Quest_Level_Petty[A_QuestOther_ARRAY] + 1)
                      • Set Quest_Level_Petty_Player[(Player number of (Owner of (Buying unit)))] = (Quest_Level_Petty_Player[(Player number of (Owner of (Buying unit)))] + 1)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
      • For each (Integer Loop[2]) from 1 to Quest_Integer, do (Actions)
        • Loop - Actions
          • Set A_QuestOther_ARRAY = ((Player number of (Owner of (Buying unit))) + (10 x Loop[2]))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Quest_Level_Epic[A_QuestOther_ARRAY] Equal to Quest_Level_Epic_Player[(Player number of (Owner of (Buying unit)))]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Quest_Type_Other[A_QuestOther_ARRAY] Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Selling unit) Equal to Quest_Unit[A_QuestOther_ARRAY]
                      • Quest_Int[A_QuestOther_ARRAY] Not equal to Loop[2]
                    • Then - Actions
                      • Set Quest_Int[A_QuestOther_ARRAY] = Loop[2]
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Update message: Quest_Message[A_QuestOther_ARRAY]
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Selling unit)) Equal to (Unit-type of Quest_Target[A_QuestOther_ARRAY])
                      • Quest_Int_2[A_QuestOther_ARRAY] Not equal to Loop[2]
                      • Quest_Int[A_QuestOther_ARRAY] Equal to Loop[2]
                    • Then - Actions
                      • Set Quest_Int_2[A_QuestOther_ARRAY] = Loop[2]
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Completed message: Quest_Message_Complete[A_QuestOther_ARRAY]
                      • Player - Add Quest_Reward_Copper[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current gold
                      • Player - Add Quest_Reward_Silver[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current lumber
                      • Hero - Add Quest_Reward_Exp[A_QuestOther_ARRAY] experience to PlayerUnits[(Player number of (Owner of (Buying unit)))], Hide level-up graphics
                      • Hero - Create Quest_Reward_Item[A_QuestOther_ARRAY] and give it to PlayerUnits[(Player number of (Owner of (Buying unit)))]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the New Item Received message: ((String(Quest_Reward_Copper[A_QuestOther_ARRAY])) + (Gold, + ((String(Quest_Reward_Silver[A_QuestOther_ARRAY])) + (Lumber, + ((String(Quest_Reward_Exp[A_QuestOther_ARRAY])) + (Exp, and + ((Name of (Last created item)) + recieved!)))))))
                      • Set Quest_Level_Epic[A_QuestOther_ARRAY] = (Quest_Level_Epic[A_QuestOther_ARRAY] + 1)
                      • Set Quest_Level_Epic_Player[(Player number of (Owner of (Buying unit)))] = (Quest_Level_Epic_Player[(Player number of (Owner of (Buying unit)))] + 1)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
      • For each (Integer Loop[3]) from 1 to Quest_Integer, do (Actions)
        • Loop - Actions
          • Set A_QuestOther_ARRAY = ((Player number of (Owner of (Buying unit))) + (10 x Loop[3]))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Quest_Level_Story[A_QuestOther_ARRAY] Equal to Quest_Level_Story_Player[(Player number of (Owner of (Buying unit)))]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Quest_Type_Other[A_QuestOther_ARRAY] Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Selling unit) Equal to Quest_Unit[A_QuestOther_ARRAY]
                      • Quest_Int[A_QuestOther_ARRAY] Not equal to Loop[3]
                    • Then - Actions
                      • Set Quest_Int[A_QuestOther_ARRAY] = Loop[3]
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Update message: Quest_Message[A_QuestOther_ARRAY]
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Selling unit)) Equal to (Unit-type of Quest_Target[A_QuestOther_ARRAY])
                      • Quest_Int_2[A_QuestOther_ARRAY] Not equal to Loop[3]
                      • Quest_Int[A_QuestOther_ARRAY] Equal to Loop[3]
                    • Then - Actions
                      • Set Quest_Int_2[A_QuestOther_ARRAY] = Loop[3]
                      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Completed message: Quest_Message_Complete[A_QuestOther_ARRAY]
                      • Player - Add Quest_Reward_Copper[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current gold
                      • Player - Add Quest_Reward_Silver[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current lumber
                      • Hero - Add Quest_Reward_Exp[A_QuestOther_ARRAY] experience to PlayerUnits[(Player number of (Owner of (Buying unit)))], Hide level-up graphics
                      • Hero - Create Quest_Reward_Item[A_QuestOther_ARRAY] and give it to PlayerUnits[(Player number of (Owner of (Buying unit)))]
                      • Quest - Display to (Player group((Owner of (Buying unit)))) the New Item Received message: ((String(Quest_Reward_Copper[A_QuestOther_ARRAY])) + (Gold, + ((String(Quest_Reward_Silver[A_QuestOther_ARRAY])) + (Lumber, + ((String(Quest_Reward_Exp[A_QuestOther_ARRAY])) + (Exp, and + ((Name of (Last created item)) + recieved!)))))))
                      • Set Quest_Level_Story[A_QuestOther_ARRAY] = (Quest_Level_Story[A_QuestOther_ARRAY] + 1)
                      • Set Quest_Level_Story_Player[(Player number of (Owner of (Buying unit)))] = (Quest_Level_Story_Player[(Player number of (Owner of (Buying unit)))] + 1)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
this is the code that makes it that only player red works. Not player 2 or anyone else...
Let me try the code above.
But the thing I don't get about the code above why use GetLocalPlayer anyway? Just make the QuestBoolean a array?
Sigh brb
 
Level 13
Joined
Jun 23, 2009
Messages
300
this is the code that makes it that only player red works. Not player 2 or anyone else...
Let me try the code above.
But the thing I don't get about the code above why use GetLocalPlayer anyway? Just make the QuestBoolean a array?
Sigh brb

Quite a long code, it'll take time to read it. (time that I don't have now)

Why use GetLocalPlayer that way? Whoops, I just noticed it didn't made sense. The best example of how it works, then, is that JASS trigger above :xxd:

EDIT: Ok, for what I've seen, I think the problem is here:
  • If - Conditions
    • (Selling unit) Equal to Quest_Unit[A_QuestOther_ARRAY]
    • Quest_Int[A_QuestOther_ARRAY] Not equal to Loop[1]
    • Then - Actions
      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
      • Quest - Enable Quest[A_QuestOther_ARRAY]
      • Custom script: endif
      • Set Quest_Int[A_QuestOther_ARRAY] = Loop[1]
      • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
      • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
      • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Update message: Quest_Message[A_QuestOther_ARRAY]
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Unit-type of (Selling unit)) Equal to (Unit-type of Quest_Target[A_QuestOther_ARRAY])
        • Quest_Int_2[A_QuestOther_ARRAY] Not equal to Loop[1]
        • Quest_Int[A_QuestOther_ARRAY] Equal to Loop[1]
      • Then - Actions
        • Set Quest_Int_2[A_QuestOther_ARRAY] = Loop[1]
        • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
        • Quest - Disable Quest[A_QuestOther_ARRAY]
        • Custom script: endif
        • Cinematic - Clear the screen of text messages for (Player group((Owner of (Buying unit))))
        • Quest - Display to (Player group((Owner of (Buying unit)))) the Hint message: Quest_Name[A_QuestOther_ARRAY]
        • Quest - Display to (Player group((Owner of (Buying unit)))) the Quest Completed message: Quest_Message_Complete[A_QuestOther_ARRAY]
        • Player - Add Quest_Reward_Copper[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current gold
        • Player - Add Quest_Reward_Silver[A_QuestOther_ARRAY] to (Owner of (Buying unit)) Current lumber
        • Hero - Add Quest_Reward_Exp[A_QuestOther_ARRAY] experience to PlayerUnits[(Player number of (Owner of (Buying unit)))], Hide level-up graphics
        • Hero - Create Quest_Reward_Item[A_QuestOther_ARRAY] and give it to PlayerUnits[(Player number of (Owner of (Buying unit)))]
        • Quest - Display to (Player group((Owner of (Buying unit)))) the New Item Received message: ((String(Quest_Reward_Copper[A_QuestOther_ARRAY])) + (Gold, + ((String(Quest_Reward_Silver[A_QuestOther_ARRAY])) + (Lumber, + ((String(Quest_Reward_Exp[A_QuestOther_ARRAY])) + (Exp, and + ((Name of (Last created item)) + recieved!)))))))
        • Set Quest_Level_Petty[A_QuestOther_ARRAY] = (Quest_Level_Petty[A_QuestOther_ARRAY] + 1)
        • Set Quest_Level_Petty_Player[(Player number of (Owner of (Buying unit)))] = (Quest_Level_Petty_Player[(Player number of (Owner of (Buying unit)))] + 1)
      • Else - Actions
The second If/Then/Else statement seems to become true as soon as the first one acts.
(Maybe Quest_Int_2[A_QuestOther_ARRAY] equals Loop[1] only for the first player)

Also, "Quest_Integer" value is always one
 
Status
Not open for further replies.
Top