Jump to content
Sign in to follow this  
amateur

Question about BmoveIn*

Recommended Posts

I have some code in external script, launched from init.sqf

_units = allunits;

for "_x" from 0 to (count _units) do {

if (local (_units select _x)) then {

switch (_units select _x) do
{
       case t1_1:	{[(_units select _x)] allowGetIn true; (_units select _x) assignAsCommander ger_tank0; [(_units select _x)] orderGetIn true; (_units select _x) moveincommander ger_tank0};
       case t1_2:	{[(_units select _x)] allowGetIn true; (_units select _x) assignAsGunner ger_tank0; [(_units select _x)] orderGetIn true; (_units select _x) moveingunner ger_tank0};
       case t1_3:      {[(_units select _x)] allowGetIn true; (_units select _x) assignAsDriver ger_tank0; [(_units select _x)] orderGetIn true; (_units select _x) moveindriver ger_tank0};

and sooo on....

t1_1, t1_2, t1_2 - units from one group (placed in editor) and t1_1 is commander. ger_tank0 - spawned via createVehicle tank. In result - if (_units select _x) - AI-bot - it works fine. But then unit is player - player moves to place normally but after that immediately disembarks from vehicle. It happens only then unit has ai-bots in his group. How can I fix this?

Share this post


Link to post
Share on other sites

That's seems crazy complicated? Why not just use BIS_fnc_spawnVehicle to spawn a fully crewed vehicle instead of elaborate spawn and move case statements?

Share this post


Link to post
Share on other sites
That's seems crazy complicated? Why not just use BIS_fnc_spawnVehicle to spawn a fully crewed vehicle instead of elaborate spawn and move case statements?

These vehicles are for players from mission rooster on start. I don't need fully crewed vehicle - I need empty vehicle to occupy it with players or bots from mission rooster. The problem is - then player takes t1_1...tn_n units and has bots in his group (for exp. t1_1 player, t1_2,t1_3 - bots) - he disembarks from vehicle right after moveIn*.

Share this post


Link to post
Share on other sites
use addVehicle command on group if leader is AI when player is alive.

Tnx, partially helped :) With this command, then player is under bot command - he doesn't leave vehicle any more, but then player is commander - he's keeping to jump off his vehicle right after moveInCommander, but his ai-crew stays in. :confused:

Share this post


Link to post
Share on other sites

try to remove the allowgetin and ordergetin, and use variables to shorten and make code clear.

_units = allunits;

for "_i" from 0 to (count _units) do {
_unit = _units select _i;
if (local _unit) then {
	switch _unit do {
		case t1_1: {_unit assignAsCommander ger_tank0; _unit moveincommander ger_tank0};
		case t1_2: {_unit assignAsGunner ger_tank0; _unit moveingunner ger_tank0};
		case t1_3: {_unit assignAsDriver ger_tank0; _unit moveindriver ger_tank0};


and sooo on....

Share this post


Link to post
Share on other sites
try to remove the allowgetin and ordergetin, and use variables to shorten and make code clear.

Didn't helped. I thinks it has some connection with locality in mp. When I test it on local server - all goes well as i'm server, but then I try it on dedicated server - strange "jump offs" begins.

Share this post


Link to post
Share on other sites

I recently got more familiar with MP Frameworks wich dynamically can detect locality of any object afaik, try this on serverside only:

// small created function, place functions module on map.
waitUntil { !isNil "BIS_MPF_InitDone" };
_fnc = {
_unit = _this select 0; _veh = _this select 1;
switch (_this select 2) do {
	case "commander": {_unit assignAsCommander _veh; _unit moveincommander _veh};
	case "gunner": {_unit assignAsGunner _veh; _unit moveingunner _veh};
	case "driver": {_unit assignAsDriver _veh; _unit moveindriver _veh};
};
};

_units = allunits;
for "_i" from 0 to (count _units) do {
_unit = _units select _i;
switch _unit do {
	case (vehicle _unit != _unit): {};  // if in a vehicle, do nothing.
	case t1_1: {[nil,_unit,rSPAWN,[_unit,ger_tank0,"commander"],_fnc] call RE};
	case t1_2: {[nil,_unit,rSPAWN,[_unit,ger_tank0,"gunner"],_fnc] call RE};
	case t1_3: {[nil,_unit,rSPAWN,[_unit,ger_tank0,"driver"],_fnc] call RE};


and sooo on....

Share this post


Link to post
Share on other sites

It's working on dedicated then i'm the only client, but then more players joins - they (and i) experience the same disambarking problems. It's crazy.

Share this post


Link to post
Share on other sites

why not just paste the moveInCargo etc directly into the units init, not in a script? then no matter locality it will work.

Share this post


Link to post
Share on other sites
why not just paste the moveInCargo etc directly into the units init, not in a script? then no matter locality it will work.

Will it work if I create vehicles (ger_tank0, 1 and so on) in init.sqf? There are some scripts before createVehicle (serverside) that take certain amount of time.

Share this post


Link to post
Share on other sites

current solution, do not create the player vehicles via scripts at mission start, and use init line to spawn them in the seats.

if its needed for some kind of join in cargo type thing.

what is the reason for the vehicle spawn via scripts?

maybe post a demo of the issue, maybe better to use MP framework to run the seating code on specified units in the vehicle spawn script etc...

Edited by Demonized

Share this post


Link to post
Share on other sites
what is the reason for the vehicle spawn via scripts?

'couse vehicle creates depending on data from paramsArray (mis settings at mis.rooster).

Share this post


Link to post
Share on other sites
'couse vehicle creates depending on data from paramsArray (mis settings at mis.rooster).

Right i understand.

Can you just create all vehicles in editor and delete the ones not in the selected paramsArray at mission start? or is it "complicated"

Share this post


Link to post
Share on other sites

You could even use condition of presence based on parameters to only load the specific units, but not sure how that would work with playable units on the unit selection screen though...

Might be easier to just start the player outside the vehicle, then spawn loaded vehicles based on parameters or control which ones spawn based on that then once in game assign the player to the group, or even delete one of the group members, add the player and move the player into place?

Might be easier if you posted what you have so far and details about what exactly you want to happen though, this thread has gotten confusing. :)

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  

×