Raised This Month: $51 Target: $400
 12% 

Solved [HELP] write_byte called no active message : Blood Colorizer


Post New Thread Reply   
 
Thread Tools Display Modes
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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-05-2018 , 02:42   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #2

In random color function use this return

s_chColors[random(sizeof s_chColors)];

And hoe did you certified its a blood message in the messagebegin hook and byte
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 03-05-2018 , 03:46   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #3

Still crashes the server
__________________
CrAzY MaN is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 03-05-2018 , 16:44   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #4

Just change the color inside Ham_BloodColor.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 03-05-2018 , 23:43   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #5

No hamsandwich is used... Check again
__________________
CrAzY MaN is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-06-2018 , 01:27   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #6

Quote:
Originally Posted by CrAzY MaN View Post
No hamsandwich is used... Check again
Then use it. Do you have a reason not to?
__________________
klippy is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 03-06-2018 , 02:23   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #7

I dont know perfectly how to use it.
I m still learning... Can you help me?
__________________
CrAzY MaN is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 03-06-2018 , 14:42   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #8

Is Google banned at your country? When you type Ham_BloodColor, the first result points to thread with THIS post.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 03-07-2018 , 05:47   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #9

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define TE_BLOODSPRITE        115
//#define _YELLOW 195
//#define BLOOD_COLOR_RED 247

new blood
new blood_gore
//new blood_color

stock const s_chColors[] =
{
    
07153147637995103,
    
106110111123127128130144146,
    
160165176179192193196202208,
    
212216225231234237238239240,
    
241242243244245246248249250,
    
251252253255
}

public 
plugin_precache()
{
    
blood precache_model("sprites/blood.spr")
}

public 
plugin_init()
{
    
register_plugin("Random Blood Color""1.0""Edited Chronic's Plugin");
    
register_event("Damage","Damage","3=DMG_BULLET")
    
blood_gore register_cvar("blood_gore","1")
    
RegisterHamHam_BloodColor"player""CPlayer_BloodColor" );
}
    
/*public CPlayer_BloodColor ( const Player )
{
    SetHamReturnInteger( s_chColors[random(sizeof s_chColors)] );
    return HAM_SUPERCEDE;
}
*/

public Damage(id)
{
    if(
is_user_connected(id) && get_user_health(id)!=100 && get_pcvar_num(blood_gore))
    {
        new 
origin[3]
        
get_user_origin(id,origin)
        new 
hitpointweapon
        get_user_attacker
(id,weapon,hitpoint)
        switch(
hitpoint)
        {
            case 
1:
            {
                
get_user_origin(id,origin,1)
            }
            case 
2:
            {
                
origin[2] += 25
            
}
            case 
3:
            {
                
origin[2] += 10
            
}
            case 
4:
            {
                
origin[2] += 10
                origin
[0] += 5
                origin
[1] += 5
            
}
            case 
5:
            {
                
origin[2] += 10
                origin
[0] -= 5
                origin
[1] -= 5
            
}
            case 
6:
            {
                
origin[2] -= 10
                origin
[0] += 5
                origin
[1] += 5
            
}
            case 
7:
            {
                
origin[2] -= 10
                origin
[0] -= 5
                origin
[1] -= 5
            
}
        }
        if(
get_pcvar_num(blood_gore))
        {
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte(TE_BLOODSPRITE)
            
write_coord(origin[0])
            
write_coord(origin[1])
            
write_coord(origin[2])
            
write_short(blood)
            
write_short(blood)
            
write_byte(random(sizeof s_chColors))
            
write_byte(10)
            
message_end()
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte(TE_BLOODSPRITE)
            
write_coord(origin[0])
            
write_coord(origin[1])
            
write_coord(origin[2])
            
write_short(blood)
            
write_short(blood)
            
write_byte(random(sizeof s_chColors))
            
write_byte(12)
            
message_end()
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte(TE_BLOODSPRITE)
            
write_coord(origin[0])
            
write_coord(origin[1])
            
write_coord(origin[2])
            
write_short(blood)
            
write_short(blood)
            
write_byte(random(sizeof s_chColors))
            
write_byte(15)
            
message_end()
        }
    }

Is this correct?
__________________
CrAzY MaN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-07-2018 , 14:36   Re: [HELP] write_byte called no active message : Blood Colorizer
Reply With Quote #10

Test and see if it's correct.
__________________
HamletEagle is offline
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 06:08.


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