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

Parsing one word from a string - i.e. 1 word from a sentence


Post New Thread Reply   
 
Thread Tools Display Modes
Mattie
Veteran Member
Join Date: Jan 2005
Old 04-22-2005 , 07:54   Re: Parsing one word from a string - i.e. 1 word from a sent
Reply With Quote #11

Quote:
Originally Posted by Dygear
Quote:
Originally Posted by Mattie
The best you'll find is using es_token for this sort of thing at the moment. There's no other way to do this that I know of.

You can search for the string with es_token by slowly incrementing what token you're checking (perhaps maxing-out at 10 tokens), or you could even write an alias loop to handle it. Unfortunately, I don't know of a clean way to handle it better at the moment.

-Mattie
What's the SDK's functions that allows you to "see" what a player is saying?

for example :
Code:
.:KPS:.Dygear : Hey what's up KingPin.
.:XFX:.KingPin : Hey the chat is working, that's good.
.:KPS:.Dygear : Yea it looks like you know what your doing, but it only looks that way. :P.
Would that all be handled by one function?
I'm not actually sure what you're asking for. I'll give you the information I have that maps most closely to what you're talking about:
  • 1. EventScripts gets the say text and passes it to you via the player_say.cfg file. Any lines in there that use event_var(text) will get the entire string expanded in-line. (Not a variable, just a raw string in a single token)
    2. In the Plugin SDK, Valve gives us access to one primary way to get say information. Whenever something happens, it will call FireGameEvent() and pass an IGameEvent with a name of "player_say" and with a field called "text" that contains a character array of what the player said. This is effectively what EventScripts is passing you.
    3. It is possible to hook the engine's "say" processor. This is done by most of the admin plugins out there because some of them need to replace the text (word filter) and other such things. I wrote a prototype to do it some time ago, but don't remember the function to hook off the top of my head. EventScripts doesn't need to do this.

Not sure if this answers your question, but I thought I'd give it a shot.


Quote:
On a side note, we need to setup a wiki, eather here on the SourceMod.net, or I could make it on my own website. Going to send a PM to BAILOPAN now about that.
Not a bad idea. Let me know what he says. I can also setup a Wiki if needed (I run a handful of others, though they're using the weak FlexWiki).

Thanks for the comment,
-Mattie
Mattie is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 04-22-2005 , 15:36   Re: Parsing one word from a string - i.e. 1 word from a sent
Reply With Quote #12

Quote:
Originally Posted by Mattie
  1. EventScripts gets the say text and passes it to you via the player_say.cfg file. Any lines in there that use event_var(text) will get the entire string expanded in-line. (Not a variable, just a raw string in a single token)
  2. In the Plugin SDK, Valve gives us access to one primary way to get say information. Whenever something happens, it will call FireGameEvent() and pass an IGameEvent with a name of "player_say" and with a field called "text" that contains a character array of what the player said. This is effectively what EventScripts is passing you.
  3. It is possible to hook the engine's "say" processor. This is done by most of the admin plugins out there because some of them need to replace the text (word filter) and other such things. I wrote a prototype to do it some time ago, but don't remember the function to hook off the top of my head. EventScripts doesn't need to do this.
2 and 3 is what I wanted. Thanks.

Quote:
Originally Posted by Mattie
Not a bad idea. Let me know what he says. I can also setup a Wiki if needed (I run a handful of others, though they're using the weak FlexWiki).
Yea, still no reply. I think, he's pondering it. I'll keep ya updated via PM, if he should permit.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 04-24-2005 , 09:29  
Reply With Quote #13

Well no reply from BAILOPAN, he has read the PM, or he has recived it, but he has not replyed. So my thinking is he does not want to do it. So I do hope you will set this up, and I also hope that XAD, Roger, and You could get togeather and coloabarate on this to make a kick ass Server Side Mode Guide for the Noobs. (Witch I include my self in). I would hope you would put some example code in. Give us all an idea on just what we have to do. Also, I will ask questions to keep it noob frendly.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
SpiffyBiff
New Member
Join Date: Jul 2005
Location: Toronto, Ontario, Canada
Old 07-03-2005 , 19:58   Help
Reply With Quote #14

I've been trying to get this to work on my server without looking too much into the actual coding. I'm working purely on the examples here, and running into problems.

Here's what my player_say.cfg says:

Quote:
setinfo word1 0
setinfo word2 0
setinfo word3 0
setinfo word4 0
setinfo word5 0
setinfo word6 0
setinfo word7 0
setinfo word8 0

es_token word1 "event_var(text)" 1
es_token word2 "event_var(text)" 2
es_token word3 "event_var(text)" 3
es_token word4 "event_var(text)" 4
es_token word5 "event_var(text)" 5
es_token word6 "event_var(text)" 6
es_token word7 "event_var(text)" 7
es_token word8 "event_var(text)" 8

if (word1 equalto "join") then ma_say "[bA] is an invite only clan"
if (word2 equalto "join") then ma_say "[bA] is an invite only clan"
if (word3 equalto "join") then ma_say "[bA] is an invite only clan"
if (word4 equalto "join") then ma_say "[bA] is an invite only clan"
if (word5 equalto "join") then ma_say "[bA] is an invite only clan"
if (word6 equalto "join") then ma_say "[bA] is an invite only clan"
if (word7 equalto "join") then ma_say "[bA] is an invite only clan"
if (word8 equalto "join") then ma_say "[bA] is an invite only clan"

if (word1 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word2 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word3 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word4 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word5 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word6 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word7 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word8 equalto "recruit") then ma_say "[bA] is an invite only clan"

if (word1 equalto "site") then ma_say "http://www.baclan.net"
if (word2 equalto "site") then ma_say "http://www.baclan.net"
if (word3 equalto "site") then ma_say "http://www.baclan.net"
if (word4 equalto "site") then ma_say "http://www.baclan.net"
if (word5 equalto "site") then ma_say "http://www.baclan.net"
if (word6 equalto "site") then ma_say "http://www.baclan.net"
if (word7 equalto "site") then ma_say "http://www.baclan.net"
if (word8 equalto "site") then ma_say "http://www.baclan.net"

if (word1 equalto "hax") then ma_say "Nope, you just suck"
if (word2 equalto "hax") then ma_say "Nope, you just suck"
if (word3 equalto "hax") then ma_say "Nope, you just suck"
if (word4 equalto "hax") then ma_say "Nope, you just suck"
if (word5 equalto "hax") then ma_say "Nope, you just suck"
if (word6 equalto "hax") then ma_say "Nope, you just suck"
if (word7 equalto "hax") then ma_say "Nope, you just suck"
if (word8 equalto "hax") then ma_say "Nope, you just suck"

if (word1 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word2 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word3 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word4 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word5 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word6 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word7 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word8 equalto "gay") then ma_say "Somewhere, the Village People are crying"

if (word1 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word2 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word3 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word4 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word5 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word6 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word7 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word8 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"

if (word1 equalto "lag") then ma_say "Stop making excuses"
if (word2 equalto "lag") then ma_say "Stop making excuses"
if (word3 equalto "lag") then ma_say "Stop making excuses"
if (word4 equalto "lag") then ma_say "Stop making excuses"
if (word5 equalto "lag") then ma_say "Stop making excuses"
if (word6 equalto "lag") then ma_say "Stop making excuses"
if (word7 equalto "lag") then ma_say "Stop making excuses"
if (word8 equalto "lag") then ma_say "Stop making excuses"
Now, the reason I added 8 possible words instead of the 3 shown previously in the thread because I obviously wanted it to catch the trigger word if it's past the 3rd word in the phrase. I don't know if this is how I would do it however.

Basically, I'm not getting any response when I type the trigger words in my server. If this looks wrong or there's an easier way to do this, then please let me know. Thanks.
SpiffyBiff is offline
Send a message via AIM to SpiffyBiff Send a message via MSN to SpiffyBiff
Mattie
Veteran Member
Join Date: Jan 2005
Old 07-04-2005 , 11:56   Re: Help
Reply With Quote #15

Quote:
Originally Posted by SpiffyBiff
I've been trying to get this to work on my server without looking too much into the actual coding. I'm working purely on the examples here, and running into problems.

Here's what my player_say.cfg says:

Quote:
setinfo word1 0
setinfo word2 0
setinfo word3 0
setinfo word4 0
setinfo word5 0
setinfo word6 0
setinfo word7 0
setinfo word8 0

es_token word1 "event_var(text)" 1
es_token word2 "event_var(text)" 2
es_token word3 "event_var(text)" 3
es_token word4 "event_var(text)" 4
es_token word5 "event_var(text)" 5
es_token word6 "event_var(text)" 6
es_token word7 "event_var(text)" 7
es_token word8 "event_var(text)" 8

if (word1 equalto "join") then ma_say "[bA] is an invite only clan"
if (word2 equalto "join") then ma_say "[bA] is an invite only clan"
if (word3 equalto "join") then ma_say "[bA] is an invite only clan"
if (word4 equalto "join") then ma_say "[bA] is an invite only clan"
if (word5 equalto "join") then ma_say "[bA] is an invite only clan"
if (word6 equalto "join") then ma_say "[bA] is an invite only clan"
if (word7 equalto "join") then ma_say "[bA] is an invite only clan"
if (word8 equalto "join") then ma_say "[bA] is an invite only clan"

if (word1 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word2 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word3 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word4 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word5 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word6 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word7 equalto "recruit") then ma_say "[bA] is an invite only clan"
if (word8 equalto "recruit") then ma_say "[bA] is an invite only clan"

if (word1 equalto "site") then ma_say "http://www.baclan.net"
if (word2 equalto "site") then ma_say "http://www.baclan.net"
if (word3 equalto "site") then ma_say "http://www.baclan.net"
if (word4 equalto "site") then ma_say "http://www.baclan.net"
if (word5 equalto "site") then ma_say "http://www.baclan.net"
if (word6 equalto "site") then ma_say "http://www.baclan.net"
if (word7 equalto "site") then ma_say "http://www.baclan.net"
if (word8 equalto "site") then ma_say "http://www.baclan.net"

if (word1 equalto "hax") then ma_say "Nope, you just suck"
if (word2 equalto "hax") then ma_say "Nope, you just suck"
if (word3 equalto "hax") then ma_say "Nope, you just suck"
if (word4 equalto "hax") then ma_say "Nope, you just suck"
if (word5 equalto "hax") then ma_say "Nope, you just suck"
if (word6 equalto "hax") then ma_say "Nope, you just suck"
if (word7 equalto "hax") then ma_say "Nope, you just suck"
if (word8 equalto "hax") then ma_say "Nope, you just suck"

if (word1 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word2 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word3 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word4 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word5 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word6 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word7 equalto "gay") then ma_say "Somewhere, the Village People are crying"
if (word8 equalto "gay") then ma_say "Somewhere, the Village People are crying"

if (word1 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word2 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word3 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word4 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word5 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word6 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word7 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"
if (word8 equalto "ip") then ma_say "This server's IP is 66.225.249.170:27015"

if (word1 equalto "lag") then ma_say "Stop making excuses"
if (word2 equalto "lag") then ma_say "Stop making excuses"
if (word3 equalto "lag") then ma_say "Stop making excuses"
if (word4 equalto "lag") then ma_say "Stop making excuses"
if (word5 equalto "lag") then ma_say "Stop making excuses"
if (word6 equalto "lag") then ma_say "Stop making excuses"
if (word7 equalto "lag") then ma_say "Stop making excuses"
if (word8 equalto "lag") then ma_say "Stop making excuses"
Now, the reason I added 8 possible words instead of the 3 shown previously in the thread because I obviously wanted it to catch the trigger word if it's past the 3rd word in the phrase. I don't know if this is how I would do it however.

Basically, I'm not getting any response when I type the trigger words in my server. If this looks wrong or there's an easier way to do this, then please let me know. Thanks.
First of all, you need to validate that EventScripts is installed correctly. Do you know if it's working for sure? I.e., if you place an es_msg at the beginning of the player_say.cfg (like the following) does it broadcast a message whenever anyone says something?
Code:
// player_say.cfg test
es_msg Someone said something: event_var(text)
To help you straight away with this particular code-- basically you don't want to put quotes around event_var(text)-- that guarantees that it won't be expanded because EventScripts will ignore it. So you'd want to remove the quotation marks when using es_token:
Code:
es_token word1 event_var(text) 1 
es_token word2 event_var(text) 2 
es_token word3 event_var(text) 3 
es_token word4 event_var(text) 4 
es_token word5 event_var(text) 5 
es_token word6 event_var(text) 6 
es_token word7 event_var(text) 7 
es_token word8 event_var(text) 8
I'd also recommend using es_tell rather than ma_say, but that's just me. For example,
Code:
if (word1 equalto "lag") then es_tell event_var(userid) "Stop making excuses"
All of this being said, there's a quicker/simpler way to do something similar for each word. You can use es_string's replace function to kinda search for a substring. This is faster, but will also find "lag" in a word like "slagsworth" which you may not want:
Code:
es_setinfo mytext event_var(text)
es_string mytext replace "lag" "___"
// if the new text is now different from the old text, we know the word was found and replaced
if (server_var(mytext) notequalto event_var(text)) then es_tell event_var(userid) "Stop making excuses"
I hope this helps. Also, I have moved most EventScripts discussion over to my new forums. If you want more people helping, visit the forum in my signature.

Best of luck!
-Mattie
Mattie is offline
Ace Rimmer
Senior Member
Join Date: Apr 2005
Old 07-06-2005 , 12:15  
Reply With Quote #16

Sorry if I am on the wrong line here but surely none of this will work:

if (word8 equalto "hax") then ma_say "Nope, you just suck"

Surely it should be:

if (server_var(word equalto "hax") then...

etc.
__________________
Smoke me a kipper, I'll be back for breakfast

Main Web Site-Ace Rimmer-System Information
Ace Rimmer 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 15:57.


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