SA-MP Forums Archive
[Include] Rui Almeida Tradutor - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+----- Forum: Lançamentos/Releases (https://sampforum.blast.hk/forumdisplay.php?fid=56)
+----- Thread: [Include] Rui Almeida Tradutor (/showthread.php?tid=549651)



Rui Almeida Tradutor - VeNuZ_ - 07.12.2014

Rui Almeida Tradutor

Continuaзгo

Continuaзгo desta include para plugin.
Aqui: https://sampforum.blast.hk/showthread.php?tid=551121
Continuaзгo realizada pelo Willian_Luigi. Obrigado!


Introduзгo

Olб, esta й a minha primeira include, e server para criar um servidor Multi-Lang.

A ideia de criar esta include surgiu quando estava a ver um tуpico e todas as formas que via de traduzir o gamemode ocupava no mнnimo 4 linhas, com esta include necessita apenas de 1 linha! Й um cуdigo muito simples mas bom (penso eu xD).


Funзхes
pawn Код:
RT_setText(lang[], key[], text[]) ou RT::setText(lang[], key[], text[])
Serve para guardar uma frase no ficheiro da linguagem.
pawn Код:
//Exemplo:
  //Caso pt:
      RT::setText("pt", "HELLO", "Olб, %s!");
  //Caso ing:
      RT::setText("ing", "HELLO", "Hello, %s!");
================================================== ===

pawn Код:
RT_getText(lang[], key[]) ou RT::getText(lang[], key[])
Serve para ir buscar uma frase existente.
pawn Код:
//Exemplo:
  new string[128];
  formatF(string, RT::getText("pt", "HELLO"), "WPNiGGas_");//Este define jб vкm com o include
  SendClientMessage(playerid, 0xFFFFFFFF, string);
================================================== =====

Exemplo de como usar
pawn Код:
#include <a_samp>

#define FILE_DIRECTORY "langs/%s.ini" // tem de estar antes de inserir a include!

#include <RA_T>

#define DEFAULT_LANG    "ing"

#define LANG_PT "pt" // nome do ficheiro da linguagem
#define LANG_ING "ing" // o mesmo..


new lang[MAX_PLAYERS][10]; // Variбvel que define qual a linguagem do jogador

new message[128];
main(){}

public OnGameModeInit()
{
    // Inserir as frases nos ficheiros!
    RT::setText(LANG_ING,   "WELCOME_MESSAGE""Hello %s, choise your language! Use /pt or /ing!");//como й a default so precisamos da mensagem em inglкs!
    RT::setText(LANG_ING,   "HELLO",    "Hello, %s!");
    RT::setText(LANG_ING,   "CHAT_SAY", "%s (%d) say:");
    RT::setText(LANG_PT,    "HELLO",    "Olб, %s!");
    RT::setText(LANG_PT,    "CHAT_SAY", "%s (%d) diz:");
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    lang[playerid] = DEFAULT_LANG;

    formatText(message, RT::getText(lang[playerid], "WELCOME_MESSAGE"), getName(playerid));
    SendClientMessage(playerid, 0xFFFFFF, message);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/pt", true))//escolher linguagem pt
    {
        lang[playerid] = LANG_PT;

        formatText(message, RT::getText(lang[playerid], "HELLO"), getName(playerid));
        SendClientMessage(playerid, 0xFFFFFF, message);
        return 1;
    }

    if(!strcmp(cmdtext, "/ing", true))//escolher linguagem ing
    {
        lang[playerid] = LANG_ING;

        formatText(message, RT::getText(lang[playerid], "HELLO"), getName(playerid));
        SendClientMessage(playerid, 0xFFFFFF, message);
        return 1;
    }
    return 0;
}

public OnPlayerText(playerid, text[])
{
    for(new i; i <= GetMaxPlayers(); i++)
    {
        formatText(message, RT::getText(lang[i], "CHAT_SAY"), getName(playerid), playerid);
        SendClientMessage(i, -1, message);
    }
    return 0;
}

stock getName(playerid)
{
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof name);
    return name;
}
Download

Pastebin

Crйditos

Ao respetivo criador da include DOF2.
E a mim.
Espero feeback, cumpz!


Re: Rui Almeida Tradutor - Artista - 08.12.2014

Bem ъtil, parabйns =)


Re: Rui Almeida Tradutor - zSuYaNw - 08.12.2014

Nгo gostei.

Algo simples vocк transformou em uma coisa complicada nada haver.


Poderia ter feito algo parecido com isto:

pawn Код:
<?php

new
    pLang[ MAX_PLAYERS ]
;





stock GetLang(p){
    static lang[50];
    if(pLang[p] == 0) lang = "default";
    if(pLang[p] == 1) lang = "inglкs";
    if(pLang[p] == 2) lang = "portuguкs";
   
    return lang;
}



// OnPlayerConnect
LoadPlayerTexts(playerid);


E tambйm a dependкncia da include DOF2.



Leia este tуpico: https://sampwiki.blast.hk/wiki/Fread

Que irб explicar como ler linha por linha.


Re: Rui Almeida Tradutor - VeNuZ_ - 08.12.2014

Nao percebi a finalidade de criar essa stock, se pode-se colocar o nome direto...


Re: Rui Almeida Tradutor - WLSF - 08.12.2014

Primeiramente, parabйns, achei a ideia muito bacana... Porйm o cуdigo deixou a desejar, vocк pretende lanзar versхes novas e atualizadas, para compensar isso ?

Mais uma vez, parabйns...

+rep


Re: Rui Almeida Tradutor - RiqueP - 08.12.2014

Fico уtimo, parabйns


Re: Rui Almeida Tradutor - ipsLuan - 08.12.2014

Ficou bom e serб muito ъtil. Parabйns!


Re: Rui Almeida Tradutor - JonathanFeitosa - 08.12.2014

+REP 5 por nгo ter muitos projetos aqui

Esperamos melhoras, mesmo assim, parabйns


Re: Rui Almeida Tradutor - ReyMysterio - 08.12.2014

Realmente um projeto que nгo se encontra muito aqui na board.

Parabйns e +REP


Re: Rui Almeida Tradutor - PT - 08.12.2014

Concordo com o zSuYaNw complicaste demasiado as coisas em algo que nao era preciso.