AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Having problem with containi (https://forums.alliedmods.net/showthread.php?t=153650)

killergirl 03-27-2011 05:22

Having problem with containi
 
I'm trying to make a restriction for clients who changed their name or uses symbols: "~ `"

Here is the code:

PHP Code:

public client_infochanged(id)
{
new 
Name[32]

get_user_name(idName31)

   if(
containi(Name"`"))
   {
      
set_user_info(id"name""SYMBOL")
   }
return 
PLUGIN_HANDLED


The code it's working only if the client change his name into "`". But if the client change his name into "`````````" or "a``````````" the code won't work.

lis_16 03-27-2011 07:22

Re: Having problem with containi
 
Your code should work but try with this:
PHP Code:

if(contain(Name"`") !=-1


Emp` 03-27-2011 13:50

Re: Having problem with containi
 
Remember that the contain natives return the location where the string was found. -1 being returned if it is not found.

lis_16 03-27-2011 16:20

Re: Having problem with containi
 
So if a string we are looking for is first, conatin return 0, so it's found but if don't work. My way should work-works for me :D


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

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