Jump to content
Sign in to follow this  
avibird 1

Why does these scripts cancel eachother out if they both work fine in a mission

Recommended Posts

I don't know why but when I try to add these codes together they will not work together. I am probably doing something very simple for it not to work!

I am working on a mobility construction truck that allows the player to use the coin interface anywhere on the map to build bases/FOB.

I am trying to add a marker script that allows the players to see the position of the trucks

using this code

nul = ["BAFMCV", this] execVM "markerlocation.sqf" this works fine

I am using this code to respawn the truck back into the mission when destroyed

veh=[this,60,0,0]execVM"Avi_custom\vehicle_respawn.sqf"; this works fine

I have these codes in a lot of my scripts within this mission and it works fine with other scripts. When I want something to stay in a units init I use this

_null = [] spawn { code here }; You place what ever code in side this { } and the code stays with the unit following respawn.

MY issue if when I add all the three codes together the marker shows up on the load screen but following a few seconds disappears and the marker script is not working.

If I remove the 3rd code then all works fine. I know the third code works because I have it in the same mission for other scripts and it works but not with the two above. Any direction would be great. this is how the full init box looks

veh=[this,60,0,0]execVM"Avi_custom\vehicle_respawn.sqf"; _null = [] spawn {nul = ["BAFMCV", this] execVM "markerlocation.sqf"};

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

I would hazard a guess that it's because you're spawning the script, it doesn't know what "this" is

_null = [] spawn {nul = ["BAFMCV", this] execVM "markerlocation.sqf"};

try doing it like this where it's passed to the spawn code

_null = this spawn {nul = ["BAFMCV", _this] execVM "markerlocation.sqf"};

Share this post


Link to post
Share on other sites

Hey F2k Sel no go the marker stay at the start of the mission but will not respawn back ): a small step forward but still can't get the marker back. If you have any other attempts please let me know. This should not be that hard just to get a marker to spawn back.

Share this post


Link to post
Share on other sites

I would try and check that the marker isn't being created before the object this has been respawned.

You could even try moving the marker script to the respawn script and see what happens.

Share this post


Link to post
Share on other sites

I think I need to change the title of this post To how to keep a vehicle marker on respawn of that vehicle. I have attempted multiple things. I know this can be done. I have looked into domination mission but lol that is a hard mission to find things at times. Any help on this would be great avibird

Share this post


Link to post
Share on other sites

Is this:

veh=[this,60,0,0]execVM"Avi_custom\vehicle_respawn.sqf"

using Tophe's vehicle respawn script? If so, it has a built in parameter for vehicle init(using setVehicleInit).

If it is, just add your marker script to the code.

First init box:

nul = ["BAFMCV", this] execVM "markerlocation.sqf"; veh=[this,60,0,0,false,false,"nul = ['BAFMCV', this] execVM 'markerlocation.sqf'"]execVM"Avi_custom\vehicle_respawn.sqf"

Share this post


Link to post
Share on other sites

@ PANTHER hey mate yes it is Tophe's script and yes I did to that code in the vehicles init but still the marker is not spawning back when the vehicle does): I have attempted multiple adjustments of the code and attempted to put the marker codes inside Tophe's script. WFT I know this can be done but I am very lost on this and have no more directions to attempt to fix it at this time. I need help with this!!!

Share this post


Link to post
Share on other sites

Here is a different way to do the same. MyTruck is the name of the vehicle.

//init.sqf

if (isServer) then
{
call compile preprocessFileLineNumbers "MoveTruckMarker.sqf";

if (isNil "TruckMarker") then {TruckMarker = [];};
"TruckMarker" addPublicVariableEventHandler 
{
	createMarker [((_this select 1) select 0), position ((_this select 1) select 1)];
	"TruckMarker" setMarkerShape "ELLIPSE";
	"TruckMarker" setMarkerSize [1, 1];
	"TruckMarker" setMarkerShape "ICON";
	"TruckMarker" setMarkerType "DOT";
	"TruckMarker" setMarkerColor "ColorRed";
	"TruckMarker" setMarkerText "MHQ";	
	call attach_truck_mkr;
};
};

and

//MoveTruckMarker.sqf

attach_truck_mkr = {
[] spawn { while {alive MyTruck} do { "TruckMarker" setmarkerpos getposATL MyTruck; sleep 1; }; };
};

the createMarker part could be streamlined into a function as well but this works.

Share this post


Link to post
Share on other sites

@Jigsor I have attempted multiple scripts to get the marker back on a vehicle following respawn. I will give you code/script ago. One question do I need to call your script in via trigger or action menu or does it upload at mission start because you have it running from the mission init.SQF. Avibird.

Share this post


Link to post
Share on other sites

This example initializes at mission start. Though you could use trigger instead. Just make sure server runs the code. You can hide it at anytime with "MHQ" setMarkerAlpha 0; and to unhide it use "MHQ" setMarkerAlpha 1; on client.

Edited by Jigsor

Share this post


Link to post
Share on other sites

If that is not working. Try this. I just tested on dedi. It shpuld also work for JIP.

// init.sqf
if (isServer) then 
{ 
   call compile preprocessFileLineNumbers "moveMarker.sqf"; 

if (!isNil "PlaneMarker") then {deleteMarker "PlaneMarker";};
_planePos = (getposATL myPlane);
_pmarker = createMarker ["PlaneMarker", _planePos];
_pmarker setMarkerShape "ELLIPSE";
"PlaneMarker" setMarkerSize [1, 1];
"PlaneMarker" setMarkerShape "ICON";
"PlaneMarker" setMarkerType "DOT";
"PlaneMarker" setMarkerColor "ColorRed";
"PlaneMarker" setMarkerText "TrackingMarker";	
publicVariable "PlaneMarker";	

//for JIP
   if (isNil "PlaneMarker") then {PlaneMarker = [];}; 
   "PlaneMarker" addPublicVariableEventHandler  
   { 
       createMarker [((_this select 1) select 0), position ((_this select 1) select 1)]; 
       "PlaneMarker" setMarkerShape "ELLIPSE"; 
       "PlaneMarker" setMarkerSize [1, 1]; 
       "PlaneMarker" setMarkerShape "ICON"; 
       "PlaneMarker" setMarkerType "DOT"; 
       "PlaneMarker" setMarkerColor "ColorRed"; 
       "PlaneMarker" setMarkerText "Plane";     
       call attach_plane_mkr; 
   }; 
};

if (isNil "PlaneMarker") then {PlaneMarker = [];};
"PlaneMarker" addPublicVariableEventHandler {call compile format ["%1",_this select 1]};
[] spawn { while {alive myPlane} do { "PlaneMarker" setmarkerpos getposATL myPlane; sleep 1; }; };

and

//moveMarker.sqf
attach_plane_mkr = {
[] spawn { while {alive myPlane} do { "PlaneMarker" setmarkerpos getposATL myPlane; sleep 1; }; };
}; 

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  

×