Raised This Month: $ Target: $400
 0% 

Scripting problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hawkie
Junior Member
Join Date: Mar 2005
Old 03-21-2005 , 12:30   Scripting problems
Reply With Quote #1

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 }
Hawkie is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-21-2005 , 15:39   Re: Scripting problems
Reply With Quote #2

Quote:
Originally Posted by Hawkie
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.
What do you mean?
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Hawkie
Junior Member
Join Date: Mar 2005
Old 03-21-2005 , 15:51   Re: Scripting problems
Reply With Quote #3

Quote:
Originally Posted by v3x
Quote:
Originally Posted by Hawkie
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.
What do you mean?
I mean, when you want to chat, you press "y". (Unless you havent changed the key for chatting) It should work to type /PM Target Message THERE, but it won't perform that command and will just output in the chat menu like "/PM Hawkie Hi".
Hawkie is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-21-2005 , 16:05  
Reply With Quote #4

First off, http://forums.alliedmods.net/showthread.php?t=5037. I already did this.

Second off, you cannot read the second arg of a say command. It only has one arguement. Everything is in quotes, so it only has ONE.

Third, use cmd_target.

Ok lemme try to salvage this...

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_clcmd("say","handle_say") } public handle_say(id){     new buffer[256], buffer1[33], buffer2[33],buffer3[33];     read_argv(1,buffer,255);     parse(buffer, buffer1, 32, buffer2, 32, buffer3, 32);     if(!equali(buffer1,"/pm",3)) return PLUGIN_CONTINUE;     new tid = cmd_target(id,buffer2)     if(!tid) return PLUGIN_CONTINUE;     new name[33], tname[33]     get_user_name(id,name,32)     get_user_name(tid,tname,32)     client_print(tid, print_chat, "(PM) %s: %s", name, buffer3)     client_print(id, print_chat, "You sent: %s to %s", buffer3, tname)     return PLUGIN_HANDLED }
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Hawkie
Junior Member
Join Date: Mar 2005
Old 03-21-2005 , 17:10  
Reply With Quote #5

Quote:
Originally Posted by Twilight Suzuka
First off, http://forums.alliedmods.net/showthread.php?t=5037. I already did this.

Second off, you cannot read the second arg of a say command. It only has one arguement. Everything is in quotes, so it only has ONE.

Third, use cmd_target.

Ok lemme try to salvage this...

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_clcmd("say","handle_say") } public handle_say(id){     new buffer[256], buffer1[33], buffer2[33],buffer3[33];     read_argv(1,buffer,255);     parse(buffer, buffer1, 32, buffer2, 32, buffer3, 32);     if(!equali(buffer1,"/pm",3)) return PLUGIN_CONTINUE;     new tid = cmd_target(id,buffer2)     if(!tid) return PLUGIN_CONTINUE;     new name[33], tname[33]     get_user_name(id,name,32)     get_user_name(tid,tname,32)     client_print(tid, print_chat, "(PM) %s: %s", name, buffer3)     client_print(id, print_chat, "You sent: %s to %s", buffer3, tname)     return PLUGIN_HANDLED }
Nice, thank you very much. You know, I am totally n00b at scripting so don't think I am totally stupid or dumb.

EDIT: Ohh, the private messaging works now, but the message will only conatain the first word, so that means you can't include any spaces. Any solutions for this?
Hawkie is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-21-2005 , 18:11  
Reply With Quote #6

Really? I guess you could try strbreak, and break it to do this. Watch:

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_clcmd("say","handle_say") }     public handle_say(id){     new buffer[256], buffer1[50], buffer2[200]     read_argv(1,buffer,255);     if(!equali(buffer,"/pm",3)) return PLUGIN_CONTINUE;     replace(buffer,255,"/pm","")     trim(buffer)         strbreak(buffer, buffer1, 50, buffer2, 199);     new tid = cmd_target(id,buffer1)     if(!tid) return PLUGIN_CONTINUE;     new name[33], tname[33]     get_user_name(id,name,32)     get_user_name(tid,tname,32)     client_print(tid, print_chat, "(PM) %s: %s", name, buffer2)     client_print(id, print_chat, "You sent: %s to %s", buffer2, tname)     return PLUGIN_HANDLED }
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Hawkie
Junior Member
Join Date: Mar 2005
Old 03-22-2005 , 08:16  
Reply With Quote #7

It works 100% now, thanks for wasting time helping a n00b (me)
Hawkie 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 14:03.


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