AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Flashbang effect time (https://forums.alliedmods.net/showthread.php?t=208805)

Unkolix 02-17-2013 14:45

Flashbang effect time
 
I have this code and I need to set gbPlayerScreenFading[id] = true if player has his screen fading and set it to false if the fading is over. If you know the event to catch when it's over or how long flashbang fading effect lasts, please tell me :/
PHP Code:

register_event("ScreenFade""EventFlashbang""b""4=255""5=255""6=255""7=200""7=255")
/***/
public EventFlashbang(id)
{
    
gbPlayerScreenFading[id] = true
    
set_task(HOWLONG"ScreenFadingOver" ,id)
}
/***/
public ScreenFadingOver(id)
{
    
gbPlayerScreenFading[id] = false;



Torge 02-17-2013 14:58

Re: Flashbang effect time
 
What's about to try while statement.. ?

Unkolix 02-17-2013 15:01

Re: Flashbang effect time
 
I am not a very good scripter, I more like remaker.

ConnorMcLeod 02-17-2013 15:26

Re: Flashbang effect time
 
PHP Code:

#include <fakemeta>

const m_flFlashedUntil 514

is_user_flashed
id )
{
    return 
get_gametime() < get_pdata_float(idm_flFlashedUntil)


Also, do never use tasks to set cooldowns, use float vars and get_gametime, or integer vars and get_systime().

Unkolix 02-17-2013 15:33

Re: Flashbang effect time
 
This checks if the user is flashed, can you explain the return value? And look is this correct?
PHP Code:

if( !is_user_flashedid ) )  
{
    
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller)
    
write_short(1<<10)
    
write_short(1<<10)
    
write_short(0x0000)
    
write_byte(0)
    
write_byte(0)
    
write_byte(200)
    
write_byte(75)
    
message_end()


This should create a fade if player is not flashed.

ConnorMcLeod 02-17-2013 15:38

Re: Flashbang effect time
 
This is correct then, return value is self "explanative" :)

Also, cache get_user_msgid("ScreenFade") in plugin_init in a global var ;)

Unkolix 02-17-2013 15:43

Re: Flashbang effect time
 
But I get undefined symbol is_user_flashed, fakemeta was already included

Do I have to write
PHP Code:

is_user_flashedid )
{
    return 
get_gametime() < get_pdata_float(idm_flFlashedUntil)


right after?
PHP Code:

const m_flFlashedUntil 514 


ConnorMcLeod 02-17-2013 23:54

Re: Flashbang effect time
 
const m_flFlashedUntil = 514 has to be at top of plugin where you declare other variables, so above plugin_init.

is_user_flashed function can be where you want but has to be somewhere in the plugin if you want to be able to use it.

Unkolix 02-18-2013 02:17

Re: Flashbang effect time
 
Quote:

Originally Posted by ConnorMcLeod (Post 1896600)
is_user_flashed function can be where you want but has to be somewhere in the plugin if you want to be able to use it.

I don't have to include it to public function?

ConnorMcLeod 02-18-2013 02:43

Re: Flashbang effect time
 
No, this should stay a private function.

Something like that :

PHP Code:

#include <amxmodx>
#include <fakemeta>

const m_flFlashedUntil 514 

public plugin_init()
{
    
// blabla
}

public 
/* or not public */ your_functionid )
{
    if( !
is_user_flashedid ) )  
    {
        
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller)
        
write_short(1<<10)
        
write_short(1<<10)
        
write_short(0x0000)
        
write_byte(0)
        
write_byte(0)
        
write_byte(200)
        
write_byte(75)
        
message_end()
    }  
}

is_user_flashedid )
{
    return 
get_gametime() < get_pdata_float(idm_flFlashedUntil)




All times are GMT -4. The time now is 21:41.

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