Raised This Month: $12 Target: $400
 3% 

[INC] New chars


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
diablix
Senior Member
Join Date: Jan 2010
Location: Warsaw, Poland
Old 08-15-2011 , 19:38   [INC] New chars
Reply With Quote #1

New chars
by diablix


At the begining I'll just say that my english isn't good.

Here is what I mean (Yes, in this example I used Polish letters)



Stock that allows you to use new letters.
These letters with my stock can be coded with UTF8 HEX system metod.

A lot of compilers (like AMXX-Studio) won't allow you to compile some "weird" chars (everything is automatically coded into ASCII) but with this stock it is posibble.

How to?

Add here the char that you wanna use with the stock (if u don't get it, hope you will at the end) For example, we'll make REGISTERED SIGN. I'll name it as 'R'

PHP Code:
new const chNewChars[] = {
    
'ą',
    
'ó',
    
'ę',
    
'ż',
    
'ź',
    
'ł',
    
'ń',
    
'ć',
    
'ś',
    
    
'Ą',
    
'Ó',
    
'Ę',
    
'Ż',
    
'Ź',
    
'Ł',
    
'Ń',
    
'Ć',
    
'Ś',
    
'R'
}; 
Now here, add the UTF8 code in HEX system. List of chars can be found Here.

it should be in format

{0xFFFFFF**, 0xFFFFFF**, 0}

For example

The bolded text is what we are looking for

U+00AE ® c2 ae REGISTERED SIGN

so to add that char you will have to extend the table and add your utf8 combination. Our "registered sign" had c2 ae so the code will look like this :

{0xFFFFFFC2, 0xFFFFFFAE, 0}

PHP Code:
new const iUTF8_HEX[sizeof chNewChars][] = { 
    {
0xFFFFFFC4,  0xFFFFFF850},     // ą
    
{0xFFFFFFC3,  0xFFFFFFB30},     // ó
    
{0xFFFFFFC4,  0xFFFFFF990},    // ę
    
{0xFFFFFFC5,  0xFFFFFFBC0},    // ż
    
{0xFFFFFFC5,  0xFFFFFFBA0},    // ź
    
{0xFFFFFFC5,  0xFFFFFF820},    // ł
    
{0xFFFFFFC5,  0xFFFFFF840},    // ń
    
{0xFFFFFFC4,  0xFFFFFF870},    // ć
    
{0xFFFFFFC5,  0xFFFFFF9B0},    // ś
    
    
{0xFFFFFFC4,  0xFFFFFF840},     // Ą
    
{0xFFFFFFC3,  0xFFFFFF930},     // Ó
    
{0xFFFFFFC4,  0xFFFFFF980},     // Ę
    
{0xFFFFFFC5,  0xFFFFFFBB0},     // Ż
    
{0xFFFFFFC5,  0xFFFFFFB90},     // Ź
    
{0xFFFFFFC5,  0xFFFFFF810},     // Ł
    
{0xFFFFFFC5,  0xFFFFFF830},     // Ń
    
{0xFFFFFFC4,  0xFFFFFF860},     // Ć
    
{0xFFFFFFC5,  0xFFFFFF9A0},     // Ś
    
{0xFFFFFFC2,  0xFFFFFFAE0}      // (R) SIGN
}; 
And now just use the modified include in your plugin.

And here is the part with "sign name".

PHP Code:
#include <newchars>
public plugin_init() {
    new 
sSign[3];
    
newChar('R'sSignsizeof sSign 1); //We named it as 'R' in chNewChars
    
    
client_print(03"REGISTERED SIGN : %s"sTab);

In the attachment you got only version with polish letters. To add your own chars, just follow How To guide.
Attached Files
File Type: inc newchars.inc (1.3 KB, 542 views)

Last edited by diablix; 08-15-2011 at 19:42.
diablix is offline
Send a message via Skype™ to diablix
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-15-2011 , 19:46   Re: Stock: New chars
Reply With Quote #2

More examples?
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Shadows In Rain
Senior Member
Join Date: Apr 2010
Location: Russia::Siberia
Old 08-15-2011 , 19:55   Re: Stock: New chars
Reply With Quote #3

Wrong forum, i see no modules.

IMO it is extreme unusable feature for absurdly lazy scripters.
Save files in appropriate encoding and compile manually, or (what is better) use translation libraries.
__________________
I'm using Google translator, yarrr. |.◕‿‿◕.|
Shadows In Rain is offline
Send a message via ICQ to Shadows In Rain
diablix
Senior Member
Join Date: Jan 2010
Location: Warsaw, Poland
Old 08-15-2011 , 19:57   Re: Stock: New chars
Reply With Quote #4

Damn I wanted to post it in Tutorial / Code-snippets ... Can any moderator move this topic? D:
diablix is offline
Send a message via Skype™ to diablix
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-15-2011 , 19:58   Re: Stock: New chars
Reply With Quote #5

FYI, AMXX-Studio is not a compiler. It uses the same compiler that everybody uses.
__________________
fysiks is offline
diablix
Senior Member
Join Date: Jan 2010
Location: Warsaw, Poland
Old 08-15-2011 , 20:00   Re: Stock: New chars
Reply With Quote #6

As far as I know you can compile some letters in PAWN Studio but if you save .sma files with AMXX-Studio all the text is coded into ASCII. Thats what I mean.

EDIT: Just try to compile normal plugin with any new char with AMXX-Studio, it will compile but even if it will, it won't appear in game.
diablix is offline
Send a message via Skype™ to diablix
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-15-2011 , 20:42   Re: Stock: New chars
Reply With Quote #7

I don't use either of those. The determining factor is the file encoding (ascii or unicode).
__________________
fysiks is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-20-2011 , 11:56   Re: [INC] New chars
Reply With Quote #8

I got no changing with using this.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Old 08-24-2011, 12:42
963258741
This message has been deleted by Exolent[jNr]. Reason: Spam
Old 08-24-2011, 13:12
abdul-rehman
This message has been deleted by Exolent[jNr]. Reason: Spam
sOnick
Senior Member
Join Date: Aug 2007
Old 09-19-2011 , 16:59   Re: [INC] New chars
Reply With Quote #9

I do not understand what its wrong

here
Code:
#if defined _newchars_included
    #endinput
#endif

#define _newchars_included

#if !defined _amxmodx_included
    #include <amxmodx>
#endif

new const chNewChars[] = {
    'ă',
    'Ă',
    'ţ',
    'Ţ',
    'Ş',
    'ş',
    'î',
    'Î',
    '©'
};

new const iUTF8_HEX[sizeof chNewChars][] = { 
    {0xFFFFFFC4,  0xFFFFFF83, 0},     // ă
    {0xFFFFFFC4,  0xFFFFFF82, 0},     // Ă
    {0xFFFFFFC5,  0xFFFFFFA3, 0},    // ţ
    {0xFFFFFFC5,  0xFFFFFFA2, 0},    // Ţ
    {0xFFFFFFC5,  0xFFFFFF9E, 0},    // Ş
    {0xFFFFFFC5,  0xFFFFFF9F, 0},    // ş
    {0xFFFFFFC8,  0xFFFFFF8A, 0},    // î
    {0xFFFFFFC8,  0xFFFFFF8B, 0},    // Î
    {0xFFFFFFC2,  0xFFFFFFA9, 0}     // ©

};

stock newChar(const chWhich, sArray[], iLen){
    new bool:bCanBreak = false;
    for(new i = 0 ; i < sizeof chNewChars ; i ++){
        if(chNewChars[i] == chWhich){
            add(sArray, iLen, iUTF8_HEX[i]);
            bCanBreak = true;
        }
        if(bCanBreak) break;
    }
}
Code:
#include <newchars>
public plugin_init() {
    new sSign[3];
    newChar('R', sSign, sizeof sSign - 1); //We named it as 'R' in chNewChars
    
    client_print(0, 3, "REGISTERED SIGN : %s", sTab);
}
__________________
I love zm servers
sOnick is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 09-20-2011 , 14:36   Re: [INC] New chars
Reply With Quote #10

Hm. looks like I can use ASCII symbols in chat like
(c) Im g0dl1ke. ®
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne 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 04:29.


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