View Single Post
Author Message
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 03-05-2018 , 00:58   [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #1

Can anyone help me out of this plugin?
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define CVAR_CHECK_FREQ 1.0

#define BLOOD_COLOR_YELLOW 195
#define BLOOD_COLOR_RED 247

stock const s_chColors[] =
{
    
000007015031047063079095103,
    
106110111123127128130144146,
    
160165176179192193196202208,
    
212216225231234237238239240,
    
241242243244245246248249250,
    
251252253255
};
stock random_color()
{
    
// This method chooses only the more robust colors
    
return s_chColors[random_num(1sizeof(s_chColors))-1];
}


new 
bool:g_bFirstWrite;
new 
bool:g_bInBloodMsg;
new 
bool:g_bBloodColorizer;
public 
plugin_init()
{
    
register_plugin("Blood Colorizer""1.1""ts2do");
    
    
register_forward(FM_MessageBegin"on_message_begin");
    
register_forward(FM_WriteByte"on_write_byte");

    
register_cvar("amx_bloodcolorizer""1");

    
set_task(CVAR_CHECK_FREQ"check_cvar"0""0"b");
    
check_cvar();
}
public 
check_cvar()
{
    
g_bBloodColorizer bool:get_cvar_num("amx_bloodcolorizer");
}

public 
on_message_begin(msg_destmsg_type, const Float:fOrigin[3], ed)
{
    
// We need to know where we are in the message
    
g_bFirstWrite g_bBloodColorizer;
}

public 
on_write_byte(byte)
{
    
// Here we need to handle two types of blood messages
    // Blood color indices are BLOOD_COLOR_RED or BLOOD_COLOR_YELLOW
    // #1 Byte 1 is a blood color and needs to be overridden
    // #2.1 Byte 1 is either TE_BLOOD, TE_BLOODSPRITE, or TE_BLOODSTREAM
    // #2.2 Byte 2 is a blood color and needs to be overridden
    
if(g_bFirstWrite)
    {
        
// Handling #1
        
if(byte==BLOOD_COLOR_RED || byte==BLOOD_COLOR_YELLOW)
        {
            
write_byte(random_color());
            
g_bFirstWrite false;
            return 
FMRES_SUPERCEDE;
        }
        
// Handling #2.1
        
g_bInBloodMsg = (byte==TE_BLOOD||byte==TE_BLOODSPRITE||byte==TE_BLOODSTREAM);
        
g_bFirstWrite false;
    }
    else if(
g_bInBloodMsg)
    {
        
// Handling #2.1
        
write_byte(random_color());
        
g_bInBloodMsg false;
        return 
FMRES_SUPERCEDE;
    }
    return 
FMRES_IGNORED;

It crashes server and gives this in log
Code:
FATAL ERROR (shutting down) : WRITE_BYTE called with no active message
I have no idea how to fix this!
__________________

Last edited by CrAzY MaN; 03-08-2018 at 03:25.
CrAzY MaN is offline