OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mr.BoDean on 13 Jun 2003, 09:14:12
-
I'm encountering problems using a triggered GroupChat message.
I have it set up like this in a Switch Trigger when all enemy are dead in the area:
P5,P6,P7,P8 GroupChat "Blahbety-Blah,Blah Blah"
(P5 thru P8 all being in the same group, P5 is the GroupLeader)
This seems to work fine , no matter who dies along the way, when an AI is the leader. However, if a player is the Group Leader and someone dies, the message doesn't show.
P5 also has mygrp = group this in his Init. line , so I tried using mygrp Groupchat "Blahbety-Blah,Blah Blah" but that failed also.
Hmm... ???
-
why don't you use a script to check who's alive and use the first one you found to groupChat?
Something like:
[p5, p6, p7, p8] exec "aliveNChat.sqs"
in aliveNChat.sqs:
_alldudes = _this;
_ndudes = count _alldudes;
_i = 0;
#checkLoop
?(_i == _ndudes) : goto "end"
_curdude = _alldudes select _i;
?(alive _curdude) : goto "speak"
_i = _i + 1;
goto "checkLoop"
#speak
_curdude groupChat "blah blah blah";
#end
exit
-
Ok, Thanks for that CMB :) , though it's a tad more complex than I'd hoped for. :o But since we're there ..... how would I exclude P5 from the list of possibles , since I want the message to come from one of his men ?
BTW , after having posted this, I found the original way to work much of the time for one of the GroupChat triggers and some of the time for the other one. (with Player Leader and 1 or 2 dead AI in the group) .... hmm
-
why don't you use a script to check who's alive and use the first one you found to groupChat?
Something like:
[p5, p6, p7, p8] exec "aliveNChat.sqs"
in aliveNChat.sqs:
_alldudes = _this;
_ndudes = count _alldudes;
_i = 0;
#checkLoop
?(_i == _ndudes) : goto "end"
_curdude = _alldudes select _i;
?(alive _curdude) : goto "speak"
_i = _i + 1;
goto "checkLoop"
#speak
_curdude groupChat "blah blah blah";
#end
exit
Ok, looking a little further at this script, I'm not sure who should actually be executing the script. ?? Does it matter?
And should I be replacing information where it says "alldudes" and "ndudes" for real player names and numbers?
Also, I'm a scripting newborn, but it seems like after the script goes thru the checkloop part the first time, having found the first guy dead, it will make i =1 and if that was the only one alive, it would goto end and exit without ever speaking. ???
Thanks for any help. :)
-
I thought you had a trigger doing the groupChat thing. If so, then use the same trigger to excute the script. No you shouldn't replace "_alldudes" and "_ndudes" to real player names because you've already parsed them in when you call the script.
See if you go [P6, P7, P8] exec "aliveNChat.sqs", I presume that P6, P7 and P8 are all names that you've assigned, so the value parsed into the script will be valide as well.
[P6, P7, P8] is parsed as an array into the script. In the script, you can access this array by using the variable "_this". What I did there is just trying to make things clearer by assigning a variable "_alldudes" to "_this" meaning it's the array of all the people's name you've parsed in. (obviously I failed :-[)
"_ndudes" is just the number of elements in the array, so if the array is parsed in proprely, when you do a count, it should return the right number.
About the loop, at the first time the loop runs. _i should be 0, which means it will take the first element of the _alldudes array. If he is the sole survivor, then he should speak when the loop runs the first time and exit. And let's say the first guy (p6) died, then _i will become 1, and _curdude will be the second element in the array and so on so forth.
btw,
?(alive _curdude) : goto "speak"
means if _curdude is alive, then speak. To check if the first guy is dead, will be:
? (!alive _curdude) : got "speak"
Hope that helped :).
-
Ok, CMB , thanks . So I did understand that line :
?(alive _curdude) : goto "speak"
I was just confused with the line:
?(_i == _ndudes) : goto "end"
because it looked like the second person would automatically make it go to the end, skipping the "speak" part. But now ,if I understand this correctly, since the script sees the array as 4 guys ID'd as 0 thru 3 instead of 1 thru 4 , it can identify each player before it counts up to the total number of them and end the script?? ???
BTW, I finally took a look at Johann G's script tutorial and maybe I was just too tired , but it was a bit overwhelming for my already-taxed brain and I just really want to finish my mission and get on with my life. :P :)
So thanks for the help in understanding this stuff.... you didn't fail at all, man! ;)
-
Hmmm well, except that now I'm getting the Object Error Expected Array message for the line:
_curdude = _alldudes select _i;
....no clue....?
DOH! :-X I didn't use the [ ] around the units before the EXEC command !
Works Great now, thanks! :)