Jump to content
Sign in to follow this  
FORCED-INDUCTN

Trying to make a new mobile HQ script

Recommended Posts

Hello,

We currently run the =BTC= Mobile HQ and Revice scripts on our server. These scripts work great until the MHQ is destroyed, then players can no longer teleport to the mobile HQ. However (very rarely) the MHQ will still work after it has been destroyed and re spawned. We attempted to "fix" the MHQ script but we have limited scripting abilities. So we decided to write our own (very simple) MHQ script and hopefully build up some scripting skills.

This is what we have so far:

/*

kc REPRESENT BITZNATCHES

*/

private ["_leader","_LX","_LY","_LZ"];

//setting up basic variables

_leader = Mobile_HQ;

_list = 0;

if ((vehicle _leader) emptyPositions "cargo"==0) then

{hint "No room in Mobile HQ. Please Wait."}

else

{

player moveincargo vehicle _leader;

};

Pastebin: http://pastebin.com/L9CRSQP6

The above script (surprisingly) works. The idea is, anyone who runs up to the porta-potty is teleported to the back of the MHQ. However it teleports EVERYONE into the back of the MHQ. Similar to what was discussed in this thread: http://forums.bistudio.com/showthread.php?149944-Teleporting-JIP-players-to-where-the-action-is

The suggested fix 1: Use a an action/trigger in the scroll wheel menu. Or something like this: if(local (thislist select 0)) then {player setPos (getMarkerPos "warpzone2")};

Only problem is we have no idea how to create an action in the scroll menu or modify the above snippet :(

Thanks in advance from [KC]FORCED-INDUCTN and [KC]Trick_Killa

---------- Post added at 13:15 ---------- Previous post was at 12:06 ----------

Hmm, so we got the new script working (yay!) but it is suffering from the same problem the =BTC= script has. When the mobile HQ is destroyed and respawns, the teleport no longer works. We think we have tracked this down to the vehicle respawn script. When the MHQ is first spawned the below code is used:

class Item176

{

position[]={1994.4907,6.1235876,5824.3877};

azimut=371.48801;

id=231;

side="EMPTY";

vehicle="B_Truck_01_covered_F";

leader=1;

skill=1;

text="Mobile_HQ";

};

And the MHQ is named "Mobile_HQ" which is the name the teleport and marker scripts utilize. When the vehicle is respawned, it is not named "Mobile_HQ." I will post back if we make any progress :)

--Forced

Share this post


Link to post
Share on other sites

The only issue you're running into is that triggers don't distinguish between the 'player' who activated it and all of the other 'player' characters which is why it teleports everyone. A simple way to fix this is to just have an object at base with an addAction that executes the teleport to MHQ script.

This is my MHQ script, and yeah it could check for empty cargo positions (if I used that option, I don't) and it could check for the speed of the vehicle, but I use it for private games only so it's a non issue. Feel free to use and modify to your liking.

mobileHQ.sqf

/* 
Dead Simple MHQ Script by Kahna

Add the following code to the INIT of the Object you want to use to teleport you to the MHQ. 
** Note: this enablesimulation false removes all interaction and physics from from the object, delete that line if it causes problems. Otherwise it keeps your MHQ teleport object from getting knocked down.

this allowdamage false; 
this enablesimulation false; 
this addAction["<t color='#ff1111'>Mobile HQ</t>", "mobileHQ.sqf"];


** Note: Where mobileHQ below is the variable name of your MHQ vehicle 
** Note: The GetDamage section is intended to prevent players from spawning into or around a critically damaged MHQ that is likely under fire and about to explode. Set your damage values to your liking. If you don't care what damage the MHQ has sustained, set (_dmg < 0.99) or remove the code block entirely.
*/

private "_veh","_dmg","_pos";

_veh = mobileHQ;

if (alive _veh) then 
{

_dmg = getDammage _veh;
_pos = getPos _veh;

if (_dmg < 0.90) then 
{
titleText ["Spawning at MHQ. Standby...", "BLACK OUT"];
sleep 2;

//** Note: Use this if you want players to spawn inside the MHQ and comment out the player setPos line.
//player moveInCargo _veh;

//** Note: This places the player at a random point within 10 meters of the MHQ at 0 elevation.
player setPos [(_pos select 0) + ((random 10) - (random 10)), (_pos select 1) + ((random 10) - (random 10)), 0];

sleep 2;
titleText ["", "BLACK IN"];
} else {hint "Mobile HQ is disabled!"};

} else {hint "Mobile HQ is not available"};

Share this post


Link to post
Share on other sites

Thanks for that. But at this time our problem is the Mobile_HQ spawning again and still working.

This is our current teleport to MHQ script and it has been working like a charm.

private ["_leader","_LX","_LY","_LZ"];

//setting up basic variables
_leader = Mobile_HQ;
_list = 0;

_telepos = _this select 3;

switch (true) do {
   case (_telepos == 1) : {
if ((vehicle _leader) emptyPositions "cargo"==0) then
{hint "No room in Mobile HQ or Mobile HQ has been destroyed. Please Wait for room or another Mobile HQ to respawn."}
else
{
player moveincargo vehicle _leader;
};
};
   default {hint "Please Select the Mobile HQ you want to teleport to.";};
};

This works until the MHQ is destroyed. We originally had the standard vehicle.sqf I see everyone else running for the respawn on it but it did not seem to work.

Does the name change on a respawn? Only thing I can think of that would break it like this.

So I have been messing around with this:

init.sqf

Mobile_HQ execVM "vehicleInit.sqf";

VehicleInit.sqf

_veh = _this;
_vname = "Mobile_HQ";
_vehiclepos = getPos _veh;
_vehicledir = getDir _veh;
_classname = typeOf _veh;
waitUntil {sleep 1; !Alive _veh};
sleep 5;
deleteVehicle _this;
sleep 30;
_veh = _classname createVehicle _vehiclepos;
_veh setPos _vehiclepos;
_veh setDir _vehicledir;
_veh SetVehicleVarName _vname;
_veh Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VName];
sleep 90;
_veh execVM "vehicleInit.sqf";

But every time it respawns 2 of them and i dont understand why.

Mobile_HQ is the name of the vehicle.

Thanks for the help.

Share this post


Link to post
Share on other sites

Never mind

Edited by Larrow

Share this post


Link to post
Share on other sites

You're running it from init.sqf, so every client and the server will run the code. That's why you're getting multiple respawns. Limit the code to only run on the server.

if (isServer) then {
   Mobile_HQ execVM "vehicleInit.sqf";
};

Share this post


Link to post
Share on other sites

I don't know, I guess you're just trying to do it differently. I've blasted my MHQ apart over and over again and it never fails to work.

I just use a Hunter called mobileHQ with Tophe's Simple Vehicle Respawn Script in the INIT field and an object at the main respawn point with an addAction that calls up mobileHQ.sqf.

To me it just looks like you're trying to do something a lot more complicated with your MHQ and I'm not sure what it is you're trying to accomplish.

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  

×