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

Solved How to get executors name in chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blAck.
Member
Join Date: Jun 2018
Old 07-19-2018 , 13:44   How to get executors name in chat
Reply With Quote #1

Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /test", "test")
}

public test()
{
    ColorChat(0, GREEN, "Player (player name) used /test command.");  
}
How can I get a name of player who typed /test.
Replace it with (player name)

Last edited by blAck.; 08-05-2018 at 14:09.
blAck. is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-19-2018 , 13:56   Re: How to get executors name in chat
Reply With Quote #2

PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""Say_Hook")
    
register_clcmd("say_team""Say_Hook")
}

public 
Say_Hook(id)
{
    new 
szMessage[36
    
read_args(szMessagecharsmax(szMessage)) 
    
remove_quotes(szMessage)
    
    if(
equali(szMessage,".test") || equali(szMessage,"/test"))
    {
        new 
szName[32]
        
get_user_name(idszNamecharsmax(szName))
        
        
client_print(0print_chat"[AMXX] My name is %s."szName)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

iceeedr is offline
Send a message via Skype™ to iceeedr
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-19-2018 , 13:59   Re: How to get executors name in chat
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test""test")
    
register_clcmd("say_team /test""test")
}

public 
test(id)
{
    static 
szName[64]
    
get_user_name(idszNamecharsmax(szName))
    
ColorChat(0GREEN"Player %s used /test command."szName);  

@iceeedr: I don't think you need to hook say just for this
__________________
My plugin:

Last edited by Celena Luna; 07-19-2018 at 13:59.
Celena Luna is offline
blAck.
Member
Join Date: Jun 2018
Old 07-19-2018 , 14:03   Re: How to get executors name in chat
Reply With Quote #4

Quote:
Originally Posted by iceeedr View Post
PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""Say_Hook")
    
register_clcmd("say_team""Say_Hook")
}

public 
Say_Hook(id)
{
    new 
szMessage[36
    
read_args(szMessagecharsmax(szMessage)) 
    
remove_quotes(szMessage)
    
    if(
equali(szMessage,".test") || equali(szMessage,"/test"))
    {
        new 
szName[32]
        
get_user_name(idszNamecharsmax(szName))
        
        
client_print(0print_chat"[AMXX] My name is %s."szName)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

Thanks buddy ^^
blAck. is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-19-2018 , 14:54   Re: How to get executors name in chat
Reply With Quote #5

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test""test")
    
register_clcmd("say_team /test""test")
}

public 
test(id)
{
    static 
szName[64]
    
get_user_name(idszNamecharsmax(szName))
    
ColorChat(0GREEN"Player %s used /test command."szName);  

@iceeedr: I don't think you need to hook say just for this
Yes, I also agree, but I like to always have a "more complete" function, in case they want to implement with others "says".
iceeedr is offline
Send a message via Skype™ to iceeedr
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-19-2018 , 22:11   Re: How to get executors name in chat
Reply With Quote #6

Register each command individually if you can, it will be more efficient.

There are a few cases where the only method is to hook "say" and/or "say_team" but only use it if there is no other way to do it.
__________________
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-19-2018 , 22:24   Re: How to get executors name in chat
Reply With Quote #7

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /test""test")
    
register_clcmd("say_team /test""test")
}

public 
test(id)
{
    static 
szName[64]
    
get_user_name(idszNamecharsmax(szName))
    
ColorChat(0GREEN"Player %s used /test command."szName);  

@iceeedr: I don't think you need to hook say just for this
Max name characters are 32 and not 64.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-19-2018 , 22:40   Re: How to get executors name in chat
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Register each command individually if you can, it will be more efficient.

There are a few cases where the only method is to hook "say" and/or "say_team" but only use it if there is no other way to do it.
Could you explain better? Is it because of performance issues?
iceeedr is offline
Send a message via Skype™ to iceeedr
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-19-2018 , 22:44   Re: How to get executors name in chat
Reply With Quote #9

Quote:
Originally Posted by iceeedr View Post
Could you explain better? Is it because of performance issues?
That is what I said.

Quote:
Originally Posted by fysiks View Post
Register each command individually if you can, it will be more efficient.
Plus it will be simpler code.
__________________

Last edited by fysiks; 07-19-2018 at 22:45.
fysiks is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-19-2018 , 23:13   Re: How to get executors name in chat
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
That is what I said.



Plus it will be simpler code.
Oops sorry, I do not speak fluent English, the translation from efficient to Brazilian leads to more interpretations, but I understood your explanation. Thank you.
iceeedr is offline
Send a message via Skype™ to iceeedr
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 20:21.


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