Jump to content
Sign in to follow this  
mr.peanut

Detect players group leader on ded server

Recommended Posts

Okay. I need a reliable way to determine who is leader of a player group, on a dedicated server.  I want to enable to radio for leaders only, and when a leader dies I want the radio enabled for the new leader.

My init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">showRadio FALSE

[] exec "radioenable.sqs"

My script radioenable.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#loop

~5

if ((leader player) == player) then {showRadio TRUE; hint localize "STR_RADIOENABLED"; exit}

if (((units group player) select 0) == player) then {showRadio TRUE; hint localize "STR_RADIOENABLED"; exit}

if not(alive player) then {exit}

goto "loop"

In paranoia I put in two test, but neither seem to work properly.  If there is one AI in my group, and the AI is leader, when I kill him I do not get the hint or my radio.

If there are many AI in my group, and I am second in rank and kill the AI leader, the script does work.

Can anyone enlighten me about htis. On a nondedicated server it works fine, but not on a dedicated.

Share this post


Link to post
Share on other sites

Well, apart from the fact that it's enableRadio, wich we already discussed in another thread, there is a small problem with the leader command:

It takes a while (sometimes it feels like forever) after one unit dies, but before the rest of the group registers him as dead. Maybe that's the problem? I recall that General Barron once stated that the leader command didn't work very well in MP for these reasons. But since Ofpec is down I cannot find the thread about MP scripting commands.

Share this post


Link to post
Share on other sites
Well, apart from the fact that it's enableRadio, wich we already discussed in another thread, there is a small problem with the leader command:

It takes a while (sometimes it feels like forever) after one unit dies, but before the rest of the group registers him as dead. Maybe that's the problem? I recall that General Barron once stated that the leader command didn't work very well in MP for these reasons. But since Ofpec is down I cannot find the thread about MP scripting commands.

Thanks... I will test again and patiently wait a bit longer.  The weird thing is that it works when there are many AI in group but not when there is one AI in group and he is leader.

Share this post


Link to post
Share on other sites

You could try kicking the dead group leader out of the group:

Into a trigger:

condition: not alive (leader group player)

statement: [(leader group player)] join grpNull

type: "repeatedly"

countdown: some other value than zero probably

This is taken from a LDD Kyllikki forum post. Original text is talking about how the leadership doesn't automatically change in multiplayer after the group leader dies. Can anyone verify if this is still true?

It's worth a try.

Share this post


Link to post
Share on other sites

Odd thing is, I thought my second check, the one that sees if the player is the zero element of an array of his group, would work if the leader command failed, but it does not work either. However, it might work if the leader is assigned grpNull!

Share this post


Link to post
Share on other sites

The first person in the group is not always the leader.

I would do:

if ( player == leader (group player) ) then { blah }

--Ben

Share this post


Link to post
Share on other sites
Original text is talking about how the leadership doesn't automatically change in multiplayer after the group leader dies. Can anyone verify if this is still true?

I think this was what General Barron refered to in his post at Ofpec. The command leader seems to be returning the name of the original leader of the group, even though he is dead or forced to leave the group with grpNull commands  banghead.gif

I have no MP testing oportunities until next weekend, unfortunately.

Share this post


Link to post
Share on other sites

Oh man... you are in for a real pain.

Even if you figure out the 'dead' part... just wait until the players start boarding vehicles!!!

If you want your work done soon, I would simply attach a "Killed" event handler to the leader and when fired, I would make the radio change hands... perhaps even with a delay.

Although if you are REALLY creative.. I would make it such that if a player is actually carrying a radio they get the commands. The interesting thing about that is you can give the radio to a subordinate (player) and have the leader bark orders smile_o.gif If the leader/radio carrier dies, the other units must find that radio!! I've done this before... I've even set it up such that a radio carried by the AI will allow another player to walk up and activate the actions.... I'll dig for it and report back.

---Side Thought---

Has anyone tried publicvariable with the unit... supposedly you can PV a unit... maybe that'll make the leader "dead"??

EDIT:

WAIT A SEC! I thought only leaders get the radio & radio commands automatically? Why are you 'checking' and disabling it when the engine does it automatically?

Share this post


Link to post
Share on other sites

Okay,

I added benreeper's suggested line to my script and another line that checks if the player is the only one alive in his group.  I then added a server script that checks every five seconds to see if the leader of a group is dead and if so joins him to GrpNull.  This seems to work.

Now another strange thing happens.  The radio appears on the map screen, but the radio commands via keystrokes are not available.  This does not happen each time.

Anybody have a copy of Gen Barron's Rank function or know if it would solve this problem?

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  

×