Multi Language System

Luga03
Por Luga03
em Mods, funções e outros

Luga03

Gabriel Lucena :D
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/04/15Posts: 956Gênero: Masculino

 

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!

 

Hello! How are you? It's fine? 

 

Okay, so you like my helps? if yes, then do you can like my post, give-me a reputation, you can't?

 

Good morning for everyone! And have a good day!

daniofordon

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/09/15Posts: 7

on for tfs 1.2?

Luga03

Gabriel Lucena :D
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/04/15Posts: 956Gênero: Masculino
20 horas atrás, daniofordon disse:

on for tfs 1.2?

Will be need only some edits to work on TFS 1.2

Hello! How are you? It's fine? 

 

Okay, so you like my helps? if yes, then do you can like my post, give-me a reputation, you can't?

 

Good morning for everyone! And have a good day!

daniofordon

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/09/15Posts: 7
Em 12.04.2017 at 21:48, Drazyn disse:

Will be need only some edits to work on TFS 1.2

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

Luga03

Gabriel Lucena :D
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/04/15Posts: 956Gênero: Masculino
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.

 

 

Hello! How are you? It's fine? 

 

Okay, so you like my helps? if yes, then do you can like my post, give-me a reputation, you can't?

 

Good morning for everyone! And have a good day!