PHP function to handle nickname colors/formatting?

Moderators: Xymph, NADEO

User avatar
slugish
Posts: 125
Joined: 10 Jul 2012, 04:30
Location: United States | Kentucky | Somerset
Contact:

PHP function to handle nickname colors/formatting?

Post by slugish »

I am working on a script to display players in my servers on my site. I want to display players by nickname, but am stuck with converting names. I would prefer to display nicks using the same color and formatting rules as maniaplanet, but I would settle for a function to strip away formatting and display standard text. I am by no means a php pro, so I would love to avoid coding this from scratch if someone else has already done so. Does anyone have this already?
RamCUP2000
Translator
Translator
Posts: 185
Joined: 15 Jun 2010, 11:14
Location: Czech republic » Jihomoravský kraj » Břeclav
Contact:

Re: PHP function to handle nickname colors/formatting?

Post by RamCUP2000 »

This is still exist and is compatible with MP
http://fish.stabb.de/index.php5?page=do ... ubpage=127
The_Big_Boo
Posts: 1026
Joined: 15 Jun 2010, 15:46

Re: PHP function to handle nickname colors/formatting?

Post by The_Big_Boo »

You can also check out our ManiaLib classes which we're using in all our projects.
- Formatting: to strip colors, links and other formatting from the string
- StyleParser: a full rework of class given in previous post, which handles formatting as closest to the game as possible and correct a few bugs. You can see the result on the player page for instance.
- Color: mandatory for these classes to work, used to contrast colors.
OS: Win 7 Pro x64
RAM: 2x4GB Corsair @ 1600MHz
CPU: Intel i5 760 @ 3.6GHz
Mobo: Asus P7P55D-E
GPU: NVidia GTX 760 2GB
HDD: WD Black 1TB
Sound: VIA VT1828S (onboard)
Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
User avatar
slugish
Posts: 125
Joined: 10 Jul 2012, 04:30
Location: United States | Kentucky | Somerset
Contact:

Re: PHP function to handle nickname colors/formatting?

Post by slugish »

Sweet... that should be able to handle what I need. Thanks!

Now, this actually confuses me somewhat... What is the difference between Manialib and Maniaplanet Web Services?
The_Big_Boo
Posts: 1026
Joined: 15 Jun 2010, 15:46

Re: PHP function to handle nickname colors/formatting?

Post by The_Big_Boo »

ManiaLib is a lightweight framework to create Manialinks (and web pages) following MVC paradigm, like Zend or Symfony (to take PHP examples).
Maniaplanet Web Services are, well, web services ^^ So they are only useful to request data about players, rankings, ... to send notifications, to make transactions and this kind of thing but it won't handle any UI at all.
OS: Win 7 Pro x64
RAM: 2x4GB Corsair @ 1600MHz
CPU: Intel i5 760 @ 3.6GHz
Mobo: Asus P7P55D-E
GPU: NVidia GTX 760 2GB
HDD: WD Black 1TB
Sound: VIA VT1828S (onboard)
Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
User avatar
magnetik
Posts: 1673
Joined: 01 Feb 2012, 19:13
Location: Bordeaux
Contact:

Re: PHP function to handle nickname colors/formatting?

Post by magnetik »

You can also use JavaScript to parse maniaplanet style.

Take a look at http://magnetik.github.com/maniaplanet-style-js-parser/


it's far from being perfect but still quite usable.

I'll publish a jQuery plugin to make the use easier during the week.
ManiaPlanet technical documentation portal (Dedicated, ManiaLink, ManiaScript, Titles...) -- contribute!
User avatar
slugish
Posts: 125
Joined: 10 Jul 2012, 04:30
Location: United States | Kentucky | Somerset
Contact:

Re: PHP function to handle nickname colors/formatting?

Post by slugish »

RamCUP2000 wrote:This is still exist and is compatible with MP
http://fish.stabb.de/index.php5?page=do ... ubpage=127
Edit: Okay, so the below was after I had tested the script as simply a php file. If I open that file, the below is what shows up. However, if I embed that file in an iframe on my wordpress site, the unicode displays correctly. I have no idea how or why that works, but apparently I have it working now...

I have this working and it handles the colors/formatting great, but it appears to have some trouble with alt code/unicode. Is this an issue with the script, or is this perhaps related to the server I have it running on? Here is an example, I am using the script to parse both the server name and player names. The bottom right corner is an overlay of the page that I have the script running on.

Image
User avatar
steppie
Translator
Translator
Posts: 96
Joined: 25 Apr 2011, 21:55
Location: Denmark

Re: PHP function to handle nickname colors/formatting?

Post by steppie »

Your output page need to encode UTF-8 to show special characters

This should do the trick.

Code: Select all

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
Image
User avatar
niarfman
Posts: 287
Joined: 07 Dec 2012, 10:46

Re: PHP function to handle nickname colors/formatting?

Post by niarfman »

Don't forget to write your file with utf8 character encoding, in case you want to display some special chars too.

This is possible with an editor like notepad++ (Menu: "Encoding"=>Convert to UTF-8).

Player list is already in UTF8 and will be displayed well with the line given by steppie.

Also I have a question in relation with this topic : Does Manialive include specifics fonts used in the game or should we use TAHOMA as usual with Tm ?
User avatar
magnetik
Posts: 1673
Joined: 01 Feb 2012, 19:13
Location: Bordeaux
Contact:

Re: PHP function to handle nickname colors/formatting?

Post by magnetik »

There are no font included.
ManiaPlanet technical documentation portal (Dedicated, ManiaLink, ManiaScript, Titles...) -- contribute!
Post Reply

Return to “General Tools”

Who is online

Users browsing this forum: No registered users and 1 guest