Jump to content
Sign in to follow this  
McSpeed

Limit a trigger to certain units in MP

Recommended Posts

hmm that would be too easy but it doesnt work unfortunately.

That was one of the first things i tried.

The gatelock script i am using

 lock = true;

while {lock}
do {
gate2 animate ["Bargate",1];
sleep 0.01;
   }; 

does work... once.

as soon as a pilot opens the gate the lock is broken, i tried to re-initiate it by adding execvm "gate.sqf" to the deactivation line, but no joy.

the script Pelham has posted there seems more complex than the one i am using, but since i dont understand what he means in that last paragraph (public variables) i cant apply and test this one yet.

Share this post


Link to post
Share on other sites

It's not a simple thing to understand and it still gives me a headache sometimes, you need to read up on it:

Variables are only visible in certain areas (namespaces) of the game. This prevents name conflicts between different variables in different scripts.

There are three namespaces:

local: A variable is only visible in the script in which it was defined.

global: A variable is visible on the whole computer where it is defined.

public: A variable is broadcasted over the network and visible on all computers connected to the network.

http://community.bistudio.com/wiki/Variables

http://community.bistudio.com/wiki/Locality_in_Multiplayer

http://community.bistudio.com/wiki/6thSense.eu:EG

Share this post


Link to post
Share on other sites

ok just to make sure i actually understand what it is i am doing here :)

on Act: [color="#FF0000"]varlockg1=0;[/color] 
on Dea:[color="#FF0000"] varlockg1=1;[/color]

those lines call for an action as defined in the script, correct?

the action is defined here? (in the first line of the script)

[color="#FF0000"]varlockg1=1;[/color] 

trying to understand so ill translate it into english:

while{true}do{
   if((gate1 animationPhase "Bargate" [color="#FF0000"]< 1[/color]) && (varlockg1==1))[color="#0000CD"]then{gate1 animate ["Bargate",1]};[/color]
sleep 0.1;
};

while the defined state is active (true) close the gate

then{gate1 animate ["Bargate",1]};
provided that the gate is already closed AND the action is being called
if((gate1 animationPhase "Bargate" < 1) && (varlockg1==1))

am i getting this right?

what i definately dont understand are these 2 things:

< 1

and

sleep 0.1;

oh and why there are 2 "==" instead of just one.

sorry for being so difficult now, but if i dont actually understand what i am doing i will never learn :)

Edited by McSpeed

Share this post


Link to post
Share on other sites

You use == when you want to do "if a is equal to b".

You use = if you want "a becomes same as b".

Share this post


Link to post
Share on other sites

now it makes sense , of course. the difference between a definition and a comparison . thank you :)

Share this post


Link to post
Share on other sites
ok just to make sure i actually understand what it is i am doing here :)

on Act: [color="#FF0000"]varlockg1=0;[/color] 
on Dea:[color="#FF0000"] varlockg1=1;[/color]

those lines call for an action as defined in the script, correct?

the action is defined here? (in the first line of the script)

[color="#FF0000"]varlockg1=1;[/color] 

It's a global variable that is set to either 1 or 0 depending on the activation of the trigger.

1 is locked, 0 is unlocked, you will see the way I set it up is when the right kind of AI walks into the trigger it stops that locking while loop.

You always sleep in a while loop or it repeats too many times a second and crashes the game. We are asking it to check all that every 0.1 of a second.

for the rest look at the scripting command index.

Share this post


Link to post
Share on other sites

yay it now works just as it should \o/

thanks to you guys and mousetrap.:)

he understood what you were talking adout ( i didnt get that the public variable line was meant literally :) )

So he implemented it for me and now , looking at it, it does indeed make perfect sense.

When it comes to code its like i have a peas for brains sometimes :)

thanks to you all.

to sum this one up:

place a gate, name it gate2 (in this case, else replace a the following "gate2" entries with whatever name you chose)

enter in the gates init:

gate2 animate ["Bargate", 1]; this addEventHandler ["HandleDamage", {false}];

locking gates!

Lock the gate :

add this to init.sqf:

 [] execVM "gatelock.sqf";

create a text file gatelock.sqf:

varlockg1=1;
while{true}do{
   if((gate2 animationPhase "Bargate" < 1) && (varlockg1==1))then{gate2 animate ["Bargate",1]};
sleep 0.1;
};

set the trigger and fill out like so: (ignore the sold1 playmove line, it refers to a guard next to the gate)

05-04-2012-14-27-14.png

thats it :)

problem solved.

thanks again to all who helped.

Edited by McSpeed

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×