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

[Solved] Custom Script not working

Status
Not open for further replies.
Level 8
Joined
Jul 29, 2010
Messages
319
I'm not that great with scripts and jass so i pretty much have no idea what i'm doing, what have i done wrong here (Custom script line)
  • AIR STRIKE
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Air Strike (Dummy)
    • Actions
      • Custom script: call PlaySoundForPlayer( gg_snd_AirStrike1, udg_snd_TriggeringPlayer )
      • Unit - Create 1 Dummy Unit (Dummy) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Target point of ability being cast)
      • Unit - Add Air Strike to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard (Target point of ability being cast)
      • Unit - Add a 5.00 second Water Elemental expiration timer to (Last created unit)
 
thanks :D

EDIT:it gave an error, says "Expected a Function Name" :/

If there is no function called PlaySoundForPlayer you need to add something like this in your maps header:

JASS:
function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
    if ( whichPlayer == GetLocalPlayer() ) then
        call PlaySoundBJ( whichSound )
    endif
endfunction
 
Level 8
Joined
Jul 29, 2010
Messages
319
If there is no function called PlaySoundForPlayer you need to add something like this in your maps header:

JASS:
function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
    if ( whichPlayer == GetLocalPlayer() ) then
        call PlaySoundBJ( whichSound )
    endif
endfunction
i think i'll just not have the sound effect, all of this is wayy beyond me, i don't even know what to do with that script you just gave me hahaha

EDIT: This is a post from another thread about this but i don't understand it at all.

"function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
if ( whichPlayer == GetLocalPlayer() ) then
call PlaySoundBJ( whichSound )
endif
endfunction

or just:
Custom script: call PlaySoundForPlayer( gg_snd_YourSound, udg_snd_YourPlayer )"
 
Last edited:
Level 10
Joined
Sep 16, 2016
Messages
269
JASS:
function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
if ( whichPlayer == GetLocalPlayer() ) then
call PlaySoundBJ( whichSound )
endif
endfunction
Copy this part of to the map header (the wide blank space when you click map'symbol) on top of trigger lists. You can use it normally in customscript.
 
Level 8
Joined
Jul 29, 2010
Messages
319
JASS:
function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
if ( whichPlayer == GetLocalPlayer() ) then
call PlaySoundBJ( whichSound )
endif
endfunction
Copy this part of to the map header (the wide blank space when you click map'symbol) on top of trigger lists. You can use it normally in customscript.

i did that, and tried the custom script with my trigger and still will not work, just to clarify i copy

JASS:
function PlaySoundForPlayer takes player whichPlayer, sound whichSound returns nothing
if ( whichPlayer == GetLocalPlayer() ) then
call PlaySoundBJ( whichSound )
endif
endfunction
by clicking the map icon,then paste it into custom script code, then put this in a trigger
  • Custom script: call PlaySoundForPlayer(gg_snd_AirStrike1, GetOwningPlayer(GetTriggerUnit()))
because i did that and i got an error saying " invalid argument type (player) "
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
I find this a little easier to use, because its more GUI friendly.

  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
  • Sound - Play ArmoryWhatSound <gen>
  • Custom script: endif
The first custom script specifies which player actions will be taken on. The second custom script tells it when to stop making actions on a specific player. Basically put whatever GUI code in between the 2 custom scripts and your good to go. No header information needed.

You could also use these custom scripts to play fade filters for specific players, create weather effects for specific players, etc. Careful not to do anything local to a specific player that will affect everyone. Example, damaging a unit, or moving a unit. These things cause desyncs. You should only do local things that don't affect gameplay, like weather, messages, sound, cameras, fade filters, etc.
 
Level 8
Joined
Jul 29, 2010
Messages
319
I find this a little easier to use, because its more GUI friendly.

  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
  • Sound - Play ArmoryWhatSound <gen>
  • Custom script: endif
The first custom script specifies which player actions will be taken on. The second custom script tells it when to stop making actions on a specific player. Basically put whatever GUI code in between the 2 custom scripts and your good to go. No header information needed.

You could also use these custom scripts to play fade filters for specific players, create weather effects for specific players, etc. Careful not to do anything local to a specific player that will affect everyone. Example, damaging a unit, or moving a unit. These things cause desyncs. You should only do local things that don't affect gameplay, like weather, messages, sound, cameras, fade filters, etc.
Thanks for the info man, and if you don't mind me asking, what's a desync?
 
Thanks for the info man, and if you don't mind me asking, what's a desync?

Usually we use "desync" to refer to "disconnects". When you run code "locally" using GetLocalPlayer(), it only gets run for that specific player. But when you play online, wc3 won't allow certain actions to be ran locally.

For example, if you use GetLocalPlayer() to kill a unit for Player 1, wc3 will realize that the unit is dead only for Player 1, but alive for all the other players. As you can imagine, that situation can get pretty messy. What if that unit attacks someone? What if he dies again? As soon as the wc3 engine spots an inconsistency like that, it'll panic and start disconnecting players to try to get things back to a consistent state.

But wc3 can only check for synchronicity for certain things. It doesn't care whether you guys are listening to the same music at the same time. But it does care about what is actually happening in the game, especially with units. So when you use GetLocalPlayer(), you just need to work around wc3's engine. You usually can't create and destroy stuff locally, but you can use certain tricks to achieve the same thing (e.g. showing/hiding objects) without causing players to disconnect. :)

If you want more info, here is an old tutorial about it:
JASS: GetLocalPlayer() | The Helper
 
Level 8
Joined
Jul 29, 2010
Messages
319
Usually we use "desync" to refer to "disconnects". When you run code "locally" using GetLocalPlayer(), it only gets run for that specific player. But when you play online, wc3 won't allow certain actions to be ran locally.

For example, if you use GetLocalPlayer() to kill a unit for Player 1, wc3 will realize that the unit is dead only for Player 1, but alive for all the other players. As you can imagine, that situation can get pretty messy. What if that unit attacks someone? What if he dies again? As soon as the wc3 engine spots an inconsistency like that, it'll panic and start disconnecting players to try to get things back to a consistent state.

But wc3 can only check for synchronicity for certain things. It doesn't care whether you guys are listening to the same music at the same time. But it does care about what is actually happening in the game, especially with units. So when you use GetLocalPlayer(), you just need to work around wc3's engine. You usually can't create and destroy stuff locally, but you can use certain tricks to achieve the same thing (e.g. showing/hiding objects) without causing players to disconnect. :)

If you want more info, here is an old tutorial about it:
JASS: GetLocalPlayer() | The Helper
that actually sounds like some fun game modes could be achieved, hiding certain objects for certain players and such, or even abilities directed at the player rather than units, this has sparked some ideas :D
 
Status
Not open for further replies.
Top