Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A
- /*\
- /!!!\
- /!!!!!\
- /!!!!!!!\
- /!!!!!!!!!\
- /!!!!!!!!!!!\
- /!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!READ!ME!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!!!!!!!\ *//*
- /!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
- /!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
- /+===================================+\
- / LangFiles v0.1 Include made by Meta \
- /+=======================================+\ *//*
- / With this Inlcude you can write a script \
- / completely without hard-coded texts. The \
- / texts get included from external files with \
- / names based on their language code (e.g. "EN"). \
- / You can create a file for your language or create \
- / a new one like klingon or some other shit :D. \ *//*
- /+=====================================================+\
- / What you are NOT allowed to do: (default shit ^^) \
- / - use it for commercial projects \ *//*
- / - leave SA:MP \
- / - re-release it and/or claim it as your work (very easy xD) \
- / - use it for commercial projects \
- / - play IV:MP \
- __________/+===================================================================+\___________
- |wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww|
- */
- #include <a_samp>
- /*
- example:
- public OnPlayerConnect(playerid) //Player's name is 'peter'!
- {
- new playername[MAX_PLAYER_NAME], string[100];
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string, sizeof(string), "%s%s%s", GetLangVar("DE", "HelloText"), playername, GetLangVar("DE", "HelloText2")); print(string);
- // Hallo, Peter, willkommen auf unserem Server!
- format(string, sizeof(string), "%s%s%s", GetLangVar("ENG", "HelloText"), playername, GetLangVar("ENG", "HelloText2")); print(string);
- // Hello, Peter, welcome to our server!
- format(string, sizeof(string), "%s%s%s", GetLangVar("JP", "HelloText"), playername, GetLangVar("JP", "HelloText2")); print(string);
- // Kon'nichiwa, Peter, Watashi-tachi no sâba e yôkoso!
- }
- */
- stock GetLangVar(lang[256], langvar[50])
- /*
- Example: You want the spanish Text stored in variable "Foo" (You must have "E.lang" or "Foo.lang" or whatever).
- Use it like this:
- GetLangVar("ES", "Foo")
- ^ Language ^ Variable
- */
- {
- new string[80], key[256], Data[256];
- format(string, sizeof(string), "Language/%s.lang", lang);
- new File: LangFile = fopen(string, io_read);
- string = "-[#]-";
- if(LangFile)
- {
- while(fread(LangFile, Data, sizeof(Data)))
- {
- key = ini_GetKey(Data);
- if(strfind(Data, "\n") != -1) { strdel(Data, strlen(Data)-1, strlen(Data)); }
- if(strcmp(key, langvar, true) == 0)
- {
- format(string, strlen(Data), "%s", ini_GetValue(Data)); break;
- }
- }
- fclose(LangFile);
- }
- return string;
- }
- stock ini_GetKey(line[])
- {
- new keyRes[256]; keyRes[0] = 0;
- if(strfind(line, "=", true) == -1) return keyRes;
- strmid(keyRes, line, 0, strfind(line, "=", true), sizeof(keyRes)); return keyRes;
- }
- stock ini_GetValue(line[])
- {
- new valRes[256]; valRes[0]=0;
- if(strfind(line, "=", true) == -1) return valRes;
- strmid(valRes, line, strfind(line, "=", true)+1, strlen(line), sizeof(valRes)); return valRes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement