Jump to content
Sign in to follow this  
Matosh

removeweapons when enter

Recommended Posts

How can i make, when someone enters a car,plane or helicopter that he losses ammo and rifle ?

Edited by matosinec

Share this post


Link to post
Share on other sites
while {true} do {
   if (vehicle player != player ) then {
       removeAllWeapons player;
           sleep 1;
   };
};

Share this post


Link to post
Share on other sites

will this still work after vehicle respawns?

Share this post


Link to post
Share on other sites
while {true} do {
   if (vehicle player != player ) then {
       removeAllWeapons player;
           sleep 1;
   };
};

Uh oh....endless looped script...bad scripting behaviour. ;)

Better use a method that only gets active when really necessary: EventHandlers

this addEventHandler ["GetIn", "if (player == (_this select 2)) then {removeAllWeapons (_this select 2)}"];

This goes in the vehicles (not playable units) initline.

:EDITH:

will this still work after vehicle respawns?

PELHAM's will, mine not unless you add the EventHandler at respawn.

Share this post


Link to post
Share on other sites
Myke;2147262']Uh oh....endless looped script...bad scripting behaviour. ;)

;) Nice solution, true you shouldn't use loops when there is another method or just don't use too many!

Share this post


Link to post
Share on other sites

I forgot to mention in first post, only when you enter as pilot/driver to get all weapons removed.

Share this post


Link to post
Share on other sites

Since you were going on about bad scripting behaviour... ;)

This is one of those:

(_this select 1) == 'driver'

String comparisons are very expensive, try to avoid them as often as possible. Especially in looped cases.

Run a check if the unit is the driver of the vehicle instead:

(_this select 2) == driver (_this select 0)

Share this post


Link to post
Share on other sites

It doesnt work anymore after respawn

Share this post


Link to post
Share on other sites

I was thinking more on pilot/driver code but nevermind, thank you all for your help.

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  

×