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

[Trigger] Custom Script error

Status
Not open for further replies.
Level 10
Joined
Dec 17, 2011
Messages
347
Hi!

Whats wrong with this? Wc3 cannot run with this script.
Plz help!

Oh and the variable name is fine.

  • Item Sold
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Set Sold_Item = (Sold Item)
      • Set BuyerPlayer = (Owner of Sold_Item)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of Sold_Item) Equal to |c00FFD84FAnub'Rekhan's Legacy|r
              • (Item-type of Sold_Item) Equal to |c00FFFF00Horn of Winter|r
              • (Item-type of Sold_Item) Equal to |c00FFD84FClaw of the Sandreaver|r
              • (Item-type of Sold_Item) Equal to |c00FFD84FGoblin Rocket Louncher|r
        • Then - Actions
          • Custom script: if GetLocalPlayer() == udg_BuyerPlayer then
          • Custom script: call PlaySound(udg_PutDownSmallMEtal , true)
          • Custom script: call endif
        • Else - Actions
          • -------- Some other things here --------
 
Level 19
Joined
Jul 14, 2011
Messages
875
PlaySound takes just one argument.
JASS:
function PlaySound takes string soundName returns nothing
    local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
    call StartSound(soundHandle)
    call KillSoundWhenDone(soundHandle)
endfunction

udg_PutDownSmallMEtal should be a string, in your case.

PlaySoundBJ takes a variable. If PutDownSmallMEtal is a variable (from the sound editor) you should use gg_snd_<Sound Name Here>.
StartSound is the same as the above, but it doesnt check if the variable is nulled.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
You are using...
JASS:
function PlaySound takes string soundName returns nothing
    local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
    call StartSound(soundHandle)
    call KillSoundWhenDone(soundHandle)
endfunction

So...

JASS:
if GetLocalPlayer() == udg_BuyerPlayer then // Perfect
call PlaySound(udg_PutDownSmallMEtal , true) // No such function definition, the function with that name expects exactly 1 argument of type string.
call endif // endif is a key word so cannot be a function definition, functions also need arguments even if they are no arguments "()", you probably meant just "endif".
 
Status
Not open for further replies.
Top