AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved set_task according to flash duration (https://forums.alliedmods.net/showthread.php?t=299735)

Syturi0 07-24-2017 08:12

set_task according to flash duration
 
PHP Code:

public Event_Flashed(id)
{
    if(
g_b_IsAlive[id])
    {
        if(
g_b_IsMainMenuOpen[id] == true)
            
FecharMenuM(id)
        
        
g_b_IsPlayerFlashed[id] = true
        
        remove_task
(id TASK_FLASH)
        
set_task(12.0"RemoveFlash"id TASK_FLASH)
    }

    if(
g_b_HasHudSprite_Screenfade[id] == false)
    {
        
message_begin(MSG_ONEg_msgScreenfade, {0,0,0}, id)
        
write_short(read_data(1))            // Duration
        
write_short(read_data(2))            // Hold time
        
write_short(read_data(3))            // Fade type
        
write_byte(255)                    // Red
        
write_byte(255)                    // Green
        
write_byte(255)                    // Blue
        
write_byte(read_data(7))            // Alpha
        
message_end()
    }


When you throw a flash grenade far away, the flash duration will be only 1-2 seconds, but if you are close it will be 12 seconds.

I want to set the time on set_task according to the duration of the flash (far away = shorter, close = longer).

How can i do that.

klippy 07-24-2017 10:17

Re: set_task according to flash duration
 
You can get times by doing:
PHP Code:

new Float:duration float(read_data(1)) / (<< 12);
new 
Float:holdTime float(read_data(2)) / (<< 12); 


Syturi0 07-24-2017 10:56

Re: set_task according to flash duration
 
Works great KliPPy, thank you.


All times are GMT -4. The time now is 23:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.