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

wrong valid player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 04-28-2020 , 11:36   wrong valid player
Reply With Quote #1

so yeah i set new player = cmd_target
and check it by player/client

but someone when im using
Code:
client_cmd( client, "amx_kick #%d", get_user_userid( player ) );
ERROR:
You must select a valid player.
Code:
public HandleCommands( client, const message[ 192 ], command )
{
	new cmd[ 64 ], arg[ 64 ], arg1[ 64 ], arg2[ 64 ], arg3[ 64 ], AdminSz[ 32 ], NameSz[ 32 ];
	
	parse( message, cmd, charsmax( cmd ), arg, charsmax( arg ), arg1, charsmax( arg1 ), arg2, charsmax( arg2 ), arg3, charsmax( arg3 ) );
	
	//client_print(0, print_chat, "[DEBUG] arg:%s arg1:%s arg2:%s", arg, arg1, arg2)
	new player = cmd_target( client, arg, arg1, command )
	//client_print(0, print_chat, "[DEBUG] player(%d)",)
	
	get_user_name( client, AdminSz, charsmax(AdminSz))

	if (player != 0)
		get_user_name( player, NameSz, charsmax(NameSz))
	else
		copy(NameSz, charsmax(NameSz), arg1);
		
	switch( command )
	{
		case KICK:
		{
			if (!player)
			{
				ColorChat(client, "^3Error^1: You must select a valid player.");
			} 
			else if (!is_user_connected(player))
			{
				ColorChat( client, "'^3%s^1' has can't be Kicked, Because he's ^4disconnected^1.", NameSz);
			}
			else
			{
				ColorChat( 0, "^3%s^1 has used ^4Kick^1 command.", AdminSz)
				//client_cmd( client, "amx_kick %s", arg );
				client_cmd( client, "amx_kick #%d", get_user_userid( player ) );
			}
		}
		
		case BAN:
		{
			if (!player)
			{
				ColorChat( client, "^3Error^1: You must select a valid player.");
			} 
			else if (!is_user_connected(player))
			{
				ColorChat( client, "'^3%s^1' has can't be Banned, Because he's ^4disconnected^1.", NameSz);
			}
			else
			{
				ColorChat( 0, "^3%s^1 has used ^4Ban^1 command.", AdminSz)
				client_cmd( client, "amx_ban %s %s %s", arg, arg1, arg2 );
			}
		}


And that case are working:
Code:
		case SLAY:
		{
			if (!player)
			{
				ColorChat(client, "^3Error^1: You must select a valid player.");
			}
			else if (!is_user_alive(player))
			{
				new szName[32];
				get_user_name(player, szName, charsmax(szName));
				ColorChat( client, "'^3%s^1' can't be Slay, Because he's ^4dead^1.", szName);
			}
			else if ( !( get_user_flags( player ) & ADMIN_IMMUNITY ) || player == client )
			{
				ColorChat( 0, "^3%s^1 has used ^4Slay^1 command.", AdminSz)
				
				user_kill( player );
			}
			else
			{
				if (get_user_flags(player) & ADMIN_IMMUNITY)
					ColorChat( client, "^3Error^1: You can not use this command on Owner")
				else
					ColorChat( client, "^3Error^1: Please enter a player name.")
			}
		}
Code:
		case VOTEMAP:
		{
			ColorChat(0, "^3%s^1 making a ^4Vote Map^1.",AdminSz)
			
			client_cmd( client, "amx_votemap %s %s %s %s", arg, arg1, arg2, arg3 );
		}

Last edited by Fuck For Fun; 04-28-2020 at 11:47.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-28-2020 , 13:57   Re: wrong valid player
Reply With Quote #2

Code:
new player = cmd_target( client, arg, arg1, command )

For starters, that code won't even compile because "cmd_target" has only 3 arguments, not 4.

https://www.amxmodx.org/api/amxmisc/cmd_target

Give us a working code and show the definition for all arguments involved in your "cmd_target" execution, including "message" and "command" values.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 04-28-2020, 14:23
Fuck For Fun
This message has been deleted by Fuck For Fun. Reason: solved
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-28-2020 , 22:33   Re: wrong valid player
Reply With Quote #3

You're redefining functions that already exist. Don't do that. Give your custom function a unique name (even if it does work, it is extremely confusing, especially if you're changing the arguments that get passed to it).

Write a small plugin to test just the functionality that you're having problems with. This will often make it easier to find the issue. The other benefit is that, if you can't fix it, you can post just this version of the plugin so that we can actually run it.
__________________
fysiks is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 04-29-2020 , 19:26   Re: wrong valid player
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
You're redefining functions that already exist. Don't do that. Give your custom function a unique name (even if it does work, it is extremely confusing, especially if you're changing the arguments that get passed to it).

Write a small plugin to test just the functionality that you're having problems with. This will often make it easier to find the issue. The other benefit is that, if you can't fix it, you can post just this version of the plugin so that we can actually run it.
I understand you, you're right.

The test I did before the changes works fine with cmd_target as well
Since I set up player then like this suddenly doesn't work for me so I think wrong setting of new player or something in CASE
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-29-2020 , 22:37   Re: wrong valid player
Reply With Quote #5

Quote:
Originally Posted by Fuck For Fun View Post
The test I did before the changes works fine with cmd_target as well
Since I set up player then like this suddenly doesn't work for me so I think wrong setting of new player or something in CASE
What??? I think you might need to consider using a translator because your posts are very confusing.

Did you write a small plugin to reproduce the issue so that it's easier to debug as I mentioned before? Post that new plugin so we can help you.
__________________
fysiks is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 04-30-2020 , 03:31   Re: wrong valid player
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
What??? I think you might need to consider using a translator because your posts are very confusing.

Did you write a small plugin to reproduce the issue so that it's easier to debug as I mentioned before? Post that new plugin so we can help you.
What? You should be more specific with your reactions

Like I said, the new I added is for Testin !player and
Quote:
client_cmd( client, "amx_kick #%d", get_user_userid( player ) );

Last edited by Fuck For Fun; 04-30-2020 at 03:32.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
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 09:41.


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