AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   catching uppercase... (https://forums.alliedmods.net/showthread.php?t=95740)

Dr.G 06-26-2009 16:53

catching uppercase...
 
can someone explain to me how this function catches 'big' letters

PHP Code:

public say_hook(id
{
 if ((
get_user_flags(id) & ADMIN_IMMUNITY) && (get_cvar_num("amx_caps_obeyimmunity") == 1)) 
 {
  return 
PLUGIN_CONTINUE
 
}  
 
 new 
text[256]
 new 
minlen get_cvar_num("amx_caps_minlen")
 new 
Float:minpercent float(get_cvar_num("amx_caps_minpercent"))
 
 
read_args(text,256)
 
 new 
len strlen(text) - 2
 
 
if (len minlen) {
  return 
PLUGIN_CONTINUE
 
}
 
 new 
0
 
 
for (new 1;<= len;i++) 
 {
 
  if (
text[i] > 64 && text[i] < 91
  {
   
x++
  }
 } 
 
 new 
Float:percent = (float(x) / float(len)) * 100.0
 
 
if (percent >= minpercent
 {
  
punish(id)
  return 
PLUGIN_CONTINUE
 
}
 
 
 return 
PLUGIN_CONTINUE


i got it from http://forums.alliedmods.net/showthread.php?p=109695


- cheers!

xPaw 06-26-2009 16:55

Re: catching uppercase...
 
[I]if (text[i] > 64 && text < 91)

Ansii chars or what ever there is

Exolent[jNr] 06-26-2009 17:05

Re: catching uppercase...
 
http://www.asciitable.com/asciifull.gif

The ascii values for the capital letters are 65 ('A') to 90 ('Z').

Dr.G 06-26-2009 17:05

Re: catching uppercase...
 
oh ok i see. thank you


All times are GMT -4. The time now is 15:25.

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