• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

My Small Lab

Status
Not open for further replies.
Level 10
Joined
Dec 15, 2012
Messages
650
:grin: Hello guys, this is the place where I put my tests. They are not 100% work as you hear so I need testers. Everyone is free to suggest a new test.
New thing here, I'm figuring out how it's work.
JASS:
/*_____Values of the Arrow-keys_____*/
/*EventType*/
//Depress : 0
//Release : 1

/*Keys*/
//Left  : 0
//Right : 1
//Down  : 2
//Up    : 3

// These are the values of arrow-keys. I'm figuring out how
// to detect letter key as easy as detecting arrow-keys.

// Require (so hard. . .) : a custom event, give values to the letter keys.
________________________________
Do not be offended by my bad English :ogre_hurrhurr:
 
Last edited:
Level 10
Joined
Dec 15, 2012
Messages
650
@ BPower, I haven't get the latest version of JNGP, it's Multiplayer Emulation does not work for me :/ (Now, downlaod it :D)
@ Chaosy & Nestharus, never mind, I will try harder on learning JASS & vJASS :)

EDIT : Thanks for correcting me, everyone :D
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
But I heard that the host will be the one who loads the map first so I try GetHost instead of GetLocalPlayer. . . is it failed ?

Hm, but if that is correct then it could be abused to get the current host...

JASS:
library Hosts
	globals
		private player host = null
	endglobals

	private keyword INITS

	function GetHost takes nothing returns player
		return host
	endfunction

	private struct Host extends array
		implement INITS
	endstruct

	private module INITS
		private static method onInit takes nothing returns nothing
			if host == null then
				set host = GetLocalPlayer()
			endif
		endmethod
	endmodule
endlibrary

?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
The classical way was about preloading iirc. Basically you locally store the number of each player and then synchronize the values. In this case the host is considered the most important, so the only number that will prevail is the one of the host.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
The classical way was about preloading iirc. Basically you locally store the number of each player and then synchronize the values. In this case the host is considered the most important, so the only number that will prevail is the one of the host.

@ Xonok, I think you mean this :
GetHost()

If the above works it should be much faster than the gamecache approach. You should give it a try Ah_Xian, maybe your idea wasn't so bad ;)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Hm, but if that is correct then it could be abused to get the current host...

JASS:
library Hosts
	globals
		private player host = null
	endglobals

	private keyword INITS

	function GetHost takes nothing returns player
		return host
	endfunction

	private struct Host extends array
		implement INITS
	endstruct

	private module INITS
		private static method onInit takes nothing returns nothing
			if host == null then
				set host = GetLocalPlayer()
			endif
		endmethod
	endmodule
endlibrary

?

JASS:
library Hosts
    globals
        private player host = null
    endglobals

    private keyword INITS

    function GetHost takes nothing returns player
        return host
    endfunction

    private function f takes nothing returns nothing
        call DestroyTimer(GetExpiredTimer())
        if GetLocalPlayer() == host then
            call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 10, "Host")
        endif
    endfunction
    
    private struct Host extends array
        implement INITS
    endstruct

    private module INITS
        private static method onInit takes nothing returns nothing
            if host == null then
                set host = GetLocalPlayer()
            endif
            call TimerStart(CreateTimer(), 0.5, false, function f)
        endmethod
    endmodule
endlibrary

will print host to both emulated players, so no it wont work, but it was quite impressive plan
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
library Hosts
	globals
		private player host = null
	endglobals

	private keyword INITS

	function GetHost takes nothing returns player
		return host
	endfunction

	private struct Host extends array
		implement INITS
	endstruct

	private module INITS
		private static method onInit takes nothing returns nothing
			if host == null then
				set host = GetLocalPlayer()
			endif
		endmethod
	endmodule
endlibrary

?

Reading the variable is async, too. Yes, one player may be the first in setting the variable (although the other players could be in the if-selection as well meanwhile, since those are parallel processes) but the variable is only set for this specific player by then, for the others it's still null.
 
Status
Not open for further replies.
Top