OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: illmatic on 02 May 2004, 19:59:00

Title: On death - make dialog to player
Post by: illmatic on 02 May 2004, 19:59:00
@GetDammage _unit>= 1.0;
~0.2
ok = createDialog "alliesmenu"


im wanting when the unit dies a dialog comes up so ONLY he can see it, ive made the dialog and im just asking if anyone could help me here... im not sure that code above would work probaly if i just did 'this exec "die.sqs' in a units innit.
Title: Re:On death - make dialog to player
Post by: PsyWarrior on 02 May 2004, 21:39:24
Greetings,

Quote
@GetDammage _unit>= 1.0;
~0.2
ok = createDialog "alliesmenu"

If this is the whole script, it wouldn't work, as you haven't told OFP what "_unit" is. Also you have a semicolon on the end of the first line, which is not required.

Here's a possible correction:
Code: [Select]
; die.sqs
_unit = _this select 0

#loop
?damage _unit >= 1: goto "dialog"
~0.2
goto "loop"

#dialog
OK = createDialog "alliesmenu"
exit

exec: [this] exec "die.sqs"

When the unit respawns, you will have to re execute the script, or it will only work once.

Quote
a dialog comes up so ONLY he can see it,
I assume you're talking about multiplayer here?

If so, I don't know how much I can help you. However, here's a few thoughts:
AFAIK, any scripts executed on the client side that don't run also on the server, will only affect that client. So, if you ran the dialog only on the client (no publicVariables), only that person will see it. Obviously, this can be done (look at MFCTI - that is filled with dialogs that are seen by only one person at a time).

My experience is outside MP scripting, so I am of limited use here. But you could DEPBO MFCTI, (or some other MP mission which uses dialogs) and see how it was done there.

-Supreme Commander PsyWarrior
-Psychic Productions Studios
Title: Re:On death - make dialog to player
Post by: Chris Death on 02 May 2004, 22:55:41
hmm - in case it's multiplayer + respawn, i would rather
check for the player being alive instead of when he dies.

Reason: when the player dies, you might loose the unit
during the script, and some things might not work as the
player will become a new object - not sure what you're after,
but this can happen in some cases.

When the player respawns, an: alive unit condition will become
active (ok, this will also happen when the mission starts, but
to avoid it happening the first time should be no prob for you).

Also you could examine kegety's spectator script to find out
more about that.

:edit - btw - one thing i forgot;

If you exec a script with: this exec "script.sqs"

you can access the unit, who's init field was used by:

_unit = _this

If you exec a script with [this] exec "script.sqs"

you have to do like Psy Warrior said:

_unit = _this select 0

And to add one more: [this,anythingelse] exec "script.sqs"

you could say:

_unit = _this select 0
_anythingelse = _this select 1

~S~ CD
Title: Re:On death - make dialog to player
Post by: illmatic on 04 May 2004, 22:35:17
thXxX *KiSS*