Raised This Month: $ Target: $400
 0% 

[Help] How to change trail color every 1 second


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ReneF
Junior Member
Join Date: Oct 2014
Location: In the world
Old 10-29-2014 , 16:23   [Help] How to change trail color every 1 second
Reply With Quote #1

I need the trail changes color every 1 second, whether you are walking, running, moving from side to side, jumping, etc...

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

#pragma semicolon 1

#define PLUGIN_VERSION "1.0.0"

#define TASKID        81732519124

#define TRAIL_ACTIVE 1
#define TRAIL_INACTIVE 0
#define TRAIL_LIFE 30
#define ACCES_FLAG  ADMIN_BAN

new gTrailSprite;
new 
gTrailRandomColor33 ][ ];
new 
bPlayerTrailStatus33 ];
new 
Float:bflNextCheck33 ];
new const 
gTrailSpriteIndex[] = "sprites/zbeam3.spr";

const 
IN_MOVING IN_FORWARD IN_BACK IN_LEFT IN_RIGHT IN_JUMP;

public 
plugin_init()

    
register_plugin"Owner Trail"PLUGIN_VERSION"tuty" );  
    
register_forwardFM_CmdStart"forward_cmdstart" );
    
register_clcmd"say /trail""cmdMakeOwnerTrail" ); 
    
register_clcmd"say_team /trail""cmdMakeOwnerTrail" );
    
    
RegisterHam(Ham_Spawn"player""Fwd_Spawn"1);
}

public 
plugin_precache()

    
gTrailSprite precache_modelgTrailSpriteIndex );
}

public 
client_connectid )

    
bPlayerTrailStatusid ] = TRAIL_INACTIVE;
}

public 
Fwd_Spawn(id)
{
    if(
get_user_flags(id) & ACCES_FLAG)
    {
        
bPlayerTrailStatus[id] = TRAIL_ACTIVE;
        
        
gTrailRandomColorid ][ ] = random_num0255 );  
        
gTrailRandomColorid ][ ] = random_num0255 );  
        
gTrailRandomColorid ][ ] = random_num0255 );
        
        
set_task(10.0"change_color"id TASKID, .flags="b");
    }
}

public 
change_color(taskid)
{
    new 
id taskid TASKID;
    
    if(!
is_user_alive(id))
    {
        
remove_task(taskid);
        return;
    }
    
    
gTrailRandomColorid ][ ] = random_num0255 );  
    
gTrailRandomColorid ][ ] = random_num0255 );  
    
gTrailRandomColorid ][ ] = random_num0255 );    
}

public 
cmdMakeOwnerTrailid )

    if( !
is_user_aliveid ) )
    {  
        
client_printidprint_center"No puedes utilizar este comando estando muerto" );  
        return 
PLUGIN_HANDLED
    }  
    if( !( 
get_user_flagsid ) & ACCES_FLAG ) )
    {  
        
client_printidprint_center"No tienes acceso" );   
        return 
PLUGIN_HANDLED
    } 
    
    if( 
bPlayerTrailStatusid ] == TRAIL_ACTIVE )
    {  
        
        
client_printidprint_center"Trail desactivado" );  
        
        
bPlayerTrailStatusid ] = TRAIL_INACTIVE;  
        
        
UTIL_KillBeamFollowid );  
        
        
bflNextCheckid ] = -5000.0;    
        
        return 
PLUGIN_HANDLED
    }  
    
    if( 
bPlayerTrailStatusid ] == TRAIL_INACTIVE 
    {  
        
client_printidprint_center"Trail activado" );  
        
        
bPlayerTrailStatusid ] = TRAIL_ACTIVE;    
        
        
gTrailRandomColorid ][ ] = random_num0255 );  
        
gTrailRandomColorid ][ ] = random_num0255 );  
        
gTrailRandomColorid ][ ] = random_num0255 );    
        
        return 
PLUGIN_HANDLED
    }  
    
    return 
PLUGIN_CONTINUE;
}

public 
forward_cmdstartidhandle )

    if( !
is_user_aliveid ) || bPlayerTrailStatusid ] == TRAIL_INACTIVE 
    {  
        return 
FMRES_IGNORED
    } 
    
    new 
iButton get_uchandleUC_Buttons ); 
    
    if( !( 
iButton IN_MOVING ) ) 
    {
        new 
Float:flGameTime get_gametime();   
        if( 
bflNextCheckid ] < flGameTime )
        {   
            
UTIL_KillBeamFollowid );   
            
UTIL_BeamFollowid );
            
bflNextCheckid ] = flGameTime + ( TRAIL_LIFE );  
        } 
    }  
    
    return 
FMRES_IGNORED;
}  

stock UTIL_BeamFollow( const iClient )
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY ); 
    
write_byteTE_BEAMFOLLOW ); 
    
write_shortiClient );
    
write_shortgTrailSprite ); 
    
write_byteTRAIL_LIFE );
    
write_byte20 ); 
    
write_bytegTrailRandomColoriClient ][ ] ); 
    
write_bytegTrailRandomColoriClient ][ ] ); 
    
write_bytegTrailRandomColoriClient ][ ] ); 
    
write_byte255 ); 
    
message_end();
}
    
stock UTIL_KillBeamFollow( const iClient )

    
message_beginMSG_BROADCASTSVC_TEMPENTITY ); 
    
write_byteTE_KILLBEAM );     
    
write_shortiClient ); 
    
message_end();

Sorry for bad english
ReneF is offline
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 10-30-2014 , 08:45   Re: [Help] How to change trail color every 1 second
Reply With Quote #2

PHP Code:
set_task(10.0"change_color"id TASKID, .flags="b"); 
change to
PHP Code:
set_task(0.1"change_color"id TASKID, .flags="b"); 

Last edited by Kellan123; 10-30-2014 at 08:46.
Kellan123 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 10-30-2014 , 09:14   Re: [Help] How to change trail color every 1 second
Reply With Quote #3

Quote:
Originally Posted by Kellan123 View Post
PHP Code:
set_task(10.0"change_color"id TASKID, .flags="b"); 
change to
PHP Code:
set_task(0.1"change_color"id TASKID, .flags="b"); 
Then it would be called 10 times a second, change it to 1.0.
__________________
Kia is offline
ReneF
Junior Member
Join Date: Oct 2014
Location: In the world
Old 10-30-2014 , 09:58   Re: [Help] How to change trail color every 1 second
Reply With Quote #4

Quote:
Originally Posted by Kia View Post
Then it would be called 10 times a second, change it to 1.0.
It works , but I have another question:

How do I change the color automatically?
ReneF is offline
Old 11-06-2014, 17:04
ReneF
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
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 17:31.


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