Jump to content
Sign in to follow this  
Xen0tech

Need help Taskhints :(

Recommended Posts

I can't for the life of me figure this out and its getting beyond frustrating failing. I just want a taskhint to appear when I complete an objective. I've tried this guys method http://www.ofpec.com/forum/index.php?PHPSESSID=bldbs4j3tvbi7nujqrsej5d9d3&topic=33768.0 but had no luck.

Here is one of my objectives as it looks in my briefing.html

MAG_tskObj1=player createSimpleTask ["Secondary objective"];

MAG_tskObj1 setSimpleTaskDescription ["Destroy the weapons cache.","Secondary objective","Secondary objective"];

I have made a trigger with this in it to go off after I complete the task

MAG_tskObj1 setTaskState "SUCCEEDED";

The little box in my briefing turns green so thats working ok but it doesn't display a hint to inform me the task was completed. Can anyone help?

Share this post


Link to post
Share on other sites

I use this script for taskHints:

fTaskHint.sqf:

#define WHITE [1,1,1,1]
#define GREY [0.75,0.75,0.75,1]
#define GREEN [0.6,0.8,0.4,1]
#define RED [1,0.1,0,1]

private["_task", "_taskDescription", "_taskStatus", "_taskParams"];

_task 			 = _this select 0;
_taskDescription = (taskDescription _task) select 1;
_taskStatus		 = toUpper(taskState _task);


_taskParams = switch (_taskStatus) do
{
case "CREATED":
{
	[format["NEW TASK ASSIGNED: \n%1", _taskDescription], WHITE, "taskNew"]
};

case "ASSIGNED":
{
	[format["ASSIGNED TASK: \n%1", _taskDescription], WHITE, "taskCurrent"]
};

case "SUCCEEDED":
{
	[format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"]
};

case "FAILED":
{
	[format["TASK FAILED: \n%1", _taskDescription], RED, "taskFAILED"]
};

case "CANCELED":
{
	[format["TASK CANCELED: \n%1", _taskDescription], GREY, "taskDone"]
};

};

taskHint _taskParams;

Just run it with for example handle = [MAG_tskObj1] execVM "fTaskHint.sqf";

Share this post


Link to post
Share on other sites

Thank you very much it worked :) I have no idea what handle means but as long as it works i'll be happy

Share this post


Link to post
Share on other sites

Just that all scripts in ArmA2 must have a script-handle. A variable that references the script, and to which return data (if there is any) will be stored.

It can have practically any variable name, and it doesn't have to be unique. You can run 50 scripts with the same script handle, as long as they don't return anything (or more specifically: as long as you don't want to store the return data if any).

Share this post


Link to post
Share on other sites

0 = execvm "script.sqf"

Hard coded constant assignment for the win! (The handle return works, but the assignment obviously fails, so its a win situation.)

Share this post


Link to post
Share on other sites

Could someone explain to me where each one of the files above goes, total newbie here clueless:)

This goes in the trigger correct? handle = [MAG_tskObj1] execVM "fTaskHint.sqf";

And the big script for the taskhints above goes in the init.sqf ?

Totally confused here, I may need a step by step process if anyone can help it would be appreciated

I keep getting an error saying sqf.task script not found? I know something is wrong?

Edited by stevedrumsdw

Share this post


Link to post
Share on other sites

The function linked in the OP is the best method for task hints. To get it to work, all you need to do is this:

1. Put the function in your mission folder.

2. In your init.sqf file, put the following line somewhere:

mk_fTaskHint = compile (preprocessFileLineNumbers "fTaskHint.sqf");

If you don't have an init.sqf file, create one.

3. To make a task hint appear, simply execute this line in a script or trigger:

[tskExample] call mk_fTaskHint;

Note that "tskExample" must be changed to the name that you gave the task when you created it. Also note that this function doesn't actually change the state of the task; it simply gives a hint that reflects the task's current state as defined by setTaskState.

Share this post


Link to post
Share on other sites
the function linked in the op is the best method for task hints. To get it to work, all you need to do is this:

1. Put the function in your mission folder.

2. In your init.sqf file, put the following line somewhere:

mk_ftaskhint = compile (preprocessfilelinenumbers "ftaskhint.sqf");

if you don't have an init.sqf file, create one.

3. To make a task hint appear, simply execute this line in a script or trigger:

[tskexample] call mk_ftaskhint;

note that "tskexample" must be changed to the name that you gave the task when you created it. Also note that this function doesn't actually change the state of the task; it simply gives a hint that reflects the task's current state as defined by settaskstate.

thank you, it works !:)

Share this post


Link to post
Share on other sites

I've run this script on a dedicated server and I noticed this line has a bug in the error log

[format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"]

It seems to work well enough in game but the log has this error message

Error in expression <[0.75,0.75,0.75,1], "taskDone"]};

taskHint _taskParams;>

Error position: <taskHint _taskParams;>

Error taskhint: Type Bool, expected Array

File mpmissions\__cur_mp.zargabad\fTaskHint.sqf, line 42

It's hard to work out what exactly is line 42 as everything on and around line 42 is a comment/remark!! :(

It doesn't affect the mission but it would be nice to have a clean log.

Share this post


Link to post
Share on other sites

All so complicated.. just use taskHint. :)

taskhint ["You killed the goat!!", [1, 0, 0, 1], "taskFailed"];

Share this post


Link to post
Share on other sites

Aye - my fault - in hindsight I put too little info.

I have this file in my scripts folder

#define WHITE [1,1,1,1]

#define GREY [0.75,0.75,0.75,1]

#define GREEN [0.6,0.8,0.4,1]

#define RED [1,0.1,0,1]

private["_task", "_taskDescription", "_taskStatus", "_taskParams"];

_task = _this select 0;

_taskDescription = (taskDescription _task) select 1;

_taskStatus = toUpper(taskState _task);

_taskParams = switch (_taskStatus) do

{

case "CREATED":

{

[format["NEW TASK ASSIGNED: \n%1", _taskDescription], WHITE, "taskNew"]

};

case "ASSIGNED":

{

[format["ASSIGNED TASK: \n%1", _taskDescription], WHITE, "taskCurrent"]

};

case "SUCCEEDED":

{

[format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"]

};

case "FAILED":

{

[format["TASK FAILED: \n%1", _taskDescription], RED, "taskFAILED"]

};

case "CANCELED":

{

[format["TASK CANCELED: \n%1", _taskDescription], GREY, "taskDone"]

};

};

taskHint _taskParams;

ala this site

http://www.ofpec.com/forum/index.php?topic=33768.0

And it works very well. I'm not sure if it is over complicated, I'll try the one above - but anyway, that one option throws an error (taskdone) but the others do not.

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  

×