Forum Jump :

Author Message


Posts: 4
Rank:


Level: Member

Country: de
Location: Baden-Würtemberg
Occupation:
Age: 20
In-game name: splash58

 
#1 Posted at 2017-03-24 20:27        
     
Hello guys,
I want to make a safezone script and every single script I saw were either not working or were really complicated.
So what I did is just setting down a trigger with the following parameters.
Type:
none
Activation:
Any Player
Activationtype:
present
repeatable:
true
server only:
false
Condition:
this

On Act:
player allowDamage false; hint parseText format["<t color= '#41c54a'>you have just entered the safezone</t>"];
On Deact:
player allowDamage true; hint parseText format["<t color= '#fa1107'>you just left the safezone</t>"];

This is working perfectly in Singleplayer. But on a MP server it works for some players but not for others. I think there is something wrong with the object class "player". I tried out a bunch of other object classes tho none were working. So is there any kind of Object that is defining the real players?

Thank you guys so much.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#2 Posted at 2017-03-25 00:03        
     
You can't do it with simple trigger because you need to refresh thislist (result for units satisfying the cond) and it's impossible without deact then react the trigger.

In fact, you don't need a trigger but loops checking for each player in some area.

Place a marker, ellipse one with the color you want to signal the area, say mkr1. You can even change the area color when activated.
In each init field of playable units, or in initPlayerLocal.sqf (at mission root),
write:
0 = this spawn { // (this select 0) for initPlayerLocal.sqf
  waitUntil {sleep 0.5; isPlayer _this};
  if (local _this) then {
    while {isPlayer _this} do {
      waitUntil {sleep 0.5; _this inArea "mkr1"};
      _this allowDamage false;
      hint "ok or what you want";
      waitUntil {sleep 0.5; !(_this inArea "mkr1")};
      _this allowDamage true;
      hint "nok or else"
    }
  }
};

This post was edited by Pierre MGI (2017-03-25 21:07, 211 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 4
Rank:


Level: Member

Country: de
Location: Baden-Würtemberg
Occupation:
Age: 20
In-game name: splash58

 
#3 Posted at 2017-03-25 15:14        
     
Hey, I put the script into "safezone.sqf".
I execute the script in the initPlayerLocal.sqf and I get the following script error when I join the server.

error, undefined variable in expression this (line 1)

thank you very much for your help btw


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#4 Posted at 2017-03-25 21:01        
     
<this> refers to the object/player here and the code works on init field of each playable unit as mentioned.
NB : In initPlayerLocal.sqf, you need to use (this select 0) instead of this (first line).

I have no idea what could be the safeZone.sqf script. You can call/spawn some scripts from initPlayerLocal.sqf but you need to pass the arguments also! (the reason why <this> is undefined)
So, just use the code as I wrote with (this select 0) instead of <this> and avoid to stack sqfs for so few lines of code.

This post was edited by Pierre MGI (2017-03-25 21:08, 211 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS