Raised This Month: $ Target: $400
 0% 

Trouble with cs_set_user_defuse


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 08-20-2009 , 02:21   Trouble with cs_set_user_defuse
Reply With Quote #1

Hi... i have a trouble with this function....

For example i set:

PHP Code:
cs_set_user_defuse(id125500
But when the round end and i respawn the color of defuse back to green =/

I tried with:

PHP Code:
RegisterHam(Ham_Spawn"player""PlayerSpawn")

...

public 
PlayerSpawn(id)
        
cs_set_user_defuse(id125500
But nothing.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 02:50   Re: Trouble with cs_set_user_defuse
Reply With Quote #2

Code:
#include < amxmodx > new const g_iDefuserColor[ 3 ] = { 255, 0, 255 }; public plugin_init( ) {     register_message( get_user_msgid( "StatusIcon" ), "MessageStatusIcon" ); } public MessageStatusIcon( iMsgId, iDest, iReceiver ) {     static szIcon[ 32 ];     get_msg_arg_string( 2, szIcon, 31 );         if( equal( szIcon, "defuser" ) )     {         for( new i = 0; i < 3; i++ )         {             if( get_msg_arg_int( i + 3 ) != g_iDefuserColor[ i ] )             {                 set_msg_arg_int( i + 3, ARG_BYTE, g_iDefuserColor[ i ] );             }         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-20-2009 , 11:42   Re: Trouble with cs_set_user_defuse
Reply With Quote #3

Or
PHP Code:
        for( new 36i++ )
        {
            if( 
get_msg_arg_int) != g_iDefuserColor] )
            {
                
set_msg_arg_intiARG_BYTEg_iDefuserColor] );
            }
        } 
xD
__________________
xPaw is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 08-20-2009 , 12:16   Re: Trouble with cs_set_user_defuse
Reply With Quote #4

Quote:
Originally Posted by xPaw View Post
Or
PHP Code:
        for( new 36i++ )
        {
            if( 
get_msg_arg_int) != g_iDefuserColor] )
            {
                
set_msg_arg_intiARG_BYTEg_iDefuserColor] );
            }
        } 
xD
No, then you would have to do:
PHP Code:
        for( new 36i++ )
        {
            if( 
get_msg_arg_int) != g_iDefuserColor] )
            {
                
set_msg_arg_intiARG_BYTEg_iDefuserColor] );
            }
        } 
Which would be just the same exolent did. The only cpu optimization you could do is this, somehow it takes more memory obviously:
PHP Code:
new const g_iDefuserColor] = { 0002550255 }; 
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-20-2009 , 12:24   Re: Trouble with cs_set_user_defuse
Reply With Quote #5

Quote:
Originally Posted by Alucard^ View Post
Hi... i have a trouble with this function....

For example i set:

PHP Code:
cs_set_user_defuse(id125500
But when the round end and i respawn the color of defuse back to green =/

I tried with:

PHP Code:
RegisterHam(Ham_Spawn"player""PlayerSpawn")

...

public 
PlayerSpawn(id)
        
cs_set_user_defuse(id125500
But nothing.
The fact is cs updates players hud after they spawn so, default icon values are restored.
If it's made as in standart half life coding, it is proceeded in UpdateClientData when m_fInitHUD == 1, so the icon will be set back to green after you spawn, or when you execute fullupdate command, or when you make a demo.

Try this :
PHP Code:
#include <amxmodx>
#include <cstrike>

#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin("defuser icon color"VERSION"ConnorMcLeod")

    
register_event("StatusIcon""Event_StatusIcon_defuser""be""1=1""2=defuser")
}

public 
Event_StatusIcon_defuserid )
{
    
cs_set_user_defuse(id125000)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 08-20-2009 , 13:24   Re: Trouble with cs_set_user_defuse
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
The fact is cs updates players hud after they spawn so, default icon values are restored.
If it's made as in standart half life coding, it is proceeded in UpdateClientData when m_fInitHUD == 1, so the icon will be set back to green after you spawn, or when you execute fullupdate command, or when you make a demo.

Try this :
PHP Code:
#include <amxmodx>
#include <cstrike>

#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin("defuser icon color"VERSION"ConnorMcLeod")

    
register_event("StatusIcon""Event_StatusIcon_defuser""be""1=1""2=defuser")
}

public 
Event_StatusIcon_defuserid )
{
    
cs_set_user_defuse(id125000)


Isn't that way an "infinite loop"?
__________________
joaquimandrade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-20-2009 , 14:58   Re: Trouble with cs_set_user_defuse
Reply With Quote #7

I think the message sent by cs_set_user_defuse is not hookable.
I used this method because i prefer to not use register_message when it's possible, + this way you need less natives calls.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 15:00   Re: Trouble with cs_set_user_defuse
Reply With Quote #8

Code:
static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_set_user_defusekit(index, defusekit = 1, r = 0, g = 160, b = 0, icon[] = "defuser", flash = 0); = 7 params
{
	// Give/take defusekit.
	// params[1] = user index
	// params[2] = 1 = give
	// params[3] = r
	// params[4] = g
	// params[5] = b
	// params[6] = icon[]
	// params[7] = flash = 0

	// Valid entity should be within range
	CHECK_PLAYER(params[1]);

	// Make into edict pointer
	edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
	
	int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);

	if (params[2])
	{
		int colour[3] = {DEFUSER_COLOUR_R, DEFUSER_COLOUR_G, DEFUSER_COLOUR_B};
		for (int i = 0; i < 3; i++)
		{
			if (params[i + 3] != -1)
			{
				colour[i] = params[i + 3];
			}
		}

		pPlayer->v.body = 1;

		char* icon;
		if (params[6] != -1)
		{
			int len;
			icon = MF_GetAmxString(amx, params[6], 1, &len);
		} else {
			icon = "defuser";
		}

		*defusekit |= HAS_DEFUSE_KIT;
		MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "StatusIcon", NULL), NULL, pPlayer);
		WRITE_BYTE(params[7] == 1 ? 2 : 1); // show (if params[7] == 1, then this should flash, so we should set two here, else just 1 to show normally)
		WRITE_STRING(icon);
		WRITE_BYTE(colour[0]);
		WRITE_BYTE(colour[1]);
		WRITE_BYTE(colour[2]);
		MESSAGE_END();
	}
	else {
		*defusekit &= ~HAS_DEFUSE_KIT;
		MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "StatusIcon", NULL), NULL, pPlayer);
		WRITE_BYTE(0); // hide
		WRITE_STRING("defuser");
		MESSAGE_END();
		pPlayer->v.body = 0;
	}

	/*
	to show:
	L 02/20/2004 - 16:10:26: [JGHG Trace] {MessageBegin type=StatusIcon(107), dest=MSG_ONE(1), classname=player netname=JGHG
	L 02/20/2004 - 16:10:26: [JGHG Trace] WriteByte byte=1
	L 02/20/2004 - 16:10:26: [JGHG Trace] WriteString string=defuser
	L 02/20/2004 - 16:10:26: [JGHG Trace] WriteByte byte=0
	L 02/20/2004 - 16:10:26: [JGHG Trace] WriteByte byte=160
	L 02/20/2004 - 16:10:26: [JGHG Trace] WriteByte byte=0
	L 02/20/2004 - 16:10:26: [JGHG Trace] MessageEnd}

	to hide:
	L 02/20/2004 - 16:10:31: [JGHG Trace] {MessageBegin type=StatusIcon(107), dest=MSG_ONE(1), classname=player netname=JGHG
	L 02/20/2004 - 16:10:31: [JGHG Trace] WriteByte byte=0
	L 02/20/2004 - 16:10:31: [JGHG Trace] WriteString string=defuser
	L 02/20/2004 - 16:10:31: [JGHG Trace] MessageEnd}	
	*/
	return 1;
}
Correct. The StatusIcon message from cs_set_user_defuse( ) is sent straight to the engine.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 08-20-2009 , 17:23   Re: Trouble with cs_set_user_defuse
Reply With Quote #9

So the connor way is better?

Thx to much.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
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 15:12.


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