Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Doggolainen

Whats the name of the current player/unit

Recommended Posts

I want to create a field, so if one enters it, he/she dies instantly.

Im using the

player setDamage 1
right now. But I wish to change the "player" to something global. So I can say that any opfor/bluefor entering will die.

Share this post


Link to post
Share on other sites

Create a trigger covering the area, activated by anybody and set it to repeatedly

In the on activation box:

{_X setdamage 1} foreach thislist

:)

Share this post


Link to post
Share on other sites

Thislist returns a list of all units in the trigger. _X is a reserved variable used in forEach (and other commands such as count) blocks that can be used to reference the current element as it iterates through an array.

Share this post


Link to post
Share on other sites

I'm sure someone can explain it better than me, but I'll have a go.

One way of explaining _x is when it's used in

{_x} foreach
you can apply multiple commands to an array. I used to get awfully confused about arrays and didn't understand them at all as I have zero experience of programming. The way I think of arrays is somewhere to store stuff. Thislist is an array of everything in the trigger.

Why would you want to do that you may ask, to save time and typing or like in the question you asked where you don't know the identity of something.

Say you have 3 groups of units in the editor that you want to reduce the skill of and remove all their weapons. You can edit each units' skill slider (tedious) and type the command into the init box of each units (very tedious) or you can have a trigger covering all 3 groups with:

{_x setskill 0.1; removeallweapons _x} foreach thislist.

This command will then apply to everyone in the trigger area. Where you would previously have put player setskill 0.1 you replace player with _x.

That probably reads like a load of drivel so have a rummage around OFPEC http://www.ofpec.com/index.php

Share this post


Link to post
Share on other sites
Sign in to follow this  

×