Home   Help Search Login Register  

Author Topic: Become leader  (Read 3027 times)

0 Members and 2 Guests are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
Become leader
« on: 22 Feb 2005, 01:05:33 »
Here is a simple script to become leader of your group during a mission, even if your rank is lower then anyone else in the group.


Run it like this : [group player] exec "Become_leader.sqs"

Become_leader.sqs
Code: [Select]
_grp = _this select 0
?leader _grp == player :exit

enableradio false

[player] join grpnull

(units _grp) join group player

~4
enableradio true
exit

Tadaa!

« Last Edit: 22 Feb 2005, 01:18:36 by Blanco »
Search or search or search before you ask.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Become leader
« Reply #1 on: 22 Feb 2005, 22:37:57 »
Handy, but (there had to be a but!) is it possible to transfer the original group's name across to the new one to make it foolproof?  That way a user can refer to the group name as or 'Group player' as convenient and not be forced into the latter.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Become leader
« Reply #2 on: 22 Feb 2005, 23:12:58 »
uh, thats a no

you can't change a global variable from inside a script without actually putting that variable in the script, which obviously he can't do.

but you could combine this with another custom script that will call the script, have a short delay (1 or 2 sec) which then updates the varible you have set for the player's group

(all names - be it group names, unit names, etc - are just variables)

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Become leader
« Reply #3 on: 22 Feb 2005, 23:37:11 »
What about:
Code: [Select]
_grp = _this select 0
?leader _grp == player :exit

enableradio false

_men = (units _grp) - [player]
{[_x] join grpnull} foreach _men
{[_x] join _grp} foreach _men

(units _grp) join group player

~4
enableradio true
exit

would the leaving/joining process of the rest of the group (which is basically all this is) reassign the player as leader? I think it might do.
« Last Edit: 22 Feb 2005, 23:37:43 by Fragorl »

Offline 456820

  • Contributing Member
  • **
Re:Become leader
« Reply #4 on: 22 Mar 2005, 10:02:48 »
what about a become squady again script so you can then become leader then become a member again

Offline Blanco

  • Former Staff
  • ****
Re:Become leader
« Reply #5 on: 24 Mar 2005, 02:21:40 »
That's possible, but it creates a problem.
I have this :

[] exec "becomeldr.sqs"

Code: [Select]
_grp = group player
?(leader _grp != player) : goto "becomeldr"

_men = (units _grp) - [player]
_grp = group (_men select 0)

[player] join grpnull
~1
[player] join _grp

exit

#becomeldr
enableradio false

[player] join grpnull

(units _grp) join group player

~4
enableradio true
exit

The script checks you're the leader or not, when you're in command you'll become a member, when you're a member you'll become leader. It works but there is a problem.

Once you become a leader and a bit later a member, it looks like the waypoints disappear...
I think I know why, but I can't explain it in English...  :-\
But I'm pretty sure it has something to with the stuff ACF mentioned.
Search or search or search before you ask.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Become leader
« Reply #6 on: 24 Mar 2005, 16:15:06 »
This is because the player joins grpNull and then the others join him, grpNull has no waypoints, and everyone has left the original group.  To make the player become the leader without losing the waypoints you should have all the others  join grpNull and then join the player.  That way the original group name and its waypoints will not be lost.  That is:

#becomeldr
_men = (units _grp) - [player]
_men join grpNull
_men join player

This keeps the original group in exitence throughout

I put a script for doing this on one of the ofpec boards months ago and tested it by having a group run round several waypoints changing the leader each time.  They did not lose their waypoints  I am overseas at the moment.  When I get back I will see if I can find it.

EDIT:
Found one of them:
http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=20074;start=0

Is this something I should have put in the Editors Dept?
« Last Edit: 24 Mar 2005, 16:52:17 by THobson »

Offline Blanco

  • Former Staff
  • ****
Re:Become leader
« Reply #7 on: 24 Mar 2005, 18:31:37 »
thx, your way is better. The only thing you have to do is to name the new leader and run the script. Handy.
ATM my old script is in the pending board
http://www.ofpec.com/editors/resource_view.php?id=770

I can update it with your script and give you the credits off course, but I'll wait for your permission.
In attachment, a testmission.








 




« Last Edit: 25 Mar 2005, 00:03:40 by Blanco »
Search or search or search before you ask.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Become leader
« Reply #8 on: 24 Mar 2005, 23:18:29 »
Forgive me if this seems little jaundiced - but I am quite pissed off with the scripting community here at the moment.  I recently submitted a script that enables a mission developer to cycle through all the faces, all the mimics and all the voices using in game ‘people' so you can see faces and expressions on real units.  This is particularly important for female units where the same face can look very different on different women.  What do I get - nothing, nada, zip.

Some weeks later a more famous individual puts on a set of static portraits for each face that really do not enable you to see how the different faces look on different units.  You cannot see the effect of different mimics, nor does it help you choose between different voices and what happens - people fall over themselves in eulogy.

I guess my script will get more attention if it is published under your name.  Please feel free - all I ask is that you put my name in the script.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Become leader
« Reply #9 on: 25 Mar 2005, 00:22:43 »
Code: [Select]
...
_men = (units _grp) - [player]
{[_x] join grpnull} foreach _men
{[_x] join _grp} foreach _men[/b]

(units _grp) join group player
...

Isn't this exactly what you're saying, THobson?  :-\
« Last Edit: 25 Mar 2005, 00:24:57 by Fragorl »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Become leader
« Reply #10 on: 25 Mar 2005, 00:38:54 »
Well it would have the same effect, and you don't need the line:

(units _grp) join group player

becasue by then _grp is only the player

but why do:
{[_x] join grpnull} foreach _men
{[_x] join _grp} foreach _men

when you could do:
_men join grpNull
_men join player
« Last Edit: 25 Mar 2005, 00:40:36 by THobson »

Offline Blanco

  • Former Staff
  • ****
Re:Become leader
« Reply #11 on: 25 Mar 2005, 00:53:50 »
hmmm, I had the same feeling about this a year and a half ago.
Scripters and missionmakers don't get the attention they deserve. We all know the story and I've learned to live with it.

A tip : put a link to your script(s) in your signature. It really helped 4 me.

Anyway, I'll submit it to the pending board in your place, but I will feel bad when I do it under my name.


 
Search or search or search before you ask.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Become leader
« Reply #12 on: 25 Mar 2005, 01:01:31 »
THobson:

Yes, your way is better, and yes, that line you mentioed is superfluous; i can't actually remember I put it in :P. But they do essentially the same thing, i was just wondering why it was ignored. But it doesn't really matter.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Become leader
« Reply #13 on: 25 Mar 2005, 05:52:48 »
Quote
A tip : put a link to your script(s) in your signature. It really helped 4 me.
Good idea.  I will have look at doing that

Quote
Anyway, I'll submit it to the pending board in your place, but I will feel bad when I do it under my name.
You shouldn't.  You didn't steal it and pretend it was yours, you put yours here first.  Just look at it as giving me a bit of publicity. :)

@fragorl:
I feel I am ignored most of the time - but I am just a sensitive soul.
« Last Edit: 25 Mar 2005, 08:03:28 by THobson »