jnZ
I
- Reaction score
- 64
no it works fine. i think ill keep it like that. but anyway how to make it "mpi" now because the tutorial says:
there is no way to determine which player triggered the event on a trackable. We can work around this by creating a trackable for each player - each can only be triggered by one player.
this is the "mpi" code mentioned in the turtorial:
so are you still able to do it?
EDIT: i need it for up to 5 players, so best would be running a playing players detection at start and only create as much trackables as needed
there is no way to determine which player triggered the event on a trackable. We can work around this by creating a trackable for each player - each can only be triggered by one player.
this is the "mpi" code mentioned in the turtorial:
JASS:
// t1 and t2 are visually the same trackable, but in fact they only work for one player each
local trackable t1 // Player 1's trackable
local trackable t2 // Player 2's trackable
local string peasant = "units\\human\\Peasant\\Peasant.mdl"
local string invisible = ""
local string path = invisible
if ( GetLocalPlayer() == Player(0) ) then
set path = peasant
endif
set t1 = CreateTrackable(path, -500, 0, 0)
set path = invisible
if ( GetLocalPlayer() == Player(1) ) then
set path = peasant
endif
set t2 = CreateTrackable(path, -500, 0, 0)
call SetHandleInt(t1, "player", 0) // Store which player "owns" this trackable
call SetHandleInt(t2, "player", 1) // Same for player 2
// Add events to register track/hit on t1 and t2...
JASS:
function GetTrackableOwner takes trackable t returns player
return Player(GetHandleInt(t, "player"))
endfunction
function NewTrackable takes string path, real x, real y, real facing, player owner returns trackable
local trackable tc
local string invisible = ""
if GetLocalPlayer() != owner then
set path = invisible
endif
set tc = CreateTrackable(path, x, y, facing)
call SetHandleReal(tc, "x", x)
call SetHandleReal(tc, "y", y)
call SetHandleReal(tc, "facing", facing)
call SetHandleString(tc, "path", path)
call SetHandleInt(tc, "player", GetPlayerId(owner))
return tc
endfunction
so are you still able to do it?
EDIT: i need it for up to 5 players, so best would be running a playing players detection at start and only create as much trackables as needed