Jump to content
Sign in to follow this  
eagledude4

Case Switching issue

Recommended Posts

I built this small script to help me debug my mission: The problem is that when I try to use the action, no hint is displayed. I'm not receiving an error.

//By OneShot.J

_Selection = _this select 3;

while {true} do {
switch (_Selection) do {
case "Vehicle": {
	Hint format ["%1", nearestObject [player, "LandVehicle"]];
};
case "Building": {
	Hint format ["%1", nearestObject [player, "Building"]];
};
case "Object": {
	Hint format ["%1", nearestObject [player, "Static"]];
};
};

_Selection is defined through addactions:

Actions:

DebugAction1 = player addaction ["<t color=""#FF8000"">" +"Hint Vehicles","Scripts\AdminHint.sqf","Vehicle",1,false,true,"",'AdminMode and AdminDebug'];
DebugAction2 = player addaction ["<t color=""#FF8000"">" +"Hint Objects","Scripts\AdminHint.sqf","Object",1,false,true,"",'AdminMode and AdminDebug'];
DebugAction3 = player addaction ["<t color=""#FF8000"">" +"Hint Buildings","Scripts\AdminHint.sqf","Building",1,false,true,"",'AdminMode and AdminDebug'];

Edited by eagledude4

Share this post


Link to post
Share on other sites

Strange script - got it to work like this:

DebugAction1 = player addaction ["<t color=""#FF8000"">" +"Hint Vehicles","Scripts\AdminHint.sqf","Vehicle",1,false,true];
DebugAction2 = player addaction ["<t color=""#FF8000"">" +"Hint Objects","Scripts\AdminHint.sqf","Object",1,false,true];
DebugAction3 = player addaction ["<t color=""#FF8000"">" +"Hint Buildings","Scripts\AdminHint.sqf","Building",1,false,true];

_Selection = _this select 3;

while {true} do {
switch (_Selection) do {
case "Vehicle": {
	Hint format ["%1", nearestObject [player, "LandVehicle"]];
};
case "Building": {
	Hint format ["%1", nearestObject [player, "Building"]];
};
case "Object": {
	Hint format ["%1", nearestObject [player, "Static"]];
};
};
[color="#FF0000"]Sleep 2;[/color]
[color="#FF0000"]};[/color]

Possibly doesn't do what you intended - run it - you will see what I mean (it returns the object ref) - if you need the class - change each case to something like this:

	case "Vehicle": {
	_nVec = nearestObject [player, "LandVehicle"];
	_class = typeOf _nVec;
	Hint format ["%1",_class];
};

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Thanks, but hint switching back and forth problem still persists. If I want to hint vehicles, then switch the hint type to objects, it wont stop hinting the vehicles.

Edited by eagledude4

Share this post


Link to post
Share on other sites

Thats beacuse it's in a loop - get rid of the lines:

 while {true} do {

Sleep 2;
};

You will then be able to click on each addaction in turn and only get 1 result at once.....

Share this post


Link to post
Share on other sites

I realize the issue is because it's in a loop. I need it to be in a loop but some how cancel the other hints.

Share this post


Link to post
Share on other sites

Use a global variable instead of a local variable

Also it would be wise to not have this script run each time you use an action, just run it on the client and change the global variable with the action.

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  

×