Matosh 34 Posted May 9, 2012 (edited) How can i make, when someone enters a car,plane or helicopter that he losses ammo and rifle ? Edited May 9, 2012 by matosinec Share this post Link to post Share on other sites
PELHAM 10 Posted May 9, 2012 while {true} do { if (vehicle player != player ) then { removeAllWeapons player; sleep 1; }; }; Share this post Link to post Share on other sites
Matosh 34 Posted May 9, 2012 will this still work after vehicle respawns? Share this post Link to post Share on other sites
[frl]myke 14 Posted May 9, 2012 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
Tankbuster 1733 Posted May 9, 2012 Myke;2147262'] mine not unless you add the EventHandler at respawn. According to Eventhandler page on Biki' date=' EH's are persistant. [url']http://community.bistudio.com/wiki/addEventHandler[/url] Share this post Link to post Share on other sites
PELHAM 10 Posted May 9, 2012 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
Matosh 34 Posted May 9, 2012 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
[frl]myke 14 Posted May 10, 2012 this addEventHandler ["GetIn", "if ((player == (_this select 2)) && ((_this select 1) == 'driver')) then {removeAllWeapons (_this select 2)}"]; Removes weapon on player when boarding as driver/pilot. Useful links: http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2 Share this post Link to post Share on other sites
mondkalb 1087 Posted May 10, 2012 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
Matosh 34 Posted May 10, 2012 It doesnt work anymore after respawn Share this post Link to post Share on other sites
[frl]myke 14 Posted May 10, 2012 It doesnt work anymore after respawn Player respawn or vehicle respawn? Share this post Link to post Share on other sites
[frl]myke 14 Posted May 10, 2012 vehicle Then please read post #4 in this thread. Share this post Link to post Share on other sites
Matosh 34 Posted May 10, 2012 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