Raised This Month: $ Target: $400
 0% 

Flashbang effect time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-17-2013 , 14:45   Flashbang effect time
Reply With Quote #1

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;


Last edited by Unkolix; 02-17-2013 at 14:47.
Unkolix is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 02-17-2013 , 14:58   Re: Flashbang effect time
Reply With Quote #2

What's about to try while statement.. ?
Torge is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-17-2013 , 15:01   Re: Flashbang effect time
Reply With Quote #3

I am not a very good scripter, I more like remaker.
Unkolix is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-17-2013 , 15:26   Re: Flashbang effect time
Reply With Quote #4

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().
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-17-2013 at 15:27.
ConnorMcLeod is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-17-2013 , 15:33   Re: Flashbang effect time
Reply With Quote #5

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.

Last edited by Unkolix; 02-17-2013 at 15:44.
Unkolix is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-17-2013 , 15:38   Re: Flashbang effect time
Reply With Quote #6

This is correct then, return value is self "explanative"

Also, cache get_user_msgid("ScreenFade") in plugin_init in a global var ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-17-2013 , 15:43   Re: Flashbang effect time
Reply With Quote #7

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 

Last edited by Unkolix; 02-17-2013 at 16:57.
Unkolix is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-17-2013 , 23:54   Re: Flashbang effect time
Reply With Quote #8

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-18-2013 , 02:17   Re: Flashbang effect time
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
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?
Unkolix is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-18-2013 , 02:43   Re: Flashbang effect time
Reply With Quote #10

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)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Old 02-18-2013, 02:51
Unkolix
This message has been deleted by Unkolix. Reason: Doesn't quite work
Old 02-24-2013, 16:19
Unkolix
This message has been deleted by Unkolix.
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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