Multi-Language Quest

Avatar utilizator
[Tupeu]
Membru de Elita

Membru de Elita
Mesaje: 4101
Membru din: 28 Oct 2015, 16:16
Aprecieri: 35  
Mulţumiri: 2304  
 Contact:
Medalii

Pasul 1:

- Deschideti questlua_pc.cpp si adaugati asta:

Cod: Selectaţi tot

	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;
	}
- Si asta:

Cod: Selectaţi tot

			{ "get_lang", pc_get_lang},
			{ "set_lang", pc_set_lang},
Pasul 2:

- Player.sql

Cod: Selectaţi tot

CREATE TABLE `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
;
Sau creati voi coloana lang in tabelul player.

Pasul 3:

- Cu il utilizati in joc?



Exemplu de quest:

Cod: Selectaţi tot

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"][s])
					say(string.format(data[pc.get_lang()]["dialog"][2],data[pc.get_lang()]["language"][s]))
				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"][s])
					say(string.format(data[pc.get_lang()]["dialog"][2],data[pc.get_lang()]["language"][s]))
				end
			end
		end
	end
end
Sistemul are limba engleza si turca momentan.

Mult succes.
Sursa| Afiseaza codul
metin2dev
Avatar utilizator
Knuckles
Fost Moderator

Fost Moderator
Mesaje: 805
Membru din: 13 Mai 2016, 15:13
Aprecieri: 218  
Mulţumiri: 902  
Medalii

Dacă intru pe joc și aleg in turcă de exemplu , o să am toate questurile în turcă ? sau cum..
RETRAS DEFINITIV
Afișează semnătura
Avatar utilizator
Dragos9091
Nivel 3

Nivel 3
Mesaje: 303
Membru din: 02 Dec 2013, 19:03
Regat: Chunjo
Aprecieri: 6  
Mulţumiri: 7  
 Contact:
Medalii

Insfarsit , multumesc ca ai postat :)

Eroare 1 : http://prntscr.com/e2re8x

Intrebare : Cum adaug coloana ? ca daca creez alt player .. o sa imi lipseasca 2 coloane
No stress , No problem
RESPECTA SI VEI FI RESPECTAT!
Afișează semnătura
Avatar utilizator
★Cristi★
Nivel 1

Nivel 1
Mesaje: 126
Membru din: 19 Aug 2014, 11:33
Server: În căutare.
Regat: Shinsoo
Aprecieri: 18  
Mulţumiri: 52  
 Contact:
Medalii

Eu unul tot pentru sistem aș opta.

[ Postat de pe Android ] Imagine
Pentru acest mesaj, ★Cristi★ for the post:
Mihawk
NO SIGMATURE
Afișează semnătura
Avatar utilizator
vasile1995
Nivel 1

Nivel 1
Mesaje: 64
Membru din: 14 Aug 2017, 10:11
Server: metin2sunox
Regat: Chunjo
Aprecieri: 5  
Mulţumiri: 2  
Medalii

Salut bos te rog spunemi unde mai exact questlua...?
In server sau client....pt ca nu gasesc acel quest :-\
Avatar utilizator
florinenache
Nivel 2

Nivel 2
Mesaje: 255
Membru din: 25 Noi 2017, 14:00
Server: Wold 4 In Curand
Regat: Jinno
Aprecieri: 35  
Mulţumiri: 229  
 Contact:
Medalii

vasile1995 scrie:Salut bos te rog spunemi unde mai exact questlua...?
In server sau client....pt ca nu gasesc acel quest :-\


boss questlua_pc.cpp se gaseste in cd /usr/src/sursa/game
asta consta ca trebuie sa ai sursa la server.

Cod: Selectaţi tot

General
https://visual-basic.online
Afișează semnătura
Răspunde
Răspunsuri
9
Vizualizări
542
Răspunsuri
7
Vizualizări
1123
Răspunsuri
2
Vizualizări
334
Răspunsuri
12
Vizualizări
1463

Înapoi la “Quest-uri”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 4 vizitatori