AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] write_byte called no active message : Blood Colorizer (https://forums.alliedmods.net/showthread.php?t=305807)

CrAzY MaN 03-05-2018 00:58

[HELP] write_byte called no active message : Blood Colorizer
 
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!

Natsheh 03-05-2018 02:42

Re: [HELP] write_byte called no active message : Blood Colorizer
 
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

CrAzY MaN 03-05-2018 03:46

Re: [HELP] write_byte called no active message : Blood Colorizer
 
Still crashes the server

NiHiLaNTh 03-05-2018 16:44

Re: [HELP] write_byte called no active message : Blood Colorizer
 
Just change the color inside Ham_BloodColor.

CrAzY MaN 03-05-2018 23:43

Re: [HELP] write_byte called no active message : Blood Colorizer
 
No hamsandwich is used... Check again

klippy 03-06-2018 01:27

Re: [HELP] write_byte called no active message : Blood Colorizer
 
Quote:

Originally Posted by CrAzY MaN (Post 2581563)
No hamsandwich is used... Check again

Then use it. Do you have a reason not to?

CrAzY MaN 03-06-2018 02:23

Re: [HELP] write_byte called no active message : Blood Colorizer
 
I dont know perfectly how to use it.
I m still learning... Can you help me?

NiHiLaNTh 03-06-2018 14:42

Re: [HELP] write_byte called no active message : Blood Colorizer
 
Is Google banned at your country? When you type Ham_BloodColor, the first result points to thread with THIS post.

CrAzY MaN 03-07-2018 05:47

Re: [HELP] write_byte called no active message : Blood Colorizer
 
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?

HamletEagle 03-07-2018 14:36

Re: [HELP] write_byte called no active message : Blood Colorizer
 
Test and see if it's correct.


All times are GMT -4. The time now is 18:01.

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