AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] cs flashbangs- all players dissapear no white screen (https://forums.alliedmods.net/showthread.php?t=174008)

csykosoma 12-14-2011 00:12

[REQ] cs flashbangs- all players dissapear no white screen
 
i could not find a plugin that does this

in cs 1.6, instead of flashbang turning the screen white, the flashbang makes all players disappear then slowly fade the players back in. while flash, you can still hear all players sound. if flashbang lands behind the player, then players are only half visible.

basically, flashbang effect without turning the screen white.


this is plugin that does the opposite and is not what i want
http://forums.alliedmods.net/showthread.php?t=15585

ConnorMcLeod 12-14-2011 01:23

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Nice idea.
Try the following code, if it works as expected and if you can install hamsandwich UPDATED module, i can simplfy the code a bit to be more efficient.

PHP Code:

/*    Formatright @ 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "Flash Disappear Players"

const XO_PLAYER 5
const m_flFlashedUntil 514
const m_flFlashedAt 515
const m_flFlashHoldTime 516
const m_flFlashDuration 517
const m_iFlashAlpha 518

const ALPHA_FULLBLINDED 255

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_forward(FM_AddToFullPack"AddToFullPack_Post"1)
    
register_message(get_user_msgid("ScreenFade"), "Message_ScreenFade")
}

public 
Message_ScreenFade()
{
    if(    
get_msg_arg_int(4) == 255
    
&&    get_msg_arg_int(5) == 255
    
&&    get_msg_arg_int(6) == 255
    
&&    get_msg_arg_int(7) > 199    )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
AddToFullPack_Post(eseiEntidhostflagsplayerpSet)
{
    if( 
player && id != iEnt && get_orig_retval() && is_user_alive(id) )
    {
        static 
iFlashiPercent
        iFlash 
get_user_flashed(idiPercent)
        if( 
iPercent )
        {
            
set_es(esES_RenderModekRenderTransAlpha)
            
set_es(esES_RenderAmt255 - (iFlash iPercent) / 100)
        }
    }
}

get_user_flashed(id, &iPercent=0)
{
    new 
Float:flFlashedAt get_pdata_float(idm_flFlashedAtXO_PLAYER)

    if( !
flFlashedAt )
    {
        return 
0
    
}

    new 
Float:flGameTime get_gametime()
    new 
Float:flTimeLeft flGameTime flFlashedAt
    
new Float:flFlashDuration get_pdata_float(idm_flFlashDurationXO_PLAYER)
    new 
Float:flFlashHoldTime get_pdata_float(idm_flFlashHoldTimeXO_PLAYER)
    new 
Float:flTotalTime flFlashHoldTime flFlashDuration

    
if( flTimeLeft flTotalTime )
    {
        return 
0
    
}

    new 
iFlashAlpha get_pdata_int(idm_iFlashAlphaXO_PLAYER)

    if( 
iFlashAlpha == ALPHA_FULLBLINDED )
    {
        if( 
get_pdata_float(idm_flFlashedUntilXO_PLAYER) - flGameTime 0.0 )
        {
            
iPercent 100
        
}
        else
        {
            
iPercent 100-floatround(((flGameTime - (flFlashedAt flFlashHoldTime))*100.0)/flFlashDuration)
        }
    }
    else
    {
        
iPercent 100-floatround(((flGameTime flFlashedAt)*100.0)/flTotalTime)
    }

    return 
iFlashAlpha



csykosoma 12-14-2011 05:11

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
yes this works exactly as described. i do plan on putting this on a 32 person server, so more efficiency is welcomed. i can put this hamsandwich update if you recommend:

https://forums.alliedmods.net/showpo...9&postcount=34

one concern is not being able to confirm if you are blind, except if other players/teammates are around. new players are already very confused. if i could have my way, have current flash percentage (00-100) to the right of the round time in the same font as the money and time.

ConnorMcLeod 12-14-2011 14:16

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Yes, install that hamsandwich version and try with this plugin version :
Gonna think about your request later.

PHP Code:

/*    Formatright @ 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.2"
#define PLUGIN "Flash Disappear Players"
/*
const XO_PLAYER = 5
const m_flFlashedUntil = 514
const m_flFlashedAt = 515
const m_flFlashHoldTime = 516
const m_flFlashDuration = 517
const m_iFlashAlpha = 518
*/

const MAX_PLAYERS 32

const ALPHA_FULLBLINDED 255

enum mFlashDatas
{
    
Float:m_flFlashedUntil,
    
Float:m_flFlashedAt,
    
Float:m_flFlashHoldTime,
    
Float:m_flFlashDuration,
    
m_iFlashAlpha
}

new 
g_iPlayerFlashDatas[MAX_PLAYERS+1][mFlashDatas]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_forward(FM_AddToFullPack"AddToFullPack_Post"1)
    
register_message(get_user_msgid("ScreenFade"), "Message_ScreenFade")
    
RegisterHam(Ham_CS_Player_Blind"player""CBasePlayer_Blind_Post"1)
}

public 
Message_ScreenFade()
{
    if(    
get_msg_arg_int(4) == 255
    
&&    get_msg_arg_int(5) == 255
    
&&    get_msg_arg_int(6) == 255
    
&&    get_msg_arg_int(7) > 199    )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CBasePlayer_Blind_Post(idFloat:flBlindTimeFloat:flFlashDurationFloat:flFlashHoldTimeiFlashAlpha)
{
    new 
Float:flGameTime get_gametime()
    
g_iPlayerFlashDatas[id][m_flFlashedUntil] = _:(flGameTime flBlindTime)
    
g_iPlayerFlashDatas[id][m_flFlashedAt] = _:flGameTime
    g_iPlayerFlashDatas
[id][m_flFlashHoldTime] = _:flFlashHoldTime
    g_iPlayerFlashDatas
[id][m_flFlashDuration] = _:flFlashDuration
    g_iPlayerFlashDatas
[id][m_iFlashAlpha] = iFlashAlpha
}

public 
AddToFullPack_Post(eseiEntidhostflagsplayerpSet)
{
    if( 
player && id != iEnt && get_orig_retval() && is_user_alive(id) )
    {
        static 
iFlashiPercent
        iFlash 
get_user_flashed(idiPercent)
        if( 
iPercent )
        {
            
set_es(esES_RenderModekRenderTransAlpha)
            
set_es(esES_RenderAmt255 - (iFlash iPercent) / 100)
        }
    }
}

get_user_flashed(id, &iPercent=0)
{
    new 
Float:flFlashedAt g_iPlayerFlashDatas[id][m_flFlashedAt]

    if( !
flFlashedAt )
    {
        return 
0
    
}

    new 
Float:flGameTime get_gametime()
    new 
Float:flTimeLeft flGameTime flFlashedAt
    
new Float:flFlashDuration g_iPlayerFlashDatas[id][m_flFlashDuration]
    new 
Float:flFlashHoldTime g_iPlayerFlashDatas[id][m_flFlashHoldTime]
    new 
Float:flTotalTime flFlashHoldTime flFlashDuration

    
if( flTimeLeft flTotalTime )
    {
        return 
0
    
}

    new 
iFlashAlpha g_iPlayerFlashDatas[id][m_iFlashAlpha]

    if( 
iFlashAlpha == ALPHA_FULLBLINDED )
    {
        if( 
g_iPlayerFlashDatas[id][m_flFlashedUntil] - flGameTime 0.0 )
        {
            
iPercent 100
        
}
        else
        {
            
iPercent 100-floatround(((flGameTime - (flFlashedAt flFlashHoldTime))*100.0)/flFlashDuration)
        }
    }
    else
    {
        
iPercent 100-floatround(((flGameTime flFlashedAt)*100.0)/flTotalTime)
    }

    return 
iFlashAlpha



csykosoma 12-15-2011 05:59

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
this second version has 1 bug, all players disappear but no longer slowly fade back in. instead they instantly appear where i think they would begin the fade in process.

edit: when you look directly at flashbang, players disappear then reappear instead of fading in.

if you get flashed from behind or half flashed, plugin works as it should.

ConnorMcLeod 12-15-2011 12:26

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Try :

PHP Code:

/*    Formatright @ 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.1.0"
#define PLUGIN "Flash Disappear Players"

const XO_PLAYER 5
const m_flFlashedUntil 514
const m_flFlashedAt 515
const m_flFlashHoldTime 516
const m_flFlashDuration 517
const m_iFlashAlpha 518

const MAX_PLAYERS 32

const ALPHA_FULLBLINDED 255

new g_bitFlashedPlayers
#define MarkPlayerFlashed(%0)        g_bitFlashedPlayers |= 1<<(%0&31)
#define ClearPlayerFlashed(%0)    g_bitFlashedPlayers &= ~(1<<(%0&31))
#define IsPlayerFlashed(%0)        g_bitFlashedPlayers & 1<<(%0&31)

enum mFlashDatas
{
    
Float:_flFlashedUntil,
    
Float:_flFlashedAt,
    
Float:_flFlashHoldTime,
    
Float:_flFlashDuration,
    
_iFlashAlpha
}

new 
g_iPlayerFlashDatas[MAX_PLAYERS+1][mFlashDatas]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_message(get_user_msgid("ScreenFade"), "Message_ScreenFade")
    
RegisterHam(Ham_CS_Player_Blind"player""CBasePlayer_Blind_Post"1)
}

public 
Message_ScreenFade()
{
    if(    
get_msg_arg_int(4) == 255
    
&&    get_msg_arg_int(5) == 255
    
&&    get_msg_arg_int(6) == 255
    
&&    get_msg_arg_int(7) > 199    )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CBasePlayer_Blind_Post(id)
{
    
g_iPlayerFlashDatas[id][_flFlashedUntil] = _:get_pdata_float(idm_flFlashedUntilXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashedAt] = _:get_pdata_float(idm_flFlashedAtXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashHoldTime] = _:get_pdata_float(idm_flFlashHoldTimeXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashDuration] = _:get_pdata_float(idm_flFlashDurationXO_PLAYER)
    
g_iPlayerFlashDatas[id][_iFlashAlpha] = get_pdata_int(idm_iFlashAlphaXO_PLAYER)
    
MarkPlayerFlashed(id)
    
CheckForward()
}

public 
client_disconnect(id)
{
    
ClearPlayerFlashedid )
    
CheckForward()
}

public 
client_connect(id)
{
    
ClearPlayerFlashedid )
    
CheckForward()
}

CheckForward()
{
    static 
_AddToFullPack
    
if( g_bitFlashedPlayers )
    {
        if( !
_AddToFullPack )
        {
            
_AddToFullPack register_forward(FM_AddToFullPack"AddToFullPack_Post"1)
        }
    }
    else if( 
_AddToFullPack )
    {
        
unregister_forward(FM_AddToFullPack_AddToFullPack1)
        
_AddToFullPack 0
    
}
}

public 
AddToFullPack_Post(eseiEntidhostflagsplayerpSet)
{
    if( 
player /*&& id != iEnt */&& IsPlayerFlashed(id) && get_orig_retval() && is_user_alive(id) )
    {
        static 
iFlashiPercent
        iFlash 
get_user_flashed(idiPercent)
        if( 
iPercent )
        {
            if( 
id == iEnt )
            {
                static 
r
                r 
= (iPercent 255) / 100
                set_hudmessage
(r255-r00.950.7500.00010.10.00010.0001, -1)
                
show_hudmessage(id"Flash : %d%%"iPercent)
            }
            else
            {
                
set_es(esES_RenderModekRenderTransAlpha)
                
set_es(esES_RenderAmt255 - (iFlash iPercent) / 100)
            }
        }
        else
        {
            
ClearPlayerFlashedid )
            
CheckForward()
        }
    }
}

get_user_flashed(id, &iPercent=0)
{
    new 
Float:flFlashedAt g_iPlayerFlashDatas[id][_flFlashedAt]

    if( !
flFlashedAt )
    {
        return 
0
    
}

    new 
Float:flGameTime get_gametime()
    new 
Float:flTimeLeft flGameTime flFlashedAt
    
new Float:flFlashDuration g_iPlayerFlashDatas[id][_flFlashDuration]
    new 
Float:flFlashHoldTime g_iPlayerFlashDatas[id][_flFlashHoldTime]
    new 
Float:flTotalTime flFlashHoldTime flFlashDuration

    
if( flTimeLeft flTotalTime )
    {
        return 
0
    
}

    new 
iFlashAlpha g_iPlayerFlashDatas[id][_iFlashAlpha]

    if( 
iFlashAlpha == ALPHA_FULLBLINDED )
    {
        if( 
g_iPlayerFlashDatas[id][_flFlashedUntil] - flGameTime 0.0 )
        {
            
iPercent 100
        
}
        else
        {
            
iPercent 100-floatround(((flGameTime - (flFlashedAt flFlashHoldTime))*100.0)/flFlashDuration)
        }
    }
    else
    {
        
iPercent 100-floatround(((flGameTime flFlashedAt)*100.0)/flTotalTime)
    }

    return 
iFlashAlpha



csykosoma 12-15-2011 17:52

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
this version is near flawless.

the new flash meter has a problem when you die while flashed. the next round the flash meter is stuck on the percent you had at death and when you get flashed the new message will overlap on the old stuck message so you cannot read the percent.


otherwise, this plugin is perfect and all my players are really enjoying it.

edit: this is more of a minor adjustment, when you are about 30-50% flashed you can see the other players. i notice that the flash meter turns green at a very low percent. maybe 1-49% green, 50-99% orange, 100 red.

ConnorMcLeod 12-15-2011 18:06

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Try
PHP Code:

/*    Formatright @ 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.1.1"
#define PLUGIN "Flash Disappear Players"

const XO_PLAYER 5
const m_flFlashedUntil 514
const m_flFlashedAt 515
const m_flFlashHoldTime 516
const m_flFlashDuration 517
const m_iFlashAlpha 518

const MAX_PLAYERS 32

const ALPHA_FULLBLINDED 255

new g_bitFlashedPlayers
#define MarkPlayerFlashed(%0)        g_bitFlashedPlayers |= 1<<(%0&31)
#define ClearPlayerFlashed(%0)    g_bitFlashedPlayers &= ~(1<<(%0&31))
#define IsPlayerFlashed(%0)        g_bitFlashedPlayers & 1<<(%0&31)

enum mFlashDatas
{
    
Float:_flFlashedUntil,
    
Float:_flFlashedAt,
    
Float:_flFlashHoldTime,
    
Float:_flFlashDuration,
    
_iFlashAlpha
}

new 
g_iPlayerFlashDatas[MAX_PLAYERS+1][mFlashDatas]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_message(get_user_msgid("ScreenFade"), "Message_ScreenFade")
    
RegisterHam(Ham_CS_Player_Blind"player""CBasePlayer_Blind_Post"1)
    
RegisterHam(Ham_Killed"player""CBasePlayer_Killed_Post"true)
}

public 
Message_ScreenFade()
{
    if(    
get_msg_arg_int(4) == 255
    
&&    get_msg_arg_int(5) == 255
    
&&    get_msg_arg_int(6) == 255
    
&&    get_msg_arg_int(7) > 199    )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CBasePlayer_Blind_Post(id)
{
    
g_iPlayerFlashDatas[id][_flFlashedUntil] = _:get_pdata_float(idm_flFlashedUntilXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashedAt] = _:get_pdata_float(idm_flFlashedAtXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashHoldTime] = _:get_pdata_float(idm_flFlashHoldTimeXO_PLAYER)
    
g_iPlayerFlashDatas[id][_flFlashDuration] = _:get_pdata_float(idm_flFlashDurationXO_PLAYER)
    
g_iPlayerFlashDatas[id][_iFlashAlpha] = get_pdata_int(idm_iFlashAlphaXO_PLAYER)
    
MarkPlayerFlashed(id)
    
CheckForward()
}

public 
client_disconnect(id)
{
    
ClearPlayerFlashedid )
    
CheckForward()
}

public 
client_connect(id)
{
    
ClearPlayerFlashedid )
    
CheckForward()
}

public 
CBasePlayer_Killed_Postid )
{
    
ClearPlayerFlashedid )
    
CheckForward()
}

CheckForward()
{
    static 
_AddToFullPack
    
if( g_bitFlashedPlayers )
    {
        if( !
_AddToFullPack )
        {
            
_AddToFullPack register_forward(FM_AddToFullPack"AddToFullPack_Post"1)
        }
    }
    else if( 
_AddToFullPack )
    {
        
unregister_forward(FM_AddToFullPack_AddToFullPack1)
        
_AddToFullPack 0
    
}
}

public 
AddToFullPack_Post(eseiEntidhostflagsplayerpSet)
{
    if( 
player /*&& id != iEnt */&& IsPlayerFlashed(id) && get_orig_retval() && is_user_alive(id) )
    {
        static 
iFlashiPercent
        iFlash 
get_user_flashed(idiPercent)
        if( 
iPercent )
        {
            if( 
id == iEnt )
            {
                static 
r
                r 
= (iPercent 255) / 100
                set_hudmessage
(r255-r00.950.7500.00010.10.00010.0001, -1)
                
show_hudmessage(id"Flash : %d%%"iPercent)
            }
            else
            {
                
set_es(esES_RenderModekRenderTransAlpha)
                
set_es(esES_RenderAmt255 - (iFlash iPercent) / 100)
            }
        }
        else
        {
            
ClearPlayerFlashedid )
            
CheckForward()
        }
    }
}

get_user_flashed(id, &iPercent=0)
{
    new 
Float:flFlashedAt g_iPlayerFlashDatas[id][_flFlashedAt]

    if( !
flFlashedAt )
    {
        return 
0
    
}

    new 
Float:flGameTime get_gametime()
    new 
Float:flTimeLeft flGameTime flFlashedAt
    
new Float:flFlashDuration g_iPlayerFlashDatas[id][_flFlashDuration]
    new 
Float:flFlashHoldTime g_iPlayerFlashDatas[id][_flFlashHoldTime]
    new 
Float:flTotalTime flFlashHoldTime flFlashDuration

    
if( flTimeLeft flTotalTime )
    {
        return 
0
    
}

    new 
iFlashAlpha g_iPlayerFlashDatas[id][_iFlashAlpha]

    if( 
iFlashAlpha == ALPHA_FULLBLINDED )
    {
        if( 
g_iPlayerFlashDatas[id][_flFlashedUntil] - flGameTime 0.0 )
        {
            
iPercent 100
        
}
        else
        {
            
iPercent 100-floatround(((flGameTime - (flFlashedAt flFlashHoldTime))*100.0)/flFlashDuration)
        }
    }
    else
    {
        
iPercent 100-floatround(((flGameTime flFlashedAt)*100.0)/flTotalTime)
    }

    return 
iFlashAlpha



Lolz0r 02-08-2012 19:27

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Connor, plugin can not compile:

http://prikachi.com/images/688/4374688k.jpg

Fix it, please!

wickedd 02-08-2012 19:50

Re: [REQ] cs flashbangs- all players dissapear no white screen
 
Update hamsandwich


All times are GMT -4. The time now is 00:26.

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