Jump to content

Recommended Posts

Hy,

I am fixing a character from somebody else, Isaac, it's almost done and only one bug gives me a headache.

Isaac is supposed to cry after every x seconds, but only the character the host plays does it.

What I mean is, when I have the server running, I play Wilson and somebody else plays Isaac, only Wilson plays the emote.

for i, v in ipairs(AllPlayers) do --Get list of all players
			print("Prefab: " .. v.prefab .. " | " .. "Index: " .. i) --Debugstuff
			if v.prefab == "isaac" then --If character is Isaac
				print("Should be \"isaac\": " .. v.prefab .. " | " .. i) --Debugstuff - Values are the right ones
				UserCommands.RunTextUserCommand("sad", AllPlayers[i], false) --Make him cry, but no matter which index I use, always only host cries
			end
		end

This is what selects the character that is supposed to play the emote,

I get the right indexnumber for the Isaac player, but always the host plays the emote.

Even when I replaced the variable "i" in

UserCommands.RunTextUserCommand("sad", AllPlayers[i], false)

with 1 or 2 Wilson cries.

I hope one of you genies can help me with my little problem.

Thanks

 - statistnr1

Edited by statistnr1

The reason Wilson (the host) cries rather than Isaac is because

UserCommands.RunTextUserCommand(...)

is run server-side, which is associated with the host and therefore the host's character. It is also a very hacky and dirty way to accomplish this. It would be better to do it like this:

inst:PushEvent("emote", { anim = "emoteXL_sad", fx = "tears", fxdelay = 17 * FRAMES, mounted = true })

Where inst is, of course, Isaac's prefab.

Edited by Joachim

Hy, thanks for your help!

20 minutes ago, Joachim said:

The reason Wilson (the host) cries rather than Isaac is because


UserCommands.RunTextUserCommand(...)

is run server-side, which is associated with the host and therefore the host's character.

I already thought this was the case.

23 minutes ago, Joachim said:

It is also a very hacky and dirty way to accomplish this.

True, first time modding and working with Lua, next time I know better.

 

23 minutes ago, Joachim said:

It would be better to do it like this:


inst:PushEvent("emote", { anim = "emoteXL_sad", fx = "tears", fxdelay = 17 * FRAMES, mounted = true })

Where inst is, of course, Isaac's prefab.

I put this in the code and it at least worked for me when I am host. I just have to wait for somebody to come online in my friendslist to test it.

I will let you know if I have more questions.

 

 - statistnr1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...