• Welcome to Valhalla Legends Archive.
 

TagBans

Started by CrAz3D, June 05, 2003, 10:15 PM

Previous topic - Next topic

CrAz3D

How would I go about comparing the tag to the user's name to see if it matches?

VB 6.0
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Tuberload

#1
Here is a more generic answer to match your question.  Read up on your language's string/character parsing libraries. Find a method/function/subroutine that will tell you whether or not a string contains another string. Then translate the following psuedocode into whatever language you are using, and everything should work.


IF username CONTAINS tag THEN
   SEND "/ban " + username


Keep in mind this is only a simple solution to tag bans.  You could make it more useful and integrate wildcard matching.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

CrAz3D

Sorry for not posting language...I'll go engrave upon my screen.

Thnx for the help
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

indulgence

VB:  instr()
C++:  strstr()
<3

Yoni

Quote from: indulgence on June 06, 2003, 02:38 PM
C++:  strstr()

Correction:

C: strstr()
C++: basic_string::find()

Camel

Quote from: Yoni on June 06, 2003, 03:27 PM
Quote from: indulgence on June 06, 2003, 02:38 PM
C++:  strstr()

Correction:

C: strstr()
C++: basic_string::find()

you can use strstr in c++

Tuberload

#6
Quote
you can use strstr in c++

C++ allows you to use it to provide backwards compatibility with C.  Just because you can do something doesn't mean you should. So pick a language and use it's functions.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Camel

Quote from: Tuberload on June 06, 2003, 04:33 PM
Quote
you can use strstr in c++

C++ allows you to use it to provide backwards compatibility with C.  Just because you can do something doesn't mean you should. So pick a language and use it's functions.

i would hardly call that backwards compatibility. the only difference between c and c++ from a compiler standpoint is the existance of classes (which are the same thing as structs but they can have functions in them).  everything else is just operators that could, in theory, be modified to work in c.

imo, c++ is crap. if you dont like pointers, dont use c. it's that simple.

herzog_zwei

#8
Quote from: Yoni on June 06, 2003, 03:27 PM
Quote from: indulgence on June 06, 2003, 02:38 PM
C++:  strstr()

Correction:

C: strstr()
C++: basic_string::find()

That sort of thinking is the reason for a lot of the bloat in today's software.  Sure, you can buy the state of the art machine with 1TB of memory to run a program written with all the bloat.  Or you can get an old system and run it with 64MB if it were written with resource limits in mind.  Memory overhead for a string used in strstr: 1 byte.  Overhead for a basic_string class: depends on the compiler but you can bet it's well over 16 bytes.  That doesn't include the extra overhead in using the vtables.  C++ can make life easier, but use the right thing for the job.  If you want safer type-checking/bounds-checking, use some other language like BASIC, Java, or some scripting language.  If you want power, use C.  If you want the power of C with a few extra bells/whistles to make OOP easier, use C++.  If you're not good with static strings or have to deal a lot with dynamic strings, use some string class.  Classes can make life easier and easier to maintain (for strings, an example would be switching to Unicode instead of ASCII) but you do pay some price for it.  Same thing applies with the bloated (though useful) iostream system (do most objects need to know how to print info about themselves?  rarely.  so why use that over something like fprintf?).  The decision should be made based upon your needs, what code you currently have access to, the amount of time you have, and how comfortable you are with an API you have no/little control over.  It shouldn't be made by some professor or book that said you shouldn't because it doesn't fit into the "C++" way of doing things.

Quote from: Camel on June 06, 2003, 06:27 PM
imo, c++ is crap. if you dont like pointers, dont use c. it's that simple.

Depends on how you use it.  Use it llike a better C and it's very powerful.  Use it as strictly an OO language and adhering to the lame philosphy many professors/books try to impose on you all the time and other languages like Small Talk/Java look a lot better.

Camel

#9
Quote from: herzog_zwei on June 06, 2003, 07:04 PMThat sort of thinking is the reason for a lot of the bloat in today's software.  Sure, you can buy the state of the art machine with 1TB of memory to run a program written with all the bloat.  Or you can get an old system and run it with 64MB if it were written with resource limits in mind.  Memory overhead for a string used in strstr: 1 byte.  Overhead for a basic_string class: depends on the compiler but you can bet it's well over 16 bytes.  That doesn't include the extra overhead in using the vtables.  C++ can make life easier, but use the right thing for the job.  If you want safer type-checking/bounds-checking, use some other language like BASIC, Java, or some scripting language.  If you want power, use C.  If you want the power of C with a few extra bells/whistles to make OOP easier, use C++.  If you're not good with static strings or have to deal a lot with dynamic strings, use some string class.  Classes can make life easier and easier to maintain (for strings, an example would be switching to Unicode instead of ASCII) but you do pay some price for it.  Same thing applies with the bloated (though useful) iostream system (do most objects need to know how to print info about themselves?  rarely.  so why use that over something like fprintf?).  The decision should be made based upon your needs, what code you currently have access to, the amount of time you have, and how comfortable you are with an API you have no/little control over.  It shouldn't be made by some professor or book that said you shouldn't because it doesn't fit into the "C++" way of doing things.

+1 for flaming c++ in >3 sentances

Quote from: herzog_zwei on June 06, 2003, 07:04 PM
Depends on how you use it.  Use it llike a better C and it's very powerful.  Use it as strictly an OO language and adhering to the lame philosphy many professors/books try to impose on you all the time and other languages like Small Talk/Java look a lot better.

a better c? the only thing that's useful at all is the ability of classes to have functions, and that can be used without violating *any* other of the definitions of c (not that there are any others).
as i said before, the only difference between c and c++ is overhead and classes. use classes, but dont use all that other iostream crap or whatever; it's a waste. printf is cooler than cout, anyways.

herzog_zwei

#10
Quote from: Camel on June 06, 2003, 07:09 PM
a better c? the only thing that's useful at all is the ability of classes to have functions, and that can be used without violating *any* other of the definitions of c (not that there are any others).
as i said before, the only difference between c and c++ is overhead and classes. use classes, but dont use all that other iostream crap or whatever; it's a waste. printf is cooler than cout, anyways.

Agreed.  C++ is C with classes, polymorphism, (limited/broken) inheritance, and templates.  Aside from polymorphism and templates, the other things can be done in standard C (take a look at X-Windows) but can leave room for lots of mistakes (or you can consider that a "feature").  Most of the C++ libraries are crap and you should just use the C ones.  You should write C++ programs with a OO C mindset instead of an OO C++ one.  Even most built-in C++ RTTI implementations are bloated and not too useful; you should just write your own RTTI.  C++ does have better exception handling (you can do that in C as well but not quite as well) but it's not that great and should be used sparingly due to overhead incurred in its use (even when exceptions aren't thrown).  Templates are useful, but most of the time isn't needed (though a good application of it would be easy and almost effortless reference counting for objects).  Polymorphism is useful and what makes the compiler know what function to use.  Some forms of it can be done in OO C easily, but the one with the same name and varying arguments can't be done as easily (you can go out of your way and use variable args and extra logic to dispatch to the correct one, but why not just let the C++ compiler do it for your C code?).  One very useful thing about C++ over C is its automatic calling of the destructor when an object falls out of scope (not to mention you can declare variables in places other than the beginning of a scope); this ability lets you do things like lock a critical section of code by declaring a lock object on the stack, which will unlock when the destructor is called.  Example:


C++:
{
  Lock _lock(mutex);
  if(!a()) return;
  if(!b()) return;
  c();
}

C:
{
  mutex.Lock();
  if(!a()) { mutex.Unlock(); return; }
  if(!b()) { mutex.Unlock(); return; }
  c();
  mutex.Unlock();
}

or better:
{
 mutex.Lock();
 if(!a()) goto done;
 if(!b()) goto done;
 c();
done:
 mutex.Unlock();
}


Anyone saying you should never use goto is an idiot and probably writes buggy code that doesn't handle errors well (or quickly if they use exceptions).  Goto has its uses but it shouldn't be abused when it's not needed.  In the latter case, it's being used as a common exit point for the function (that handles resource cleanup) when errors occur (which sometimes isn't as simple as a single line of code).

Yoni

I'm left breathless.
I don't believe in Internet flaming, so I won't elaborate.

herzog_zwei

#12
Quote from: Yoni on June 06, 2003, 08:02 PM
I'm left breathless.
I don't believe in Internet flaming, so I won't elaborate.

I don't want this to sound like flame, but it'll probably be taken that way.

Since when did not agreeing with your philosphy become flaming?  Flames have very low SNR and are generally attacks on individuals.  Most of this thread contains good info from various people, though some of it is off topic.  The way I see it is it's a debate that should be taken elsewhere if it wants to continue.  Debates do not need to reach a definite conclusion but they do educate people and open them up to different POVs.

Moonshine

Quote from: herzog_zwei on June 06, 2003, 07:40 PM
Agreed.  C++ is C with classes, polymorphism, (limited/broken) inheritance, and templates.

Hmm, you missed a few features: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047588051&id=1043284376

c0ol

[quote author=herzog_zwei link=board=17;threadid=1555;start=0#msg11759
Anyone saying you should never use goto is an idiot and probably writes buggy code that doesn't handle errors well (or quickly if they use exceptions).  Goto has its uses but it shouldn't be abused when it's not needed.  In the latter case, it's being used as a common exit point for the function (that handles resource cleanup) when errors occur (which sometimes isn't as simple as a single line of code).

Quote
uhh goto in C and most other languages with control structures is usually bad form, instead use statements like break and continue.