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

Colored Spawn v1.2.2


Post New Thread Reply   
 
Thread Tools Display Modes
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-10-2009 , 14:08   Re: Colored Spawn v1.0
Reply With Quote #11

Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
 
new const PLUGIN[] = "Colored Spawn"
new const VERSION[] = "1.0"
new const AUTHOR[] = "fezh"
 
new g_enabled, g_spawn_color, g_time
 
public plugin_init()
{
 register_plugin(PLUGIN,VERSION,AUTHOR)
 RegisterHam(Ham_Spawn,"player","event_player_spawn",1)
 g_enabled = register_cvar("amx_colored_spawn","1")
 g_spawn_color = register_cvar("amx_spawn_color","255 180 0")
 g_time = register_cvar("amx_color_time","4.0")
 register_cvar("colored_spawn",VERSION,FCVAR_SERVER|FCVAR_SPONLY)
}
 
public event_player_spawn(id)
{
 if(!get_pcvar_num(g_enabled)) return
 new szColor[12], szRed[4], szGreen[4], szBlue[4]
 get_pcvar_string(g_spawn_color,szColor,11)
 parse(szColor,szRed,3,szGreen,3,szBlue,4)
if(is_user_alive(id))
 set_user_rendering(id, kRenderFxGlowShell, str_to_num(szRed), str_to_num(szGreen), str_to_num(szBlue), kRenderNormal, 255)
 set_task(get_pcvar_float(g_time),"event_remove_color",id)
}
 
public event_remove_color(id)
{
 set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,0)
}
EDIT:
Works perfectly fine NOW.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 06-23-2009 at 03:46.
Xellath is offline
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 05-10-2009 , 14:19   Re: Colored Spawn v1.0
Reply With Quote #12

Quote:
Originally Posted by Xellath View Post
Works perfectly fine.
That's exactly I did. And yeah, it works, but I have those logs too.
__________________
"There is no knowledge, that is not power"
fezh is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-10-2009 , 14:19   Re: Colored Spawn v1.0
Reply With Quote #13

Add is_user_alive() check
__________________
xPaw is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-10-2009 , 14:22   Re: Colored Spawn v1.0
Reply With Quote #14

Okay, tested, and got the debug line, adding alive check removes the debug lines though.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 05-10-2009 , 14:56   Re: Colored Spawn v1.1
Reply With Quote #15

Plugin updated & added a screenshot.
__________________
"There is no knowledge, that is not power"
fezh is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-10-2009 , 15:03   Re: Colored Spawn v1.1
Reply With Quote #16

Add random colors
__________________
xPaw is offline
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 05-10-2009 , 15:34   Re: Colored Spawn v1.0
Reply With Quote #17

Quote:
Originally Posted by Xellath View Post
Works perfectly fine NOW.
Thanks, but now I released my version. And about your code, I think it's useless check the cvar value if the user isn't alive, should be both together
__________________
"There is no knowledge, that is not power"

Last edited by fezh; 05-10-2009 at 15:36.
fezh is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-10-2009 , 15:51   Re: Colored Spawn v1.0
Reply With Quote #18

Quote:
Originally Posted by fezh View Post
Thanks, but now I released my version. And about your code, I think it's useless check the cvar value if the user isn't alive, should be both together
Yeah, I actually didn't think about that. And you're right, it's useless.
Thanks for the heads up.

EDIT:
I didn't say good job, or did I? Either way..
Good Job, fezh.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 05-10-2009 at 16:16.
Xellath is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-11-2009 , 01:15   Re: Colored Spawn v1.1b
Reply With Quote #19

Like this will be better
PHP Code:
public event_player_spawnid ) {
    if( 
is_user_aliveid ) && get_pcvar_numg_enabled ) ) {
        if( 
get_pcvar_numg_random_color ) ) {
            new 
iRed random_num0255 );
            new 
iGreen random_num0255 );
            new 
iBlue random_num0255 );

            
set_user_renderingidkRenderFxGlowShelliRediGreeniBluekRenderNormal255 );
        } else {
            new 
szColor[12], szRed[4], szGreen[4], szBlue[4];
            
get_pcvar_stringg_spawn_colorszColor11);
            
parseszColorszRed,3szGreen,3szBlue);
            
            new 
iRed clampstr_to_numszRed ), 0255 );
            new 
iGreen clampstr_to_numszGreen ), 0255 );
            new 
iBlue clampstr_to_numszBlue ), 0255 );
            
            
set_user_renderingidkRenderFxGlowShelliRediGreeniBluekRenderNormal255 );
        }
        
        
set_taskget_pcvar_float(g_time), "event_remove_color"id );
    }

If random_colors is 1 then you dont need to get other cvar (normal color)
Also you should check the cvar in radius 0-255
__________________
xPaw is offline
KadiR
Unnecessary Member
Join Date: Aug 2008
Location: Zürich / Switzerland
Old 05-11-2009 , 07:06   Re: Colored Spawn v1.0
Reply With Quote #20

Quote:
Originally Posted by KadiR View Post
nice plugin ;)

what about amx_spawn_admin_color ?
KadiR 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 16:32.


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