Requiem Posted April 8, 2016 at 07:07 PM Share Posted April 8, 2016 at 07:07 PM Desde que o MetinLife fechou (um famoso servidor português que tenho imensas saudades de jogar) era possível escolher qual a nossa língua e a partir daí todas as missões seriam nessa Língua. Aqui apenas tem duas Línguas, Inglês e Turco, mas é fácil adaptar a novas línguas que queiram inserir. FAÇAM BACKUP DOS VOSSOS FICHEIROS ANTES DE TENTAREM ISTO.... Passo 1 Abram o questlua_pc.cpp e adicionem: int pc_get_lang(lua_State* L) { char szQuery[QUERY_MAX_LEN]; LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); snprintf(szQuery,sizeof(szQuery),"select lang from player%s where id = '%u'",get_table_postfix(),ch->GetPlayerID()); SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery); MYSQL_ROW row; for(int i = 0; (row = mysql_fetch_row(pMsg->Get()->pSQLResult)) != NULL; ++i) { lua_pushstring(L,row[0]); } return 1; } int pc_set_lang(lua_State* L) { char szQuery[QUERY_MAX_LEN]; if(!lua_isstring(L,1)) { return 0; } LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); snprintf(szQuery,sizeof(szQuery),"update player%s set lang = '%s' where id = '%u'",get_table_postfix(),lua_tostring(L,1),ch->GetPlayerID()); std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(szQuery)); if(pmsg->Get()->uiInsertID == 0) { return 0; } return 1; } Adicionem ainda: { "get_lang", pc_get_lang}, { "set_lang", pc_set_lang}, Passo 2 Player.SQL (Penso que seja adicionar no Mysql) CREATE TABLE `new_NewTable` ( `id` int(11) NOT NULL AUTO_INCREMENT , `account_id` int(11) NOT NULL DEFAULT 0 , `name` varchar(24) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'NONAME' , `job` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 , `voice` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 , `dir` tinyint(2) NOT NULL DEFAULT 0 , `x` int(11) NOT NULL DEFAULT 0 , `y` int(11) NOT NULL DEFAULT 0 , `z` int(11) NOT NULL DEFAULT 0 , `map_index` int(11) NOT NULL DEFAULT 0 , `exit_x` int(11) NOT NULL DEFAULT 0 , `exit_y` int(11) NOT NULL DEFAULT 0 , `exit_map_index` int(11) NOT NULL DEFAULT 0 , `hp` smallint(4) NOT NULL DEFAULT 0 , `mp` smallint(4) NOT NULL DEFAULT 0 , `stamina` smallint(6) NOT NULL DEFAULT 0 , `random_hp` smallint(5) UNSIGNED NOT NULL DEFAULT 0 , `random_sp` smallint(5) UNSIGNED NOT NULL DEFAULT 0 , `playtime` int(11) NOT NULL DEFAULT 0 , `level` tinyint(2) UNSIGNED NOT NULL DEFAULT 1 , `level_step` tinyint(1) NOT NULL DEFAULT 0 , `st` smallint(3) NOT NULL DEFAULT 0 , `ht` smallint(3) NOT NULL DEFAULT 0 , `dx` smallint(3) NOT NULL DEFAULT 0 , `iq` smallint(3) NOT NULL DEFAULT 0 , `exp` int(11) NOT NULL DEFAULT 0 , `gold` int(11) NOT NULL DEFAULT 0 , `stat_point` smallint(3) NOT NULL DEFAULT 0 , `skill_point` smallint(3) NOT NULL DEFAULT 0 , `quickslot` tinyblob NULL , `ip` varchar(15) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0.0.0.0' , `part_main` int(7) NOT NULL DEFAULT 0 , `part_base` tinyint(4) NOT NULL DEFAULT 0 , `part_hair` smallint(4) NOT NULL DEFAULT 0 , `skill_group` tinyint(4) NOT NULL DEFAULT 0 , `skill_level` blob NULL , `alignment` int(11) NOT NULL DEFAULT 0 , `last_play` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' , `change_name` tinyint(1) NOT NULL DEFAULT 0 , `mobile` varchar(24) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL , `sub_skill_point` smallint(3) NOT NULL DEFAULT 0 , `stat_reset_count` tinyint(4) NOT NULL DEFAULT 0 , `horse_hp` smallint(4) NOT NULL DEFAULT 0 , `horse_stamina` smallint(4) NOT NULL DEFAULT 0 , `horse_level` tinyint(2) UNSIGNED NOT NULL DEFAULT 0 , `horse_hp_droptime` int(10) UNSIGNED NOT NULL DEFAULT 0 , `horse_riding` tinyint(1) NOT NULL DEFAULT 0 , `horse_skill_point` smallint(3) NOT NULL DEFAULT 0 , `lang` varchar(5) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL , PRIMARY KEY (`id`), INDEX `account_id_idx` USING BTREE (`account_id`), INDEX `name_idx` USING BTREE (`name`) ) ENGINE=MyISAM DEFAULT CHARACTER SET=latin1 COLLATE=latin1_swedish_ci AUTO_INCREMENT=321434631 CHECKSUM=0 ROW_FORMAT=DYNAMIC DELAY_KEY_WRITE=0 ; Passo 3 Para usar no Jogo em si (apenas um exemplo): quest mLanguage begin state start begin function load_setting() local data = { ["extension"] = {"tr","en"}, ["en"] = { ["letter"] = "Change Language" ["language"] = {"Turkish","English","Close"}, ["dialog"] = {"Please select a language... ", "No longer your language is %s. "}, }, ["tr"] = { ["letter"] = "Dilini Değiştir", ["language"] = {"Türkçe","Ingilizce","Kapat"}, ["dialog"] = {"Lütfen bir dil seçiniz.. ","Artık diliniz %s oldu. "}, }, } return data end when letter begin if(pc.get_lang() == 0) then send_letter("Select language") else send_letter(mLanguage.load_setting()[pc.get_lang()]["letter"]) end end when button or info begin local data = mLanguage.load_setting() if(pc.get_lang() != 0) then say(data[pc.get_lang()]["dialog"][1]) say("") local s = select_table(data[pc.get_lang()]["language"]) if(s >= table.getn(data[pc.get_lang()]["language"])) then return else pc.set_lang(data["extension"]) say(string.format(data[pc.get_lang()]["dialog"][2],data[pc.get_lang()]["language"])) end else say(data["en"]["dialog"][1]) say("") local s = select_table(data["en"]["language"]) if(s >= table.getn(data["en"]["language"])) then return else pc.set_lang(data["extension"]) say(string.format(data[pc.get_lang()]["dialog"][2],data[pc.get_lang()]["language"])) end end end end end CRÉDITOS: AvelineTM Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now