No problems for such man
I saw your code, I earlier did not know and has peeped it from source RACC bot
, and earlier at me was so:
PHP Code:
void Bot:: SwitchFlashlight (bool on)
{
// this function switches on/off the flashlight of a bot.
if
(
(on && (!g_botVar[Variable_FlashLight]->GetBool () || (pev->effects & EF_DIMLIGHT) || m_flashLightBattery == 0 || !IsAlive (GetEntity ()))) ||
(!on && !(pev->effects & EF_DIMLIGHT))
)
return;
if (on)
pev->effects |= EF_DIMLIGHT;
else
pev->effects &= ~EF_DIMLIGHT;
// emit flashlight sound
EMIT_SOUND_DYN2 (GetEntity (), CHAN_VOICE, "items/flashlight1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
And charging of the battery occured so:
PHP Code:
if (pev->effects & EF_DIMLIGHT)
{
static float dischargingFlashLightBatteryTime = 0.0;
if (m_flashLightBattery > 0 && dischargingFlashLightBatteryTime + 1.2 <= GetWorldTime ())
{
m_flashLightBattery--;
dischargingFlashLightBatteryTime = GetWorldTime ();
}
}
else
{
static float chargingFlashLightBatteryTime = 0.0;
if (m_flashLightBattery < 100 && chargingFlashLightBatteryTime + 0.2 <= GetWorldTime ())
{
m_flashLightBattery++;
chargingFlashLightBatteryTime = GetWorldTime ();
}
}
You see as I counted up, complete discharging of the battery occurs for 2 minutes and complete charging for 20 seconds.