Raised This Month: $ Target: $400
 0% 

how to read several values out of a the chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 12-26-2005 , 16:53   how to read several values out of a the chat
Reply With Quote #1

Let's say an admin uses (say / team_say) following command "/10 20 30".
How do I intercept those 3 values which do differ?
Wolle is offline
Send a message via AIM to Wolle
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-26-2005 , 20:02  
Reply With Quote #2

Code:
public checktext(id) {     new arg[4], arg1[4], arg2[4]     read_argv(1, arg, 3)     read_argv(2, arg1, 3)     read_argv(3, arg2, 3)     if (arg[0] == '/')     {         replace(arg, 3, "/", "")         trim(arg)         new r = str_to_num(arg)         new g = str_to_num(arg1)         new b = str_to_num(arg2)                 //etc function     } }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-26-2005 , 21:05  
Reply With Quote #3

also:
Code:
register_clcmd("say", "checksay");
__________________
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
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 12-27-2005 , 05:59  
Reply With Quote #4

Thanks guys I'll try this right away.
After searching through the forum I started to get a similiar idea.
Wolle is offline
Send a message via AIM to Wolle
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 12-27-2005 , 07:16  
Reply With Quote #5

I tried this but I'm not satisfied.
When checking for the return values with this test command "/10 20 30"
arg holds 49
r holds actually 10
and all the others 0

I'm not too sure how the code really works.
Doesn't "read_argv" already return the appropriate string?
What does
Code:
read_argv(1...
read_argv(2...
read_argv(3...
really do?
I'm under the impression, also after double checking with the docs, that it would return the first three arguments. Which would mean that "arg" holds "/10", "arg2" " 20" and "arg3" " 30".
Here btw I see why it would be necessary to trim the second and third argument.
What am I misunderstanding here?

EDIT: nvm the 49, I forgot that I %d a string instaed %s.
Wolle is offline
Send a message via AIM to Wolle
DarlD
Senior Member
Join Date: Aug 2004
Old 12-27-2005 , 08:34  
Reply With Quote #6

read_argv(1,said,31)

the 1 is the ID, said is the name of the var and 31 is the lenght
__________________
DarlD is offline
Send a message via MSN to DarlD
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 12-27-2005 , 11:43  
Reply With Quote #7

Well that's not really what I meant.
What exactly is the "ID"?
The docs say "0" returns the command. What command? Is "/" the command?
And everything after "0" is arguments.
So let's say if "/num" is the command, "0" returns "/num" or "num"? Will I need to register "/num" as a command first?
Let's assume an admin "say"s or "team_say"s this "/num 10 20 30".
"read_argv( 0 ..." holds "/num" right? And "read_argv( 1 ..." holds "10" and "read_argv( 2 ..." holds "20" and so on right?
I know it doesn't but that's how I understand the docs. What am I missing?
Wolle is offline
Send a message via AIM to Wolle
VEN
Veteran Member
Join Date: Jan 2005
Old 12-27-2005 , 14:59  
Reply With Quote #8

Quote:
Originally Posted by teame06
Code:
public checktext(id) {     new arg[4], arg1[4], arg2[4]     read_argv(1, arg, 3)     read_argv(2, arg1, 3)     read_argv(3, arg2, 3)     if (arg[0] == '/')     {         replace(arg, 3, "/", "")         trim(arg)         new r = str_to_num(arg)         new g = str_to_num(arg1)         new b = str_to_num(arg2)                 //etc function     } }
Reread what he said:
Quote:
Let's say an admin uses (say / team_say) following command "/10 20 30".
VEN is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-27-2005 , 15:19  
Reply With Quote #9

Quote:
Originally Posted by VEN
Reread what he said:
Quote:
Let's say an admin uses (say / team_say) following command "/10 20 30".
Quote:
Originally Posted by Wolle
Well that's not really what I meant.
What exactly is the "ID"?
The docs say "0" returns the command. What command? Is "/" the command?
And everything after "0" is arguments.
So let's say if "/num" is the command, "0" returns "/num" or "num"? Will I need to register "/num" as a command first?
Let's assume an admin "say"s or "team_say"s this "/num 10 20 30".
"read_argv( 0 ..." holds "/num" right? And "read_argv( 1 ..." holds "10" and "read_argv( 2 ..." holds "20" and so on right?
I know it doesn't but that's how I understand the docs. What am I missing?
Code:
public checktext(id) {     new arg[4], arg1[4], arg2[4], arg3[4]     read_argv(1, arg, 3)     read_argv(2, arg1, 3)     read_argv(3, arg2, 3)     if (equali(arg, "/num")) // Check first argument after the /say command     {         new r = str_to_num(arg1)         new g = str_to_num(arg2)         new b = str_to_num(arg3)                 //etc function     } }

if you do a read_argv(0, example, 3) it will return the /say /say_team command. So you want to start at 1 and on.

Well you read it so fix it. k?
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 12-27-2005 , 16:48  
Reply With Quote #10

You are all wrong. say and teamsay commands are wrapped up in quotes.
You must do read_args, then remove_quotes, then break it apart with strbreak or similar.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
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 16:08.


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