Yourry
May 25 2012, 22:28
Hello Everyone,
I want to create flashlight on the player weapon.
I rad the thread and I tried to find a solution (without addons):
http://forums.bistudio.com/showthread.php?110943-Still-no-flashlight-scripts-for-ak-weapons-or-way-to-alter-ingame-reality
So I wrote this script:
////////////////////////////////////////////
// Fait par =[TTK]= Yourry //
////////////////////////////////////////////
private ["_unit", "_player", "_center", "_group", "_light"];
//On défini le joueur
_unit = player;
_player = call compile format["%1",_unit];
//On défini la variable à faux
player setVariable["lampe_on",false,true];
if(local player) then {
while {alive _player} do {
waituntil{vehicle _player == _player};
action_allumer = _player addaction ["<t color='#33ff00'>Allumer lampe</t>","scripts\lampe.sqf",["allumer"], 0, false, true, "", " !(player getvariable""lampe_on"") "];
waituntil{(_player getvariable"lampe_on")};
_player removeaction action_allumer;
light = "Old_moto_TK_Civ_EP1" createVehicleLocal [0,0,0];
light setvehicleInit"hideObject this;this allowDamage false; this addEventHandler [""HandleDamage"", {false}]";
processInitCommands;
light setpos getpos _player;
_player action ["lightOn",light];
light attachTo [_player,[0,-3,1]];
action_eteindre = _player addaction ["<t color='#00ccff'>Eteindre lampe</t>","scripts\lampe.sqf",["eteindre"], 0, false, true, "", " player getvariable""lampe_on"" "];
while{(_player getvariable"lampe_on") || alive _player ||!isnull light || count [(currentWeapon _player)] > 0 ||vehicle _player != _player}do{sleep 1;};
_player action ["lightOFF",light];
light removeEventHandler ["HandleDamage",0];
deletevehicle light;
_player removeaction action_eteindre;
};
waituntil{!alive _player};
if(!isnil"action_eteindre")then{_player removeaction action_eteindre;};
if(!isnil"action_allumer")then{_player removeaction action_allumer;};
if(!isnull "light")then{_player action ["lightOFF",light];light removeEventHandler ["HandleDamage",0];;deletevehicle light};
_player setVariable["lampe_on",false,true];
};
It works well but I can not move the flashlight when the player looks up or down.
I tried in the "while" :
_weapon=(weapons _player) select 0;
_dir = _player weaponDirection _weapon;
light setVectorDir (_dir);
light setVectorUp (_dir);
_getpos = getpos _player;
light setpos _getpos
;
But this does not work.
How to change the angle of the headlights when the player looks down or up ?
Thank you very much
I want to create flashlight on the player weapon.
I rad the thread and I tried to find a solution (without addons):
http://forums.bistudio.com/showthread.php?110943-Still-no-flashlight-scripts-for-ak-weapons-or-way-to-alter-ingame-reality
So I wrote this script:
////////////////////////////////////////////
// Fait par =[TTK]= Yourry //
////////////////////////////////////////////
private ["_unit", "_player", "_center", "_group", "_light"];
//On défini le joueur
_unit = player;
_player = call compile format["%1",_unit];
//On défini la variable à faux
player setVariable["lampe_on",false,true];
if(local player) then {
while {alive _player} do {
waituntil{vehicle _player == _player};
action_allumer = _player addaction ["<t color='#33ff00'>Allumer lampe</t>","scripts\lampe.sqf",["allumer"], 0, false, true, "", " !(player getvariable""lampe_on"") "];
waituntil{(_player getvariable"lampe_on")};
_player removeaction action_allumer;
light = "Old_moto_TK_Civ_EP1" createVehicleLocal [0,0,0];
light setvehicleInit"hideObject this;this allowDamage false; this addEventHandler [""HandleDamage"", {false}]";
processInitCommands;
light setpos getpos _player;
_player action ["lightOn",light];
light attachTo [_player,[0,-3,1]];
action_eteindre = _player addaction ["<t color='#00ccff'>Eteindre lampe</t>","scripts\lampe.sqf",["eteindre"], 0, false, true, "", " player getvariable""lampe_on"" "];
while{(_player getvariable"lampe_on") || alive _player ||!isnull light || count [(currentWeapon _player)] > 0 ||vehicle _player != _player}do{sleep 1;};
_player action ["lightOFF",light];
light removeEventHandler ["HandleDamage",0];
deletevehicle light;
_player removeaction action_eteindre;
};
waituntil{!alive _player};
if(!isnil"action_eteindre")then{_player removeaction action_eteindre;};
if(!isnil"action_allumer")then{_player removeaction action_allumer;};
if(!isnull "light")then{_player action ["lightOFF",light];light removeEventHandler ["HandleDamage",0];;deletevehicle light};
_player setVariable["lampe_on",false,true];
};
It works well but I can not move the flashlight when the player looks up or down.
I tried in the "while" :
_weapon=(weapons _player) select 0;
_dir = _player weaponDirection _weapon;
light setVectorDir (_dir);
light setVectorUp (_dir);
_getpos = getpos _player;
light setpos _getpos
;
But this does not work.
How to change the angle of the headlights when the player looks down or up ?
Thank you very much