Jump to content
Sign in to follow this  
galzohar

moveInCargo in the init line and JIP?

Recommended Posts

If I use moveInCargo command in the init line of a soldier so that at mission start he will go in the vehicle's cargo, what happens when a player JIPs in? Non-local units are supposed to ignore the command, but what if it just happened that he managed to grab a unit (and thus player is no longer null, and that unit became local)? Won't there be a chance for the moveInCargo to move his soldier into the cargo even if the soldier he's JIPing into have already disembarked? If this can't happen, why is it like that? If it can happen, how can I prevent it?

Share this post


Link to post
Share on other sites

Maybe put an if statement around the move in cargo? Check if the vehicle exists (start of mission) or if it's deleted (after airdrop/movement) and if it's not there move the player to the AO instead?

Share this post


Link to post
Share on other sites

init for the unit has already been executed upon mission start, before the JiP player jumped in. Shouldn't be a problem

PS : My rule for MP & JiP issues : don't try to prevent them by anticipating what the engine will do. Correct the errors after you see them ;) It's already difficult enough like that :)

Edited by whisper

Share this post


Link to post
Share on other sites

So init lines are only executed at mission start and don't get executed for JIP players? That is definitely a good thing, I thought I read differently somewhere.

Some testing requires other people to actually join your game, so I would rather have it working first time whenever possible. There will be enough errors to fix on a "when I see them" basis anyway ;)

Share this post


Link to post
Share on other sites

I'm not sure, I think it should work that way, like I said, test it and see if it works. Think about a correction afterwards :)

Even if init line is executed, the most likely event is that the player will not be incarnated yet for the engine, thus the unit won't be local. I think the init line execution is way before player enters the game, and even at that point (player entering 3D world), player is still not really incarnated

Edited by whisper

Share this post


Link to post
Share on other sites

Yeah, I thought that would be the case, but I'd rather write stuff that work 100% rather than 99.9%.

Same goes with how I hate using sleep .1 before any assign gear script, and only reason I use it is because I have absolutely no idea as to why it doesn't work without it. Would much rather use some kind of waitUntil{something}.

Share this post


Link to post
Share on other sites

You mean, to assign gear with a script launched from unit init line, you need to add a tempo in the script?

That's perhaps because adding any sleep or waitUntil in a script executed during the initialisation phase will post-pone execution of said script to the mission start (after the briefing screen is passed and players actually enter 3D world), AFAIK.

Perhaps it's something needed for the script

Share this post


Link to post
Share on other sites

That might be the case, but it still doesn't make a lot of sense, as not using it will cause the weapons to properly be applied but you will have the bug where you can't aim or shoot. Then again that same bug is caused when you don't use the selectWeapon command after switching loadouts, so probably onlt that command is what needs to wait until missions starts. So I suppose a waitUntil {true} would serve the same purpose...

As for the moveInCargo, it seems you have to specify the cargo slot for it to work on a dedicated server, or else it seems to do something nasty probably because it ends up trying to put 2 soldiers into the same slot for some reason. Does not happen on a hosted server, at least not when the host is the only player. And for some reason the mission still takes a really long time to start up (from the moment I hit "continue" in the briefing until it actually starts "receiving").

Share this post


Link to post
Share on other sites
As for the moveInCargo, it seems you have to specify the cargo slot for it to work on a dedicated server, or else it seems to do something nasty probably because it ends up trying to put 2 soldiers into the same slot for some reason.

Been using moveincargo since always in units init fields for dedi servers, never had any problems. The units are moved in the order they are in the mission.sqm. Only issue, which is kind of logical, is that they won't be moved if the vehicle is full already.

Not that I've had any problems with adding/switching unit's gear either. But, I'm doing it the old "addweapon etc commands straight to init field" -way, no fancy scripts.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×