Jump to content
Sign in to follow this  
bangabob

Show players name in hint

Recommended Posts

Hi everyone.

Context:

Certain player slots will have a task to kill friendly players (the traitor) Using the taskmaster script. For example the player names s1

What i want:

A hint to pop-up naming the player in s1 after a trigger is activated

Any help appreciated

Edited by BangaBob

Share this post


Link to post
Share on other sites

On activation of the trigger:

hint format ["Traitor: %1",name s1];

Share this post


Link to post
Share on other sites

Cheers.

So i have 4 traitors. Named s1,s2,s3,s4.

Is there a way to randomly select one of them four?

So something like

hint format ["Traitor: %1",name s1 OR s2 OR s3 OR s4];

Share this post


Link to post
Share on other sites
_traitor = [s1, s2, s3, s4] select floor(random 4);
hint format ["Traitor: %1", name _traitor];

Share this post


Link to post
Share on other sites

Sweet cheers.

Sorry to keep asking questions but i keep encountering new problems.

So say i have called the script and it has named s1. How can i remove s1 (last named called) from the next selection.

For example:

_traitor = [s1, s2, s3, s4] select floor(random 4);

hint format ["Traitor: %1", name _traitor]; CHOSEN S1;

_traitor = [s2, s3, s4] select floor(random 4);

hint format ["Traitor: %1", name _traitor];

Share this post


Link to post
Share on other sites

You can subtract from an array. Check here.

Example:

_units = [s1,s2,s3,s4];
_traitor = _units select floor (count _units);
hint format ["Traitor: %1", name _traitor];

_units = _units - [_traitor];

If S1 was selected _units is now [s2,s3,s4];

Share this post


Link to post
Share on other sites

I had alter the code because it wasnt returning any names:

_units = [s1,s2,s3,s4];

_traitor = _units select floor (random 4);

hint format ["Traitor: %1", name _traitor];

_units = _units - [_traitor];

But this still didnt work the way i'd like it too.

When i activate the script via addaction it sometimes repeats names. Therefore that name is not being removed from the array.

Im very new to scripting so some more help would be great

Share this post


Link to post
Share on other sites

It's a local array. It will be re-created everytime you run the script (and deleted on exit)

Here's a working example (please note that actions and hints are local to the client)

if (isNil "TAG_units") then 
{
 TAG_units  = [s1,s2,s3,s4];
};
_traitor = TAG_units select floor (random 4);

hint format ["Traitor: %1", name _traitor];
TAG_units = TAG_units - [_traitor];

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  

×