PDA

View Full Version : Toggled by someone saying a certain word.


PropKiller
06-25-2010, 17:56
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
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
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
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() (http://docs.sourcemod.net/api/index.php?fastload=show&id=615&)

grimvh2
06-26-2010, 06:05
If you didn't notice, this is for SourceMod (as I stated above). The SourceMod function is StrContains() (http://docs.sourcemod.net/api/index.php?fastload=show&id=615&)

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

PropKiller
06-26-2010, 08:07
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
Alright. On the API site, It says this for StrContains:

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
I'm not sure about the rest, but to do the StrContains:

if( StrContains( msg, "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
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
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 :).

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

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

PropKiller
06-26-2010, 10:20
kk, I'll look at it. I gtg, ill be back in about 3-4 hours. Could you explain to me, what "your_string_var_here" is. I know its the string variable, but could you message me, how to create one, or something, im quickly typin this, so..

Thanks.

fysiks
06-26-2010, 10:27
kk, I'll look at it. I gtg, ill be back in about 3-4 hours. Could you explain to me, what "your_string_var_here" is. I know its the string variable, but could you message me, how to create one, or something, im quickly typin this, so..

Thanks.

Nope, my knowledge of SourceMod is limited and I know that strings are a bit different there than in AMX Mod X.

your_string_var_here is just a string variable that contains the string you are searching to see if "blank" is in it. In your case it should be the string from reading the "argument string".

For further assistance it would be wise to post in the SourceMod section. I don't forsee this getting moved any time soon :).

RedRobster
06-26-2010, 11:12
His example is incomplete and incorrect :wink:.

Remember you are talking with AMX'ers :).

if( StrContains(your_string_var_here, "blank", false) != -1 )
{
// string contains "blank"
}My example is incomplete so you must make it complete :).

:oops: I apologize. Didn't notice that it will return -1 if it doesn't contain it.

**For your request about getting the strings, http://docs.sourcemod.net/api/index.php?fastload=show&id=473&I'm not going to try to show you again...as I clearly have an extremely limited knowledge of SourceMod. :grrr:

fysiks
06-26-2010, 11:28
http://docs.sourcemod.net/api/index.php?fastload=show&id=473&I'm not going to try to show you again...as I clearly have an extremely limited knowledge of SourceMod. :grrr:

Actually it would be GetCmdArgString() (http://docs.sourcemod.net/api/index.php?fastload=show&id=474&)

RedRobster
06-26-2010, 11:32
Actually it would be GetCmdArgString() (http://docs.sourcemod.net/api/index.php?fastload=show&id=474&)
Ah, yeah. Sorry. He's hooking "say", not doing a console command.

PropKiller
06-26-2010, 11:35
Alright. Ill wait another day, and see if someone will move it by then. Probably PM a moderator, letting them know I need this moved.

PropKiller
06-26-2010, 16:10
I got it working. I started a thread on the SourceMod part of the forums.

No need to move it. Unless someone wants it in the trash.

http://forums.alliedmods.net/showthread.php?p=1220701 (http://forums.alliedmods.net/showthread.php?p=1220701#post1220701)

GXLZPGX
06-26-2010, 16:54
For some reason I use to think it was this simple:

#include <amxmodx>

#define PLUGIN "Switch Enable"
#define AUTHOR "Shadow"
#define VERSION "1.0"

new bool:gSwitch[33] /*= false*/

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd( "say blah", "cmdSwitch" )
register_clcmd( "say_team blah", "cmdSwitch" )
}

public cmdSwitch( id )
{
if( gSwitch[id] == false )
{
gSwitch[id] = true;
client_print( id, "Enabled" )
}
if( gSwitch[id] == true )
{
gSwitch[id] = false;
client_print( id, "Disabled" )
}
}

wrecked_
06-26-2010, 17:44
if( gSwitch[id] == false )
{
gSwitch[id] = true;
client_print( id, "Enabled" )
}
if( gSwitch[id] == true )
{
gSwitch[id] = false;
client_print( id, "Disabled" )
}
:arrow:
gSwitch[id] = !gSwitch[id]

client_print( id, print_chat, "%s", gSwitch[id] ? "Disabled" : "Enabled" )