AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Toggled by someone saying a certain word. (https://forums.alliedmods.net/showthread.php?t=130622)

PropKiller 06-25-2010 17:56

Toggled by someone saying a certain word.
 
Ok, this is what I need help on. (Probably a noobish question, I am new so..)
When someone says "blank" in chat, how would I get it to print something in chat to all the players. (PrintToChatAll)

I have:
RegConsoleCmd("say", Command_Say)
RegConsoleCmd("say_team", Command_Say)

How would i get that to work out?

I got it to print that to chat when the map starts, but how would I make it so that when a person says "blank".

Thanks.

fysiks 06-25-2010 19:26

Re: Toggled by someone saying a certain word.
 
You could probably register "say blank" or if you mean he can say it anywhere in the chat line then you will have to register it like you have it and check if what was said contains the word "blank".

Also, your request is for SourceMod :). SourceMod section is below AMX Mod X section (this section).

grimvh2 06-25-2010 19:32

Re: Toggled by someone saying a certain word.
 
I think he wants that if someone types "blank" in a sentence. If so, register the "say" cmd and if you want, also the "say_team" cmd.

Then at ur function read the args, and use contain().
Be aware, false == -1

fysiks 06-25-2010 23:32

Re: Toggled by someone saying a certain word.
 
Quote:

Originally Posted by grimvh2 (Post 1219934)
I think he wants that if someone types "blank" in a sentence. If so, register the "say" cmd and if you want, also the "say_team" cmd.

Then at ur function read the args, and use contain().
Be aware, false == -1

If you didn't notice, this is for SourceMod (as I stated above). The SourceMod function is StrContains()

grimvh2 06-26-2010 06:05

Re: Toggled by someone saying a certain word.
 
Quote:

Originally Posted by fysiks (Post 1220051)
If you didn't notice, this is for SourceMod (as I stated above). The SourceMod function is StrContains()

Thats why I did'nt knew what regconsolecmd was xD
Still it would be the same way.

PropKiller 06-26-2010 08:07

Re: Toggled by someone saying a certain word.
 
Oh, srry guys. I clicked Scripting on AMX instead of Scripting on Sourcemod. Uhm. Could a moderator, or someone who can, move it to sourcemod > scripting please.

Alright, ill check StrContains out.

PropKiller 06-26-2010 08:36

Re: Toggled by someone saying a certain word.
 
Alright. On the API site, It says this for StrContains:

Quote:

Originally Posted by API-Reference
StrContains(const String:str[], const String:substr[], bool:caseSensitive=true);

Could someone post an example for StrContains, in an If event.

And, I would put that If, in the Command_Say, right?
[public Action:Command_Say(client, args)]

Thanks.

RedRobster 06-26-2010 08:48

Re: Toggled by someone saying a certain word.
 
I'm not sure about the rest, but to do the StrContains:
PHP Code:

if( StrContainsmsg"find"false) ) //This is going to find "find" in msg with no case sensitivity 

I'm not sure how to read args in SP, so I won't answer that, but this is how you would determine if msg contains the word "find".

PropKiller 06-26-2010 09:02

Re: Toggled by someone saying a certain word.
 
It comes up with an error, that says: Undefined symbol "msg". Is there something I should have changed from your example? (Again, im new.)

fysiks 06-26-2010 10:11

Re: Toggled by someone saying a certain word.
 
Quote:

Originally Posted by PropKiller (Post 1220374)
It comes up with an error, that says: Undefined symbol "msg". Is there something I should have changed from your example? (Again, im new.)

His example is incomplete and incorrect :wink:.

Remember you are talking with AMX'ers :).

Code:

if( StrContains(your_string_var_here, "blank", false) != -1 )
{
    // string contains "blank"
}

My example is incomplete so you must make it complete :).


All times are GMT -4. The time now is 14:43.

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