Jump to content

isSelfHost funtion


seeh
 Share

Recommended Posts

I'm trying to find out if I'm a host. a function does not return an error. But sometimes returns true when false would have been expected.

works no problem. thank you (23-0811_1534-51)

/**
 * Determine if the current player is the host player.
 */
function isSelfHost(){ // maybe call it in a settimeout assync function
	const selfGUID = Engine.GetPlayerGUID()
	const firstPlayerGUID = Object.keys(g_PlayerAssignments)[0];

	const selfPlayerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
	const hostPlayerAssignment = g_PlayerAssignments[firstPlayerGUID];

	g_selfInHost = selfGUID == firstPlayerGUID;

	const bugIt = true // new implementation so i will watch longer
	if(bugIt){ 
		warn(`42: selfPlayerAssignment.name = ${selfPlayerAssignment.name}`);
		warn(`43: hostPlayerAssignment.name = ${hostPlayerAssignment.name}`);
		warn(`44: g_selfInHost => ${g_selfInHost}`);
	}
	warn(`45: g_selfInHost => ${g_selfInHost}`);
	return g_selfInHost
}

 

Edited by seeh
Link to comment
Share on other sites

  • seeh changed the title to isSelfHost funtion

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...