Raised This Month: $ Target: $400
 0% 

[HELP] Fix needed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shustas
SourceMod Donor
Join Date: May 2007
Location: London
Old 07-27-2008 , 10:14   [HELP] Fix needed
Reply With Quote #1

*Solved*
__________________

Last edited by shustas; 07-30-2008 at 13:42. Reason: Solved
shustas is offline
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
shustas
SourceMod Donor
Join Date: May 2007
Location: London
Old 07-27-2008 , 11:43   Re: [HELP] Fix needed
Reply With Quote #3

No man, connectshown[id] does not solve the problem.
__________________
shustas is offline
Dr. Jan Itor
Veteran Member
Join Date: Mar 2008
Location: there.
Old 07-27-2008 , 11:57   Re: [HELP] Fix needed
Reply With Quote #4

whats the problem that it wont compile? if thats the case this compiles fine
Code:
new  enable, plTag[33][33]
static BaseDir[64], FileDir[64], FileIP[64]
new bool:tagged[33]
public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR)
 enable = register_cvar("tag_by_ip", "1")
 
}
 
public plugin_cfg() {
 
 get_basedir(BaseDir, charsmax(BaseDir))
 
 formatex(FileDir, charsmax(FileDir), "%s/TagByIp", BaseDir)
 formatex(FileIP, charsmax(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(id, pIp, charsmax(Ip), 1)
 
 iFile = fopen(FileIP, "rt")
 while(!feof(iFile))
 {
  fgets(iFile, Buffer, charsmax(Buffer));
 
  if((Buffer[0] == ';') || (Buffer[0] == '/' && Buffer[1] == '/'))
   continue
 
  strtok(Buffer, Ip, charsmax(Ip), Tag, charsmax(Tag), '=', 1)
 
  if(ipmatch(pIp, Ip))
  {
   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=0; i<=len; i++)
 {
  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(id, OldName, charsmax(OldName))
 
  if(contain(OldName, plTag[id]) ==-1)
  {
   format(TName, charsmax(TName), "%s%s", plTag[id], OldName)
   set_user_info(id, "name", TName) 
  }
 }
 return PLUGIN_HANDLED
}
public client_disconnect(id) {
 
 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(id, OldName, charsmax(OldName))
  get_user_info(id, "name", NewName, charsmax(NewName))
 
  if(!equali(NewName, OldName))
  {
   if(contain(NewName, plTag[id]) ==-1)
   {
    format(TName, charsmax(TName), "%s%s", plTag[id], NewName)
    set_user_info(id, "name", TName)
   }
 
  }
 }
 
 return PLUGIN_HANDLED
}
__________________
Dr. Jan Itor is offline
shustas
SourceMod Donor
Join Date: May 2007
Location: London
Old 07-27-2008 , 12:04   Re: [HELP] Fix needed
Reply With Quote #5

Im not talking about compile. Short intro. It reads from file the beggining of ip and asociated tag with it. Now everything is ok, except when i first connect and it reads my ip and assigns tag to my nick, it adds tag twice to my nick. Like [tag][tag]Nick
__________________
shustas is offline
shustas
SourceMod Donor
Join Date: May 2007
Location: London
Old 07-28-2008 , 12:14   Re: [HELP] Fix needed
Reply With Quote #6

Thanks Jan, but its not. I got no more ideas
__________________
shustas is offline
Reply


Thread Tools
Display Modes

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