AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to upgrade say_bs? (https://forums.alliedmods.net/showthread.php?t=60746)

FIYA 09-11-2007 15:21

how to upgrade say_bs?
 
Hi!
First of all, I'm newb if it comes to scripting and I don't have any idea how it works so please be understanding.
I've recently come across this plugin "say_bs" by f117bomb which I noticed is really basic and everyone knows it.

Code:

/* AMXMOD script.
  *
  * (c) Copyright 2000-2002, f117bomb
  * This file is provided as is (no warranties).
  *
  */
  #include <amxmod>
  new phrase[4][] = { "bs", "bullshit", "bullsh*t", "hack"}
  public say_event(id)
  {
      new sid[10]
      num_to_str(id,sid,10)
      new said[192]
      read_args(said,191)

      for(new i = 0 ;i < 4; i += 1)
          if(containi(said,phrase[i]) != -1)
              set_task(1.0,"client",0,sid,10)
  }
  public client(sid[])
  {
      new id = str_to_num(sid)
      engclient_cmd(id,"say", "But then agian, I am a noob...")
  }
  public plugin_init()
  {
      register_plugin("Say BS","0.3","f117bomb")
      register_clcmd("say","say_event")
      return PLUGIN_CONTINUE
  }

Without any knowledge of scripting or whatsoever I've put some slight changes with the key words triggering this plugin and the response to those words to adapt it to my language so it would work fine on my server.
Now, the situation is that some of these really short words are parts of other words in my language that are not offensive so I wouldn't want them to trigger the afterward response, but that's the way it works in this form. As I tried to logically solve this problem I noticed the "containi" part that might be the problem but only based on my english language knowledge. I looked at some other plugins and found the possible alternative which is "equali". I tried some different combinations but either the plugin works as it was at the beginning, triggers on every word written or it doesn't work at all. All I want to know is how to set it up so it would work only on the words given the way they are exactly written, not being parts of any other words. Oh, and not case sensitive as I came across that issue too. So please, help me if you can :)

FIYA 09-12-2007 11:24

Re: how to upgrade say_bs?
 
come on guys, it's only one line (i guess). give it a sec and help me - poor thing ;)

ConnorMcLeod 09-12-2007 11:41

Re: how to upgrade say_bs?
 
Give a try to this plugin :

http://forums.alliedmods.net/showthread.php?p=89648

FIYA 09-12-2007 12:05

Re: how to upgrade say_bs?
 
but doesn't it work on the same basis?
isn't "if ( containi ( said, g_swearWords[i++] ) != -1 )" the same as "if(containi(said,phrase[i]) != -1)"?
that's what i'm trying to avoid. i don't want it to find words containing a trigger word but exactly those words.

for example: lets assume the word i'm trying to set as a trigger is "muff". so if someone writes it on chat it works. but if someone writes "muffler" it works as well and it shouldn't.

i tried to switch containi with equali but then it just triggers with any word or letter written on chat. so if anyone can give it a look and suggest the solution i'd be really grateful.

ConnorMcLeod 09-12-2007 14:11

Re: how to upgrade say_bs?
 
Sure, but of someone write "f..y..b.st.rd" (sorry for admins..),without any spaces but in real letters, you you manage to do what you want it won't be detected...

FIYA 09-12-2007 15:13

Re: how to upgrade say_bs?
 
that's right, but it's not really what i'm aiming for here. i'm not planning to use it exactly for swearing (because then i could use this more advanced plugin that you recommended). i want to eliminate some annoying replies from fragged people that aren't considered as swearing. it's a language thing, i cant explain it. if i used the term 'swear' it was just to make the description easier to understand for you.

i'm just looking for technical side of my problem, not content-related.
it's how to detect these defined words without spaces, being parts of other words or other stuff that would make it harder to detect. just detecting them the way they are normally written. i'm really expecting nothing more, it's supposed to be really simple plugin.

how to modify "if(containi(said,phrase[i]) != -1)" to make it work? or maybe there's more to it? i hope i made it as clear as possible :)

Lord_Destros 09-12-2007 23:49

Re: how to upgrade say_bs?
 
Sorry, forgot to repost XD. After re-reading this I got confused on what you want. If you want to block the word ass but not asymptote; you could just put spaces before and after each word in the array.
Your example would be:
Code:

  new phrase[4][] = { " bs ", " bullshit ", " bullsh*t ", " hack "}

purple_pixie 09-13-2007 08:21

Re: how to upgrade say_bs?
 
If you want to dissallow exact phrases, rather than anything containing them, replace "contan[i]" with "equal[i]".

Adding the "i" to the end makes it case-insensitive.

FIYA 09-13-2007 09:25

Re: how to upgrade say_bs?
 
thank you Lord_Destros, that should do it, so simple :)
edit: on second thought, wouldn't it work only when there is a space before and after the phrase?

purple_pixie, i've tried that already but something's messed up then, it doesn't work at all :/

purple_pixie 09-13-2007 09:38

Re: how to upgrade say_bs?
 
Oh, it's because you're reading them all, not just the word.

Try putting "say " in front of each one or similar.

Or of course, just go with Destros :-D

Just trying to find the actual problem over work-arounds.

EDIT: Try using equal() and replacing "read_args(" with "read_argv(1," which reads the first argument, rather than all of them (i.e. reads "text" instead of "say text" )


All times are GMT -4. The time now is 16:10.

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