Ir para conteúdo

Posts Recomendados

 

Eae Xtibianos! Td na paz? Eu vim aqui para postar um script que achei na net do sistema de Multi Linguagem, eu creio que seja o primeiro do fórum, eu vi que o Zipter, fez um em um pedido, porém ele não funciona da mesma forma que este.

 

 

Então vamos começar...

 

 

 

 

 

Primeiramente Execute este código na sua database:

 

 


ALTER TABLE  `accounts` ADD  `language` INT( 11 ) NOT NULL DEFAULT  '0'

 

 Agora em data/lib/050-function.lua no final do arquivo adicione este código:

 

 


function getPlayerLanguage(cid) -- By Acubens

    local Lang = db.getResult("SELECT `language` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")

    if Lang:getID() ~= LUA_ERROR then

        local langid = Lang:getDataInt("language")

        Lang:free()

        return langid

    end

    return LUA_ERROR

end

 

function doPlayerSetLanguage(cid, new) -- By Drazyn1291

local acc = getPlayerAccountId(cid)

if new == 2 then

db.executeQuery("UPDATE `accounts` SET language = 2 WHERE `id` = " .. acc)

elseif new == 1 then

db.executeQuery("UPDATE `accounts` SET language = 1 WHERE `id` = " .. acc)

else

db.executeQuery("UPDATE `accounts` SET language = 0 WHERE `id` = " .. acc)

end

end

 

Agora em Agora em lib/000-constant.lua Adicione isso no final do arquivo:

 

 


ENGLISH = 0

SPANISH = 1

PORTUGUES = 2

 

Você pode criar suas linguagem com os ID's acima!

 

 

 

 

 

Funções:

 

 


getPlayerLanguage(cid) -- By Acubens

doPlayerSetLanguage(cid, new) -- By Drazyn1291

 

Creio que só de ler a função já saibam oque faz né?? 

 

 

 

 

 

Exemplo:

 

 


function onLogin(cid) -- By Drazyn

local msg = {

[PORTUGUES] = {"Bem-Vindo!"},

[sPANISH] = {"Bienvenida"},

[ENGLISH] = {"Welcome!"}

}

 

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, msg[getPlayerLanguage(cid)][1])

return true

end

 

Testado no Tfs 0.4

 

 

 

 

 

Créditos:

 

 


Acubens -- Por Criar o sistema

Drazyn1291 -- Por criar a função doPlayerSetLanguage(cid, new) e pelo Exemplo!

 

Editado por Drazyn
Link para o comentário
https://xtibia.com/forum/topic/238987-multi-language-system/
Compartilhar em outros sites

  • 7 months later...
  • 2 months later...
2 horas atrás, daniofordon disse:

Hello:) or gave you the trick is to convert the TFS 1.3?

Everything what you do on TFS 1.2, this will work on TFS 1.3

 

But i don't have time to convert for my self and post it. My time is limited and i am giving her on my server.

 

 

Link para o comentário
https://xtibia.com/forum/topic/238987-multi-language-system/#findComment-1718405
Compartilhar em outros sites

×
×
  • Criar Novo...