ID:261358
 
OK. Im not 100% sure that this is a bug and Im not just using it wrong, but...
When I use findtext() it will only search the first word.
So it finds the "Pig" in the name "Pig Man", but not the "Pig" in "Super Pig".
Here is the code so far:

mob
var
offendingword
global
badnames = new/list()
proc
scanname()
var/T
for(T in badnames) //Searches through badwords
if(findtext("[usr.name]",T) == 1) //Sees if the name has the word in it.
usr.offendingword = T
return 0
return 1
Login()
badnames += list("Cheese", "France", "Pig")
NAMECHARACTER
usr.name = input("What will your name be?","Your Name", usr.key) as text
if(scanname() == 0)
usr << "You can not use that name. It contains unsuitable words."
usr << "The unsuitable word is [usr.offendingword]"
usr.name = null
goto NAMECHARACTER
else
usr << "Its fine."
usr << "[usr.name]"
..()


I took a look at Vortezz's DBZ Name Blocker and it happens with that too.
Thanks.
-DogMan
Dog Man wrote:
OK. Im not 100% sure that this is a bug and Im not just using it wrong, but...
When I use findtext() it will only search the first word.

findtext() returns the character position, not a true/false value. So:
<code>findtext("Pig Man","Pig")==1</code>
and
<code>findtext("Super Pig","Pig")==7</code>

In your example, you are only checking for the ==1 case. Just do
<code>if(findtext(name,T))!=0</code>
and it should work.

Note that you probably should pass in the name to scanname() rather than just use usr.name, since the current implementation may cause you headdaches down the line should you ever change the calling convention.
In response to Tom
OK, thankks.
-DogMan
In response to Tom
If you really wanted a proc that returned 1 or 0, you could easily build your own:

proc/spec_findtext(var/string = "", var/text = "")
if(findtext(string,text) != 0) return 1
return 0


That way, you could just use spec_findtext to save you the time.

-Lord of Water
In response to Tom
Tom wrote:
In your example, you are only checking for the ==1 case. Just do
<code>if(findtext(name,T))!=0</code>
and it should work.

I would prefer the slightly easier to read:

<code>if(findtext(name,T))</code>

It's 44/100% purer.