Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: rulk on September 07, 2009, 10:42:37 PM

Title: Extract Clan Tags from Nick-Name
Post by: rulk on September 07, 2009, 10:42:37 PM
Hya guys,

This is my version of extracting the clan tag from a players name.

It uses mIRC's regex engine and is pretty fast because strings are cached before using them.


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered:
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Note: Combinations are also valid.
; --------------------------

alias FindClanTag {
  var %HasTag = $regex( $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  if (%HasTag > 0) return $regml(1)
}



Some superb regex tutorials and one hour tests can be found at #regex on the undernet network "irc.undernet.org"

alternatively, you might find reading THIS WEBSITE (http://www.regular-expressions.info/tutorial.html) beneficial

I have enjoyed using both methods and can be found taking the regex tests quite regularly, if you need any assistance in breaking down this particular expression, don't hesitate to ask me.

Hope this helps you guys.

Kind Regards

Luke Rudge (rulk)
Title: Re: Extract Clan Tags from Nick-Name
Post by: [XT]ariel[X] on September 08, 2009, 02:05:52 AM
ok tranks :)
Title: Re: Extract Clan Tags from Nick-Name
Post by: rulk on September 08, 2009, 04:56:42 PM
Hya guys,

Here is an update on the clan tag extraction using mIRC's regex engine.

It now covers both single and double delimiter clan tags (apologies to ULK. for excluding them)

I have decided not to couple both expressions into one, to eliminate confusion for beginners.

I recommend that unless this update is needed you stick with the one in the first post.


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered: (Double Delimiter)
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Tags Covered: (Single Delimiter)
; ULK. ULK_ ULK=
;
; Note: Combinations are also valid for double delimiter tags.
; Note: Combinations are NOT valid for single delimiter tags
; --------------------------

alias FindClanTag {
  var %Double_Delim = $regex( D_DELIM, $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  var %Single_Delim = $regex( S_DELIM, $1,  (\w+[.=_]+) )
  return $iif( %Double_Delim > 0, $regml(D_DELIM, 1), $regml(S_DELIM, 1) )
}


Happy coding.

Kind Regards

Luke Rudge (rulk)
Title: Re: Extract Clan Tags from Nick-Name
Post by: thijn on September 08, 2009, 07:51:00 PM
Very nice!
Title: Re: Extract Clan Tags from Nick-Name
Post by: creepers on September 12, 2009, 12:59:27 AM
the underscore isn't a good idea for a clan tag detection

like if The_Don comes in without a tag, the clan would be "The"
Title: Re: Extract Clan Tags from Nick-Name
Post by: Usaji on September 13, 2009, 03:57:27 AM
Great Alias rulk, but would u please rewrite the alias so it does not detect the ULK_ ?

Thanks in advance
Title: Re: Extract Clan Tags from Nick-Name
Post by: Obito on September 13, 2009, 05:29:48 AM
Quote from: creepers on September 12, 2009, 12:59:27 AM
the underscore isn't a good idea for a clan tag detection

like if The_Don comes in without a tag, the clan would be "The"
wrong
that will happend if his nick was :
_The_Don
Title: Re: Extract Clan Tags from Nick-Name
Post by: creepers on September 13, 2009, 07:11:31 AM
Quote from: Obito on September 13, 2009, 05:29:48 AM
Quote from: creepers on September 12, 2009, 12:59:27 AM
the underscore isn't a good idea for a clan tag detection

like if The_Don comes in without a tag, the clan would be "The"
wrong
that will happend if his nick was :
_The_Don

?_?

Quote; Tags Covered: (Single Delimiter)
; ULK. ULK_ ULK=
i meant only 1
Title: Re: Extract Clan Tags from Nick-Name
Post by: rulk on September 13, 2009, 05:35:35 PM
Hya Guys,

Tag detection without an underscore for single delimiter


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered: (Double Delimiter)
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Tags Covered: (Single Delimiter)
; ULK. ULK=
;
; Note: Combinations are also valid for double delimiter tags.
; Note: Combinations are NOT valid for single delimiter tags
; --------------------------

alias FindClanTag {
  var %Double_Delim = $regex( D_DELIM, $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  var %Single_Delim = $regex( S_DELIM, $1,  (\w+[.=]+) )
  return $iif( %Double_Delim > 0, $regml(D_DELIM, 1), $regml(S_DELIM, 1) )
}


Any other combinations that need to be removed/added let me know

Kind Regards

Luke Rudge (rulk)
Title: Re: Extract Clan Tags from Nick-Name
Post by: [AoD]NC on September 13, 2009, 06:53:07 PM
Great work rulk! Ideal for clan stats etc.

Btw. the code looks a bit complicated ;D.

Anyway, there is a polish clan with tag L.Team*. Using this script should return "L"...
/me wonders why clans cant have tags in [ ]
Title: Re: Extract Clan Tags from Nick-Name
Post by: rulk on September 13, 2009, 07:40:54 PM
Hya [AoD]NC,

Theres going to be a few tags that wont be catered for, but as they pop up, its simple to add them.

Here is a special edition for your polish friends.


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered: (Double Delimiter)
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Tags Covered: (Single Delimiter)
; ULK. ULK= L.Team*
;
; Note: Combinations are also valid for double delimiter tags.
; Note: Combinations are NOT valid for single delimiter tags
; --------------------------

alias FindClanTag {
  var %Double_Delim = $regex( D_DELIM, $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  var %Single_Delim = $regex( S_DELIM, $1,  (\w.+[.*=]+) )
  return $iif( %Double_Delim > 0, $regml(D_DELIM, 1), $regml(S_DELIM, 1) )
}


Hope this helps

Kind Regards


Luke Rudge (rulk)
Title: Re: Extract Clan Tags from Nick-Name
Post by: kaje on September 13, 2009, 09:24:57 PM
Hey, rulk.
I've read the codes, But I still didn't understood why is this nessecary?
Title: Re: Extract Clan Tags from Nick-Name
Post by: SianMaenad on September 14, 2009, 07:23:56 AM
its in the titel
Title: Re: Extract Clan Tags from Nick-Name
Post by: rulk on September 14, 2009, 09:03:13 PM
Hya Guys,


Here is an amended version, thanks for your comments so far.

kaje: Its a small snippet aimed at people that wish to obtain the clan tag from the players name for whatever purposes they desire.


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered: (Double Delimiter)
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Tags Covered: (Single Delimiter)
; ULK. ULK= L.Team*
;
; Note: Combinations of characters are also valid for
;       both double and single delimiter tags.
; --------------------------

alias FindClanTag {
  var %Double_Delim = $regex( D_DELIM, $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  var %Single_Delim = $regex( S_DELIM, $1,  (\w.+[.*=]+) )
  return $iif( %Double_Delim > 0, $regml(D_DELIM, 1), $regml(S_DELIM, 1) )
}


Dont forget, if there is any combination that you require me to add/remove dont hesitate to ask.

Kind Regards

Luke Rudge (rulk)
Title: Re: Extract Clan Tags from Nick-Name
Post by: [AoD]NC on September 15, 2009, 02:13:05 PM
Rulk u are pr0! :D
Title: Re: Extract Clan Tags from Nick-Name
Post by: kaje on September 17, 2009, 07:45:15 PM
Quote from: rulk on September 14, 2009, 09:03:13 PM
Hya Guys,


Here is an amended version, thanks for your comments so far.

kaje: Its a small snippet aimed at people that wish to obtain the clan tag from the players name for whatever purposes they desire.


; -----------USAGE----------
; //echo -a $FindClanTag([MK]rulk)
;
; Tags Covered: (Double Delimiter)
; [MK] (MK) =MK= ^MK^ <MK> -MK-
;
; Tags Covered: (Single Delimiter)
; ULK. ULK= L.Team*
;
; Note: Combinations of characters are also valid for
;       both double and single delimiter tags.
; --------------------------

alias FindClanTag {
  var %Double_Delim = $regex( D_DELIM, $1, /([[(=^<-]+\w+.[])=^>-]+)/ )
  var %Single_Delim = $regex( S_DELIM, $1,  (\w.+[.*=]+) )
  return $iif( %Double_Delim > 0, $regml(D_DELIM, 1), $regml(S_DELIM, 1) )
}


Dont forget, if there is any combination that you require me to add/remove dont hesitate to ask.

Kind Regards

Luke Rudge (rulk)
Thank you for explaining me.
Title: Re: Extract Clan Tags from Nick-Name
Post by: [-xerox-] on November 05, 2010, 01:50:27 PM
do this work ?