Raised This Month: $ Target: $400
 0% 

[HELP] Fix needed


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2008 , 11:02   Re: [HELP] Fix needed
Reply With Quote #2

PHP Code:
new  enableplTag[33][33]
static 
BaseDir[64], FileDir[64], FileIP[64]
new 
bool:tagged[33]
new 
bool:connectshown[33];

public 
plugin_init() {
 
 
register_plugin(PLUGINVERSIONAUTHOR)
 
enable register_cvar("tag_by_ip""1")
 
}
 
public 
plugin_cfg() {
 
 
get_basedir(BaseDirCharsMax(BaseDir))
 
 
formatex(FileDirCharsMax(FileDir), "%s/TagByIp"BaseDir)
 
formatex(FileIPCharsMax(FileIP), "%s/Tag_By_Ip.cfg"FileDir)
 if(!
dir_exists(FileDir))
  
mkdir(FileDir)
 
 if(!
file_exists(FileIP))
  
write_file(FileIP";Add the beggining of Ip and prefered Tag: 127=[LOC]", -1)
 
}
public 
readfile(id) {
 
 new 
Ip[16], pIp[16], Tag[33], Buffer[64]
 static 
iFile
 
 get_user_ip
(idpIpCharsMax(Ip), 1)
 
 
iFile fopen(FileIP"rt")
 while(!
feof(iFile))
 {
  
fgets(iFileBufferCharsMax(Buffer));
 
  if((
Buffer[0] == ';') || (Buffer[0] == '/' && Buffer[1] == '/'))
   continue
 
  
strtok(BufferIpCharsMax(Ip), TagCharsMax(Tag), '='1)
 
  if(
ipmatch(pIpIp))
  {
   
tagged[id] = true
   copy
(plTag[id], CharsMax(Tag), Tag)
   
fclose(iFile)
   return 
PLUGIN_CONTINUE
  
}
 
 }
 
tagged[id] = false
 plTag
[id] = ""
 
fclose(iFile)
 return 
PLUGIN_CONTINUE
}
stock bool:ipmatch(pIp[], Ip[]) {
 
 new 
len
 
 len 
strlen(Ip) - 1
 
for(new i=0i<=leni++)
 {
  if(
pIp[i] != Ip[i])
  return 
false
 
}
 return 
true 
}
public 
client_putinserver(id) {
 
 if(!
get_pcvar_num(enable))
  return 
PLUGIN_HANDLED
 
 tagged
[id] = false
 plTag
[id] = ""
 
readfile(id)
 if(
tagged[id])
 {
  new 
OldName[32], TName[64]
  
get_user_name(idOldNameCharsMax(OldName))
 
  if( (
contain(OldNameplTag[id]) ==-1) && (connectshown[id] == false) )
  {
   
format(TNameCharsMax(TName), "%s%s"plTag[id], OldName)
   
set_user_info(id"name"TName
   
connectshown[id] = true;
  }
 }
 return 
PLUGIN_HANDLED
}
public 
client_disconnect(id) {
 
 
connectshown[id] = false;
 
tagged[id] = false
 plTag
[id] = ""
}
public 
client_infochanged(id) {
 
 if(!
get_pcvar_num(enable))
  return 
PLUGIN_HANDLED
 
 readfile
(id)
 if(
tagged[id])
 {
  new 
OldName[32], TName[64], NewName[64]
  
get_user_name(idOldNameCharsMax(OldName))
  
get_user_info(id"name"NewNameCharsMax(NewName))
 
  if(!
equali(NewNameOldName))
  {
   if(
contain(NewNameplTag[id]) ==-1)
   {
    
format(TNameCharsMax(TName), "%s%s"plTag[id], NewName)
    
set_user_info(id"name"TName)
   }
 
  }
 }
 
 return 
PLUGIN_HANDLED

__________________
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:38.


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