[Include] stormLang 1.0.0 - Use more than 1 language
#1

I am here to introduce you...

stormLang


Currently supports English, Spanish, German, and Polish - And it's easy to add more!

News
February 20, 2013: Released 1.0.1, a bug fix update. 1.0.2 will now be when i add more languages

FUNCTIONS
SetPlayerLanguage - Easily set someone's language!
pawn Код:
SetPlayerLanguage(playerid, language);
/*/Options
-1 = No language selected
0 = English
1 = Spanish
2 = German
3 = Polish
/////*/
SendMessage - Send a message in a language - No more files with all your strings!
pawn Код:
SendMessage(playerid, color, English[], Spanish[], German[], Polish[])
/*If you get an error about the line being too long, do it like:
SendMessage(playerid, yourcolorhere, "EnglishMessage", "SpanishMessage",
"GermanMessage", "PolishMessage");
See? It was on 2 lines!*/
GetPlayerLanguageName - Get a player's language's name!
pawn Код:
GetPlayerLanguageName(playerid); //It will return the name, for example you could do it in /stats
GetPlayerLanguage - Get a player's language number!
pawn Код:
GetPlayerLanguage(playerid); //It will return a number, for example, 0 is english.

CALLBACKS
No callbacks.

NOTES
Make sure you add a way to change language in your GM!

How to add more/change a language
So, to do this, you need to change a few things. For this example, we will use french and will be adding a line.

First, you need to go to SetPlayerLanguage.
You will see this:
pawn Код:
stock SetPlayerLanguage(playerid, language);
{
    if(language == -1) return pLanguage[playerid] = -1;
    if(language == 0) return pLanguage = 0;
    if(language == 1) return pLanguage = 1;
    if(language == 2) return pLanguage = 2;
    if(language == 3) return pLanguage = 3;
}
Add another language line.
pawn Код:
stock SetPlayerLanguage(playerid, language);
{
    if(language == -1) return pLanguage[playerid] = -1;
    if(language == 0) return pLanguage[playerid] = 0;
    if(language == 1) return pLanguage[playerid] = 1;
    if(language == 2) return pLanguage[playerid] = 2;
    if(language == 3) return pLanguage[playerid] = 3;
        if(language == 4) return pLanguage[playerid] = 4; //French
}
Then change SendMessage to this:
pawn Код:
stock SendMessage(playerid, color, English[], Spanish[], German[], Polish[], French[])
{
    switch(pLanguage[playerid])
    {
        case 0: //English
        {
            SendClientMessage(playerid, color, English);
        }
        case 1: //Spanish
        {
            SendClientMessage(playerid, color, Spanish);
        }
        case 2: //German
        {
            SendClientMessage(playerid, color, German);
        }
        case 3: //Polish
        {
            SendClientMessage(playerid, color, Polish);
        }
        case 4: //French
        {
            SendClientMessage(playerid, color, French);
        }
    }
    return true;
}
After that, change the other 2 stocks:
pawn Код:
stock GetPlayerLanguageName(playerid)
{
    new name[35];

    if(pLanguage[playerid] == -1)
    {
        name = "No Language";
    }

    if(pLanguage[playerid] == 0)
    {
        name = "English";
    }

    if(pLanguage[playerid] == 1)
    {
        name = "Espanol";
    }

    if(pLanguage[playerid] == 2)
    {
        name = "Deutsch";
    }
   
    if(pLanguage[playerid] == 3)
    {
        name = "Polski";
    }
   
    if(pLanguage[playerid] == 4)
    {
        name = "Francais"
    }
    return name;
}

stock GetPlayerLanguage(playerid)
{
    new lan;

    if(pLanguage[playerid] == -1)
    {
        lan = -1;
    }
   
    if(pLanguage[playerid] == 0)
    {
        lan = 0;
    }
   
    if(pLanguage[playerid] == 1)
    {
        lan = 1;
    }
   
    if(pLanguage[playerid] == 2)
    {
        lan = 2;
    }
   
    if(pLanguage[playerid] == 3)
    {
        lan = 3;
    }
   
    if(pLanguage[playerid] == 4)
    {
        lan = 4;
    }
    return lan;
}
You're done!

Download:
Adf.ly: http://adf.ly/JIFZs
Direct: https://dl.dropbox.com/u/77376451/stormlang.inc

Thank you!

Please report any bugs you find.

NEWS FEED
IT'S NOT REALLY A FEED
Update 1.0.2 coming soon! Adding advanced features such as disabling certain languages! And more languages!
Coming soon is version 1.0.2!
Credits
Me (stormchaser206): For the script
pds2k12: Fixing 1.0.0 for 1.0.1
Reply
#2

Easy but nice, add new languages
Reply
#3

Quote:
Originally Posted by E_Meec
Посмотреть сообщение
Easy but nice, add new languages
I will add more in 1.0.1, also there is a tutorial in the post on how to add more

Edit:: v1.0.1 is a bug fix update, 1.0.2 will add more.
Reply
#4

Hm.. nice ..
Reply
#5

Quote:
Originally Posted by gabyk
Посмотреть сообщение
Hm.. nice ..
Thanks.
Reply
#6

pawn Код:
stock SetPlayerLanguage(playerid, language);
{
    if(language == -1) return pLanguage[playerid] = -1;
    if(language == 0) return pLanguage[playerid] = 0;
    if(language == 1) return pLanguage[playerid] = 1;
    if(language == 2) return pLanguage[playerid] = 2;
    if(language == 3) return pLanguage[playerid] = 3;
}
Can be:

pawn Код:
stock SetPlayerLanguage(playerid, language);
{
    pLanguage[playerid] = language;
    return 1;
}
Or
pawn Код:
stock GetPlayerLanguage(playerid)
{
    new lan;

    if(pLanguage[playerid] == -1)
    {
        lan = -1;
    }
   
    if(pLanguage[playerid] == 0)
    {
        lan = 0;
    }
   
    if(pLanguage[playerid] == 1)
    {
        lan = 1;
    }
   
    if(pLanguage[playerid] == 2)
    {
        lan = 2;
    }
   
    if(pLanguage[playerid] == 3)
    {
        lan = 3;
    }
   
    if(pLanguage[playerid] == 4)
    {
        lan = 4;
    }
    return lan;
}
Can be:

pawn Код:
#define GetPlayerLanguage(%1) (pLanguage[%1])
Reply
#7

y_languages is more efficient...
Reply
#8

1.0.1 released, 1.0.1 is a bug fix update.

Credits to pds2012 for finding the bugs when i was getting errors in my GM
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)