Jump to content
Sign in to follow this  
zuff

Mobile HQ Script

Recommended Posts

I've got a simple MHQ script running with a vehicle named "mhq".

I have the "respawn_west" marker move to the position of "mhq" like this in my init.txt:

if (isServer) then {
[] spawn {
	while {TRUE} do {
		if (!isNil "mhq") then { 
			"respawn_west" setMarkerPos position vehicle mhq;
		};
		sleep 3;
	};
};
};

This works fine. If the mhq is non-existent the marker script doesn't run (i think?). The problem comes when I want the "respawn_west" marker to move to the base marker called "base_foxtrot" if the mhq is not available, so I tried this if else statement:

if (isServer) then {
[] spawn {
	while {TRUE} do {
		if (!isNil "mhq") then { 
			"respawn_west" setMarkerPos position vehicle mhq;
		};
		else {
			"respawn_west" setMarkerPos getMarkerPos "base_foxtrot";
		};
		sleep 3;
	};
};
};

But upon destroying said "mhq", the marker does not update to the "base_foxtrot" marker. Any clue what I'm doing wrong here?

Thanks in advance!

FIXED VERSION

init.sqf

if (isServer) then {
[] spawn {
	while {TRUE} do {
		if (alive mhq) then { 
			"respawn_west" setMarkerPos position vehicle mhq;
		}
			else {
			"respawn_west" setMarkerPos getMarkerPos "base_foxtrot";
		};
		if !(alive mhq) then {
			hint "MHQ Destroyed! Spawning at Foxtrot until new MHQ is delivered.";
		};
		sleep 3;
	};
};
};

NEW PROBLEM

Trying to teleport to "mhq" from ammo crate back at base using this:

ammo.sqf

_box addAction ["Teleport to MHQ", "teleport_mhq.sqf"];

teleport_mhq.sqf

if (alive mhq) then { 
player setPos mhq;
};
else {
hint "MHQ is Destroyed, please wait for new MHQ to be delivered.";
};

Puts me almost INSIDE the vehicle, any way I can be placed around it so I'm not clipping in it?

Edited by zuff

Share this post


Link to post
Share on other sites

I figured out a big problem, this is the code that works:

init.sqf

if (isServer) then {
[] spawn {
	while {TRUE} do {
		if (alive mhq) then { 
			"respawn_west" setMarkerPos position vehicle mhq;
		} else {
			"respawn_west" setMarkerPos getMarkerPos "base_foxtrot";
		};
		if !(alive mhq) then {
			hint "MHQ Destroyed! Spawning at Foxtrot until new MHQ is delivered.";
		};
		sleep 3;
	};
};
};

The "alive" condition fixes most of my problems. If vehicle is blown up the respawn point is set to base until vehicle is respawned.

My new problem is I'm trying to teleport to the vehicle. I have this addaction setup on the ammo crate back at base:

ammo.sqf

_box addAction ["Teleport to MHQ", "teleport_mhq.sqf"];

teleport_mhq.sqf

if (alive mhq) then { 
player setPos mhq;
} else {
hint "MHQ is Destroyed, please wait for new MHQ to be delivered.";
};

The problem is you teleport INTO the vehicle, how can I setup a radius around the vehicle in which the player is teleported?

Edited by zuff

Share this post


Link to post
Share on other sites

Use the getpos or getmarkerpos command first to get the coordinates of either the mhq or the marker, then use setpos with one of them offset by a few metres.

Don't recall sytax perfectly, but something like:

_pos = getmarkerpos "marker name here";

_newpos = [(_pos select 0) - 10, _pos select 1, _pos select 2];

player setpos _newpos

or something similar.

Hope it helps.

Share this post


Link to post
Share on other sites

you may also find locality problems in multiplayer - the addaction on the box will show up while youre a client on your own hosted server. as soon as a client joins you'll find they cannot see it. needs a little work. you can do this with eventhandlers on player etc and using cursortarget on client.

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  

×