Hello,
I want to make a flashlight for my horror-survival game. The battery of the flashlight should be empty in 300 seconds and flashlight should be automatically go off.
I used this code:
var x = 1;
var battery = 300;
function flashlight(ENTITY* ent){
if(battery>0){
my.ambient = 100;
my.lightrange = 150;
}
while((battery>0)){
wait(-1);
battery = battery - x;
}
my.ambient = 0;
my.lightrange = 0;
}
Action (){
if(key_f) flashlight(me);
}
The Problem is that the flashlight does go off in a few seconds Long before 300 seconds.
I watched the var battery and it fells rapid and not with the value of 1 in 1 second like in the code.
(Sorry my english is not so good - i am german^^)
Can anyone tell me why the flashlight goes off before 300 seconds are gone??