Raised This Month: $32 Target: $400
 8% 

Need help with register_clcmd s


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thEsp
BANNED
Join Date: Aug 2017
Old 10-04-2018 , 16:20   Need help with register_clcmd s
Reply With Quote #1

Hi peoples,
I have an problem with my code.

I want to do a function once I write "name" in cmd. Or at least cmd argument starts with "name" (But it could be "name RandomName")

Current code:
Code:
new szName[32]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("name ","RejectName")
}
public client_connect(id) {
	get_user_name(id,szName,charsmax(szName))
}
public RejectName(id){
	client_print(id,print_center,"You can't change your name multiple times!")
	client_cmd(id,"name ^"%s^"",szName)
}
I have used that code above but It doesnt work.
When I change
Code:
register_clcmd("name,"RejectName")
with
Code:
register_clcmd("say /name,"RejectName")
It actualy works.

Thanks in advance.
P.S I'll not publish this if I solve it (Just so you know) and I will not answer questions such as "Why you need it".

Last edited by thEsp; 10-04-2018 at 16:21.
thEsp is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-04-2018 , 17:08   Re: Need help with register_clcmd s
Reply With Quote #2

The correct way is

Code:
register_clcmd("say /name","RejectName")
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 10-04-2018 , 17:16   Re: Need help with register_clcmd s
Reply With Quote #3

Look up client_infochanged and get/set_user_info functions. Don't slowhack your players.
__________________
<VeCo> is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-04-2018 , 22:15   Re: Need help with register_clcmd s
Reply With Quote #4

Quote:
Originally Posted by thEsp View Post
P.S I'll not publish this if I solve it (Just so you know) and I will not answer questions such as "Why you need it".
Saying that probably isn't the best way to make people want to help you.

Regardless, look at existing examples for creating console commands e.g. in admincmd.sma.
__________________
fysiks is offline
thEsp
BANNED
Join Date: Aug 2017
Old 10-05-2018 , 08:31   Re: Need help with register_clcmd s
Reply With Quote #5

Quote:
Originally Posted by <VeCo> View Post
Look up client_infochanged and get/set_user_info functions. Don't slowhack your players.
No man. Absolutely not. I hate some idiots in the game changing their names multiple times.
Thats why I need it.

Last edited by thEsp; 10-05-2018 at 08:31.
thEsp is offline
thEsp
BANNED
Join Date: Aug 2017
Old 10-05-2018 , 08:33   Re: Need help with register_clcmd s
Reply With Quote #6

Quote:
Originally Posted by iceeedr View Post
The correct way is

Code:
register_clcmd("say /name","RejectName")
What? I just wanted to say that code works with that cmd argument,but not with argument I need to.
In C# and vb.net it would be like
Code:
If cmd_arg.startsWith("name")
thEsp is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 10-05-2018 , 11:10   Re: Need help with register_clcmd s
Reply With Quote #7

Blocking name has already been covered.
search
__________________
Relaxing is offline
D4rkSiD3Rs
Senior Member
Join Date: Jan 2018
Location: Morocco
Old 10-05-2018 , 11:28   Re: Need help with register_clcmd s
Reply With Quote #8

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

#define VERSION "0.1.0"

public plugin_init()
{
    
register_plugin("One Name"VERSION"ConnorMcLeod")
    
register_forward(FM_ClientUserInfoChanged"ClientUserInfoChanged")
}

public 
ClientUserInfoChanged(id)
{
    static const 
name[] = "name"
    
static szOldName[32], szNewName[32]
    
pev(idpev_netnameszOldNamecharsmax(szOldName))
    if( 
szOldName[0] )
    {
        
get_user_info(idnameszNewNamecharsmax(szNewName))
        if( !
equal(szOldNameszNewName) )
        {
            
set_user_info(idnameszOldName)
            return 
FMRES_HANDLED
        
}
    }
    return 
FMRES_IGNORED

__________________


D4rkSiD3Rs is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-05-2018 , 15:32   Re: Need help with register_clcmd s
Reply With Quote #9

Search in google, instead of lose time talking about who charge to work with plugins.
__________________








CrazY. 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 21:14.


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