Jump to content
Sign in to follow this  
Scatoogle

Scripts not Communicating

Recommended Posts

I have a script that for some reason will not run the next script.

Delivery Mission

_Selector = _this Select 2;
_User = _this Select 1;
_UserCall = _this Select 0;

Hint"Boke 1";

if (_Selector == 2) then {
Hint Format ["%1 2", _Selector];
Hint "Car Delivery Started";
};


if (_Selector == 1) then {
Hint Format ["%1 1", _Selector];
_this ExecVM "PickUpTruckDM.sqf";
sleep 1;
Hint "PickUp";
};

if (_Selector == 0) then {
Hint Format ["%1 0", _Selector];
_this ExecVM "BigTruckDM.sqf";
sleep 1;
Hint "BigTruck";
};

Big Truck DM

_RandomDeliveryTruck = -1;
_RandomDeliveryTruck = round random 7;

_Test = compile preprocessfile "PickUpTruckDM.sqf";
_TestActive = [MissionActive]_Test;
Hint format["%1", _TestActive];

Sleep 1;

if (MissionActive == 1) then {
Hint "A DeliveryMission is Active!";
};

if (MissionActive != 1) Then {

Hint "Mission is now Active!";

if (_RandomDeliveryTruck == 0) then {
_DM = createMarker ["DeliveryMission", position DP1];
"DeliveryMission" setMarkertype "Flag";
};

if (_RandomDeliveryTruck == 1) then {
_DM = createMarker ["DeliveryMission", position DP2];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 2) then {
_DM = createMarker ["DeliveryMission", position DP3];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 3) then {
_DM = createMarker ["DeliveryMission", position DP4];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 4) then {
_DM = createMarker ["DeliveryMission", position DP5];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 5) then {
_DM = createMarker ["DeliveryMission", position DP6];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 6) then {
_DM = createMarker ["DeliveryMission", position DP7];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 7) then {
_DM = createMarker ["DeliveryMission", position DP8];
"DeliveryMission" SetMarkerType "Flag";
};

MissionActive = 1;
};

Share this post


Link to post
Share on other sites

does it require an array (brackets) before ExecVM?

_this=[]execVM "script.sqf"

in any case it looks like it should work.

have you actually ran the script when _selector is equal to 1 or 0? So you run the script and it evaluates the conditions and then exits the script. maybe you put it into some loop or something to keep evaluating the conditions? Or you may want to try something like

_Selector = _this Select 2;
_User = _this Select 1;
_UserCall = _this Select 0;

Hint"Boke 1";

waitUntil {_Selector == 2}; 
Hint Format ["%1 2", _Selector];
Hint "Car Delivery Started";



waitUntil {_Selector == 1};
Hint Format ["%1 1", _Selector];
_this ExecVM "PickUpTruckDM.sqf";
sleep 1;
Hint "PickUp";


waitUntil {_Selector == 0};
Hint Format ["%1 0", _Selector];
_this ExecVM "BigTruckDM.sqf";
sleep 1;
Hint "BigTruck";

Edited by Iceman77

Share this post


Link to post
Share on other sites

This Script is called through an Add Action on a person that is already there. The Problem isn't that the If-Then isn't working it is that the ExecVM I tried _this = []ExecVM "PickUpTruckDM.sqf"; but it just wont run the script.

Share this post


Link to post
Share on other sites

okay, so when you use the adddaction, will anything at all happen? Hint(s) or anything? Just to confirm you have addaction setup correctly.

Share this post


Link to post
Share on other sites

Boke 1 confirms that it has entered the IF-Then

_this ExecVM "PickUpTruckDM.sqf";

sleep 1;

Hint "PickUp";

These three lines confirm that the If-Then statement has been executed, but it will not allow the program to execute the script it just skips it.

Share this post


Link to post
Share on other sites

well, how you have it in your op, hint "boke 1" confirms the script has been run but not if the if-then statement condition is true. The other hints in the if-then blocks will tell you if any if-then has been ran. Are you recieving the other hints? The one(s) inside of the if-then blocks? ie; hint"car delivery started", if those arent working then the condition isn't being met, which could be any number of issues. how are you calling the initial script? Can you please post the addaction or w/e, that executes your delivery mission script?

Edited by Iceman77

Share this post


Link to post
Share on other sites

The Referenced scripts have their own Hint but they don't show.

This allowDamage False; This disableAI "ANIM"; This disableAI "MOVE"; This addAction ["Cargo Truck Delivery Mission", "DeliveryMission.sqf","",2]; This disableAI "MOVE"; This addAction ["PickUp Truck Delivery Mission", "DeliveryMission.sqf","",1]; This disableAI "MOVE"; This addAction ["Car Delivery Mission", "DeliveryMission.sqf","",0];

Share this post


Link to post
Share on other sites

Is the # the 2nd element in the addaction array? Meaning, is 2, in the "cargo Truck Delivery Mission" addaction the second element in the array? I think it's actually the 3rd element, though I could be wrong. So in your script, it would be

_selector = _this select 3;

or maybe even the 4th element, so like

_selector = _this select 4;

I may be wrong as I've stated, but I think the elements of a addaction goes like:

(0)This addAction [(1)"Cargo Truck Delivery Mission",(2)"DeliveryMission.sqf",(3)"",(4)2];

note: i believe the empty string in the addaction array is like a condition field

Edited by Iceman77

Share this post


Link to post
Share on other sites

Try

[_this] execVM "script.sqf";

if that doesn't work _this can't be used to execute the script since _this is what gets returned by execVM (to the script). Try the name of the truck otherwise.

Share this post


Link to post
Share on other sites

DeliveryMission.sqf

_DeliveryStarts = [DS1];
_DeliveryPoints = [DP1, DP2, DP3, DP4, DP5, DP,6, DP7, DP8];
Comment "Determine which addaction has been selected";

_Selector = _this Select 2;

Comment "Determine the players name";

_User = _this Select 1;

Comment "Determine which Port Man has been selected";

_UserCall = _this Select 0;

Hint"Boke 1";



if (_Selector == 2) then {
Hint Format ["%1 2", _Selector];
Hint "Car Delivery Started";
};


if (_Selector == 1) then {
Hint Format ["%1 1", _Selector];
[]ExecVM "PickUpTruckDM.sqf";
sleep 1;
Hint "PickUp";
};

Comment "if the Cargo Truck Delivery Mission was selected go through If-Then statement.";

if (_Selector == 0) then {
Hint Format ["%1 0", _Selector];
[]ExecVM "BigTruckDM.sqf";
sleep 1;
Hint "BigTruck";
};

comment "Produce a random number called _RandomDeliveryTruck";

_RandomDeliveryTruck = -1;
_RandomDeliveryTruck = round random 7;


comment "If the mission is still active inform player";

if (MissionActive == 1) then {
Hint "A DeliveryMission is Active!";
};

comment "Use the random number to place a marker at a selected posistion based on gamelogic";

if (MissionActive != 1) Then {

Hint "Mission is now Active!";

if (_RandomDeliveryTruck == 0) then {
_DM = createMarker ["DeliveryMission", position DP1];
"DeliveryMission" setMarkertype "Flag";
};

if (_RandomDeliveryTruck == 1) then {
_DM = createMarker ["DeliveryMission", position DP2];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 2) then {
_DM = createMarker ["DeliveryMission", position DP3];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 3) then {
_DM = createMarker ["DeliveryMission", position DP4];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 4) then {
_DM = createMarker ["DeliveryMission", position DP5];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 5) then {
_DM = createMarker ["DeliveryMission", position DP6];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 6) then {
_DM = createMarker ["DeliveryMission", position DP7];
"DeliveryMission" SetMarkerType "Flag";
};

if (_RandomDeliveryTruck == 7) then {
_DM = createMarker ["DeliveryMission", position DP8];
"DeliveryMission" SetMarkerType "Flag";
};

comment "Set mission active";
MissionActive = 1;
};

Here are the scripts but commented so that you can see what is going on as the game moves through the script.

Share this post


Link to post
Share on other sites

Yes, but

_selector = _this select 2

is what you have atm. I'm wondering if the second element in the addaction array is infact the # values you have in the addaction array? I was saying I believed that the values weren't the 2nd element, but actually tghe 3rd or maybe fourth element.Also, as suggested earlier by tryt, use the name of the delivery vehicles and see if that helps.

Share this post


Link to post
Share on other sites

They are

[code}
Hint Format ["%1 1", _Selector];
[]ExecVM "PickUpTruckDM.sqf";
sleep 1;
Hint "PickUp";
[/code]

When I had selected them the Hint showed up. Now I am at know it has something to do with the If-Then in the BigTruckDM.sqf because it is the only thing that will not execute when I bypass the DeliveryMission.sqf script.

Share this post


Link to post
Share on other sites

It's

_object = _this select 0;
_usedBy = _this select 1;
_actionID = _this select 2;
_arguments = _this select 3;

Share this post


Link to post
Share on other sites

ActionID

Comment "Determine which addaction has been selected";

_Selector = _this Select 2;

UsedBy

Comment "Determine the players name";

_User = _this Select 1;

Target

Comment "Determine which Port Man has been selected";

_UserCall = _this Select 0;

Share this post


Link to post
Share on other sites

The ID is mainly used to remove the action. If you add several addActions to one object you can remove them based upon their ID.

You can't pass the ID in the addAction array, it' automatically passed.

I think you want this

init:

this addAction ["Cargo Truck Delivery Mission", "DeliveryMission.sqf",2]; this addAction ["PickUp Truck Delivery Mission", "DeliveryMission.sqf",1]; this addAction ["Car Delivery Mission", "DeliveryMission.sqf",0];

DeliveryMission.sqf:

_selector = _this select 3;

switch _selector do 
{
 case 0: 
 {
_this ExecVM "BigTruckDM.sqf";
sleep 1;
hint "BigTruck";
 };
 case 1: 
 {
_this ExecVM "PickUpTruckDM.sqf";
sleep 1;
hint "PickUp";
 };
 case 2: 
 {
hint "Car Delivery Started";
 };
};

Share this post


Link to post
Share on other sites

The problem isn't that the values aren't being passed. The problem is that my if then with _missionactive==0 isn't working.

-_-

Share this post


Link to post
Share on other sites

well the correct values aren't being passed if you have _selector = _this select 2... from what code you've posted anyhow. From what you've posted the #s are the 3rd or 4th element (you have an empty string too).

Edited by Iceman77

Share this post


Link to post
Share on other sites

All the values have been passed that need to be passed. Trust me I have tested them.

Share this post


Link to post
Share on other sites

But you are using them in the wrong way

Anyway, do you define your missionActive anywhere before running the truck/car scripts

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  

×