So I've been working on a script using the extra_rc.hpp script to make a new tool function. A headlamp or lantern if you prefer. (In effect it is really more like the latter.) The lamp part works perfectly, but I am unable to shut it off afterwards. Here is what I have so far:
if (isNil "headlamp") then { headlamp = 0; }; if (headlamp == 0) then { _hlight = "#lightpoint" createVehicle (getpos player); _hlight setLightAmbient [.15, .15, .15]; _hlight setLightColor [.15, .12, .10]; _hlight setLightBrightness .25; setaperture -1; _hlight setDir (getDir player); _hlight attachTo [(vehicle player), [0,0,1.5]]; Sleep 0.1; headlamp = 1; hint "Headlamp ON"; } else { Sleep 0.1; detach _hlight; _hlight setPosATL [-10000,-10000,100000]; Sleep 0.1; deleteVehicle _hlight; Sleep 0.1; headlamp = 0; hint "Headlamp OFF"; };
It never makes it to "Headlamp OFF". It is having trouble detaching the light from the player and it can't delete it while it is attached. Any ideas? Am I just using the command wrong?