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

Can I add to an integer within a local block?

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
Yes but the actual answer depends on what are you going to do with that integer later.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
Actually I'm using it to see whether a player has an .mp3 file in a folder or not, like:

JASS:
            if GetLocalPlayer() == p then
            if GetSoundFileDuration(EMSCreateTrackLocation(i)) > 0 then
                set i2 = i2 + 1
            endif
            endif

It's a check. I'll use that integer for an exitwhen and a return for a function, which will be used widely...

EDIT: Looks like I can.
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
What you get when you do those things in local blocks, is that different players (clients) will have different values for it.

If you use it for local purpose, then its fine.
However, you cant use it to anything that needs syncronization.
 
Level 12
Joined
May 22, 2015
Messages
1,051
You can do anything inside a local block, just be aware that you may cause players to drop out of the game due to desyncs. I can't say I know all the details about what will cause these desyncs and what won't, but it's definitely not something to be toying with. It could cause painfully complicated bugs that are annoying to debug (need another player connected and you have to debug when they drop from the game).

All I know is that I am sticking to using this only for floating text. I may experiment with some animation dummy units, but I don't know if that can break things.
 
The system you linked works, yes, albeit it's a bit overengineered for such a simple task (for example, it is completely beyond me why you must run a 32 fps timer for something like starting a new track).

Basicly, playing music from a local folder is as easy as getting the GetSoundFileDuration from the path, storing the currently playing sound in a variable and using GetSoundIsLoading and GetSoundIsPlaying to find out if the currently running track finished or not. This will also get rid of any problems when the player minimizes the game or a player lags (which creates a gap in the music [player drop dialog stops timers] after the current track finishes or makes them overlap [minimizing pauses music, but not timers in multiplayer]).

And yes, you can increment the music tracks by counting up an integer locally. But you can also just do it globally with an array. It doesn't matter in this case. I'd go local for simplicity (and, you know, saves you an array in that case).
 
Status
Not open for further replies.
Top