Hello, I am currently working on a script that lets people PM other people by a command. You should be able to do that by just typing "/PM Target Message" on the chat screen, but it will output it as a normal chat message in the chat menu. But when I type "say /PM Player Message" in the console, it works perfectly. I just need it to work directly from the chat screen. please help.
Code:
#include <amxmodx>
#include <amxmisc>
public plugin_init() {
register_plugin("Private Messaging", "1.0", "Hawkie")
register_clcmd("say /PM", "cmd_pm")
}
public cmd_pm(id) {
new name[33]
new targetname[33]
new Text[300]
new Player[33]
read_argv(2, Player, 32)
read_argv(3, Text, 299)
remove_quotes(Player)
new userid = get_user_index(Player)
get_user_name(userid,targetname,32)
get_user_name(id,name,32)
if(equal(Player, "") || equal(Text, "")) {
client_print(id, print_chat, "Usage: /PM <Player> <Message>")
return PLUGIN_HANDLED
}
else if(!userid) {
client_print(id, print_chat, "Error: Player not found")
return PLUGIN_HANDLED
}
else {
client_print(userid, print_chat, "(PM) %s: %s", name, Text)
client_print(id, print_chat, "You sent: %s to %s", Text, targetname)
}
return PLUGIN_HANDLED
}