Jump to content
Sign in to follow this  
[evo] dan

while and if statement failing

Recommended Posts

Hello all. I have written this piece of code that seemingly does not work (and I cannot figure out whats wrong with it):

nm = 1;
	tskObj1 = player createSimpleTask["Primary: Patrol"]; 
	tskObj1 setSimpleTaskDescription["Patrol along the given route.", "Patrol", "Patrol"];
	sleep 4;

_triggeram1 = createTrigger["EmptyDetector",[3500,3500,0]];
_triggeram1 setTriggerArea [160,160,0,false];
_triggeram1 setTriggerActivation ["BRAVO","PRESENT",false];
_triggeram1 setTriggerTimeout [1,1,1,true];
_triggeram1 setTriggerStatements ["this", "dude = 1; publicVariable 'dude'; player setVariable ['dude', dude, TRUE];", "hint 'trigger off'"];
_Marker3 = createMarker ["Marker3", [3500,3500]]; 
"Marker3" setMarkerShape "RECTANGLE";
"Marker3" setMarkerSize [50,50];


while{nm == 1} do {
ar5 = player getVariable ["dude", 0];
sleep 10;
hint 'working';
if(ar5 == 1) then {
	hint "You've done it right";
	nm = 0;
	numberOfSites = 1;
	if(isServer) then {
	ambushSite = 2 + (round random (numberOfSites-1));
	publicVariable "ambushSite";
	player setVariable ["ambushSite", ambushSite, TRUE];
	}; 
	wait 5;
	hint 'loading';
	execVM "missions.sqf";
};
};

However, once I remove the if(isServer) part so that it looks like the below, it does work:

nm = 1;
	tskObj1 = player createSimpleTask["Primary: Patrol"]; 
	tskObj1 setSimpleTaskDescription["Patrol along the given route.", "Patrol", "Patrol"];
	sleep 4;

_triggeram1 = createTrigger["EmptyDetector",[3500,3500,0]];
_triggeram1 setTriggerArea [160,160,0,false];
_triggeram1 setTriggerActivation ["BRAVO","PRESENT",false];
_triggeram1 setTriggerTimeout [1,1,1,true];
_triggeram1 setTriggerStatements ["this", "dude = 1; publicVariable 'dude'; player setVariable ['dude', dude, TRUE];", "hint 'trigger off'"];
_Marker3 = createMarker ["Marker3", [3500,3500]]; 
"Marker3" setMarkerShape "RECTANGLE";
"Marker3" setMarkerSize [50,50];


while{nm == 1} do {
ar5 = player getVariable ["dude", 0];
sleep 10;
hint 'working';
if(ar5 == 1) then {
	hint "You've done it right";
	nm = 0;
};
};

So can someone tell me where I am going wrong with this code when going adding the extra statement?

Share this post


Link to post
Share on other sites

Instead of "Wait" use "Sleep". Not even sure "Wait" is a valid command like Doppler said.

Share this post


Link to post
Share on other sites

Yup, my derp, changed wait to sleep and it worked fine (mixing up languages again)

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  

×