Jump to content
Sign in to follow this  
LoOni3r

player setpos vehicle / player moveInCargo after respawn not working

Recommended Posts

hi,

 

I want the player to be teleported to a MHQ.

I'm hereby doing this:

 

if (!isEngineOn westmhq1) then {
    player moveInCargo westmhq1;
}else{
    player setPos (westmhq1 getPos [10,10]);
};

if (!isEngineOn westmhq1) then {
	player moveInCargo westmhq1;
}else{
	player setPos (westmhq1 getPos [10,10]);
};

 

 

that works too.

If the MHQ named westmhq1 is destroyed, spawns it again:

_vehicle = _this select 0;
_respawntime = _this select 1;
_facingofvehicle = getDir _vehicle;
_positionofvehicle = getPosATL _vehicle;
_vehicletype = typeOf _vehicle;
_name = vehicleVarName _vehicle;
....
			_vehicle = _vehicletype createVehicle _positionofvehicle;
			_vehicle setVehicleVarName _name;
			_vehicle setPosATL _positionofvehicle;
			_vehicle setDir _facingofvehicle;
...

 

that works too.

 

 

After respawning from westmhq1, the player is no longer teleported. No error message appears.

Unfortunately, I do not understand why that is.
Maybe someone can explain why the player is no longer teleported after respawn westmhq1.

 

thanks..

Share this post


Link to post
Share on other sites

I wanted to extend my file to teleport:

 

if (getPos westmhq1 = getPosATL) then {
	player moveInCargo westmhq1;
}else{
	if (!isEngineOn westmhq1) then {
		player moveInCargo westmhq1;
	}else{
		player setPos (westmhq1 getPos [10,10]);
	};
};

 

"if (getPos westmhq1 = getPosATL) then {"

give me back error "error missing )"

 

as I see it, everything is right...

Share this post


Link to post
Share on other sites
8 hours ago, LoOni3r said:

as I see it, everything is right...

 

if (getPos westmhq1 = getPosATL) then {

A single equal sign (=) assigns a value. Your code says "if the position of the MHQ, which is now the same as the position of <null>, then { do things }. 
It makes no sense.
A double equal sign (==) compares values.
What object's position are you trying to compare the MHQ's position to?

Share this post


Link to post
Share on other sites

many thanks for your response.

 

I only have this code in a single one .sqf:

if (getPos westmhq1 == getPosATL) then {
	player moveInCargo westmhq1;
}else{
	if (!isEngineOn westmhq1) then {
		player moveInCargo westmhq1;
	}else{
		player setPos (westmhq1 getPos [10,10]);
	};
};

 

If the westmhq1 still has the same place as at the beginning of the game -> moveInCargo

other position -> check engine on / off

engine on -> moveInCargo

engine off -> setPos.

 

 

The bigger problem for me is that teleporting after respawn from westmhq1 does not work.

you just will not be teleported..

no error message .. that is missing...

Share this post


Link to post
Share on other sites
20 minutes ago, LoOni3r said:

if (getPos westmhq1 == getPosATL) then {

 

Again, getPosATL what?

Share this post


Link to post
Share on other sites

uhhh "getPosATL westmhq1"

 

sorry i was blind. That can not work like that

 

I changed it now as follows:

_vehPosSart = getPosATL westmhq1;
_vehPosCurrent = getPos westmhq1;
if (_vehPosCurrent == _vehPosSart) then {
...

 

When I run it, I get an error message. I test some possibilities

 

"arma 3 error ==: type array expected number, string, not a number..."

 

I have noticed that the current position is slightly different from the starting position. so I'm trying to compare it to [1699.64,2943.2,0.0716782]  (is the output of hintSilent)

Share this post


Link to post
Share on other sites

You are essentially checking to see if the object is where it is. That makes no sense.

 

The two commands (getPos, getPosATL) will return very slightly different Z values, but that's irrelevant.

 

What are you trying to accomplish?

Share this post


Link to post
Share on other sites

I have the westmhq1 on a plane carrier.

if the player is teleporting to the Westmhq1, should -> moveInCargo when westmhq on plane carrier.

when engine on -> moveInCargo

when engine of and another place -> player setPos..

 

edit:\\

current status:

 

_vehPosCurrent = getPos westmhq1;
_vehPosPlaneCarrier = [1699.64,29436.2,0.0756626];



_asdasdasd = "------------";
systemChat format ["%1",_vehPosCurrent];
systemChat format ["%1",_vehPosPlaneCarrier];
systemChat format ["%1",_asdasdasd];


if (_vehPosCurrent == _vehPosPlaneCarrier) then {
hint "AAAAA";
}else{
hint "BBBBB";
};

 

according to systemChat both expenses are the same and should be "AAAAA".

 

"error ==: type array expected number, string, not a number"

 

why I do not understand yet but I get closer to the thing..

Share this post


Link to post
Share on other sites

ah, i did not know this feature yet.

Many Thanks

 

then only the main problem remains that teleporting after vehicle (westmhq1) respawn is not carried out

Share this post


Link to post
Share on other sites

Is that your entire .sqf? I did a small scale test and seemed to keep teleporting the player into the vehicle after it was respawned. Also might help us narrow it down if you show/tel;l us how you are calling the script. Its execution could also be important.

Share this post


Link to post
Share on other sites

hello XianGrim,

 

I placed the westmhq1 in the mission.sqm (editor) on a plane carrier.

 

in the editor:

variable name -> westmhq1

init -> 0 = [this,1] execVM "scripts\system\respawn\vehicle_respawn.sqf";

 

My teleport script works until the westmhq1 is destroyed.

 

respawn script:

 

_vehicle = _this select 0;
_respawntime = _this select 1;
_facingofvehicle = getDir _vehicle;
_positionofvehicle = getPosATL _vehicle;
_vehicletype = typeOf _vehicle;
_name = vehicleVarName _vehicle;
_n = 1;

if(isServer) then{
	while{_n == 1} do{
		if((!alive _vehicle) || (!canMove _vehicle)) then {
			sleep 2;
			deleteVehicle _vehicle;
			sleep _respawntime;
			_vehicle = _vehicletype createVehicle _positionofvehicle;
			_vehicle setVehicleVarName _name;
			_vehicle setPosATL _positionofvehicle;
			_vehicle setDir _facingofvehicle;
...

the respawn works great.

just do not teleport after respawn.

 

I wrote a little script that creates and updates a marker for the westmhq1.

this works perfectly.

but only until the vehicle respawnt.

The marker remains where the westmhq1 was destroyed.

it seems as if the name is not adopted at the respawn.

 

if I show the name after the respawn via hint, he agrees "westmhq1".

 

I get no error message :/

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  

×