[npc] Sistema De Casamento 8.50

delton
Por delton
em NPCs, monsters e raids

delton

Ex-Xtibian
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 16/11/07Posts: 389Gênero: MasculinoChar no Tibia: Tiger Darm

Bom, Godely criou o sistema de casamento para o TFS, mas é um pouco antigo, porém foi adaptado para Tibia 8.50 :positive:

 

Adicione isso no function.lua

 

 function getPlayerMarriage(player)
local rows = db.getResult("SELECT `marriage` FROM `players` WHERE `id` = " .. player .. ";")
local marry = rows:getDataInt("marriage")
if marry ~= 0 then
	return marry
else
	return FALSE
end
end

function addMarryStatus(player,partner)
db.executeQuery("UPDATE `players` SET `marrystatus` = " .. partner .. " WHERE `id` = " .. player .. ";")
return TRUE
end

function doCancelMarryStatus(player)
db.executeQuery("UPDATE `players` SET `marrystatus` = 0 WHERE `id` = " .. player .. ";")
return TRUE
end

function getMarryStatus(player)
local stat = db.getResult("SELECT `id` FROM `players` WHERE `marrystatus` = " .. player .. ";")
if(stat:getID() == -1) then
	return FALSE
else
	local info = stat:getDataInt("id")
	return info
end
end

function getOwnMarryStatus(player)
local stat = db.getResult("SELECT `marrystatus` FROM `players` WHERE `id` = " .. player .. ";")
if(stat:getID() == -1) then
	return FALSE
else
	local info = stat:getDataInt("marrystatus")
	return info
end
end

function isOnline(player)
local rows = db.getResult("SELECT `online` FROM `players` WHERE `id` = " .. player .. ";")
local on = rows:getDataInt("online")
if on ~= 0 then
	return TRUE
else
	return FALSE
end
end

 

Agora vá para data/npc e crie um arquivo chamado: Priest.lua, e adicione isso:

 

 <?xml version="1.0"?>
<npc name="Priest" script="data/npc/scripts/weedding.lua" access="3" lookdir="2">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="57" head="20" body="30" legs="40" feet="50"/>
</npc>

 

Agora vá para data/npc/scripts e crie um arquivo chamado: wedding.lua e adicione:

 

 local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, 'marry') or msgcontains(msg, 'marriage') then
	if getPlayerStorageValue(cid,3066) == -1 then
		selfSay('Would you like to get married?', cid)
		talkState[talkUser] = 1
	elseif getPlayerStorageValue(cid,3066) == 1 then
		local fid = getPlayerGUID(cid)
		local marrystatus = getOwnMarryStatus(fid)
		if marrystatus ~= 0 then
			local newpartner = getPlayerNameByGUID(marrystatus)
			selfSay('You already set a wedding date with {' .. newpartner .. '}, now I must talk to your partner. Do you want to {cancel} it?', cid)
			talkState[talkUser] = 5
		else
			setPlayerStorageValue(cid,3066,-1)
			selfSay('Would you like to get married?', cid)
			talkState[talkUser] = 1
		end
	elseif getPlayerStorageValue(cid,3066) == 2 then
		selfSay('You are already married. If you want to {divorce}, just say it.', cid)
		talkState[talkUser] = 0
	end

elseif msgcontains(msg, 'divorce') then
	if getPlayerStorageValue(cid,3066) == 2 then
		selfSay('Would you like to divorce of your partner?', cid)
		talkState[talkUser] = 6
	else
		selfSay('You are not married. If you want to get married, just say {marry}.', cid)
		talkState[talkUser] = 0
	end
end

if talkState[talkUser] == 1 then
	if msgcontains(msg, 'yes') then
		local fid = getPlayerGUID(cid)
		local marrystatus = getMarryStatus(fid)
		if marrystatus == FALSE then
			selfSay('And what\'s the name of your future partner?', cid)
			talkState[talkUser] = 2
		else
			local marryname = getPlayerNameByGUID(marrystatus)
			selfSay('{' .. marryname .. '} has set a wedding date with you. Do you want to {proceed} or {cancel} the wedding?', cid)
			talkState[talkUser] = 4
		end
	end

elseif talkState[talkUser] == 2 then
	local p = msg
	local player = getPlayerName(cid)
	local fid = getPlayerGUID(cid)
	local sid = getPlayerGUIDByName(p)
	if sid == 0 then
		selfSay('A player with that name does not exists.', cid)
		talkState[talkUser] = 0
	elseif sid == fid then
		selfSay('Don\'t worry, you will always be married with yourself, kid.', cid)
		talkState[talkUser] = 0
	else
		local marrystatus = getMarryStatus(fid)
		local pmarriage = getPlayerMarriage(sid)
		local ownstatus = getOwnMarryStatus(cid)
		if pmarriage == FALSE then
			if marrystatus == FALSE then
				if ownstatus == FALSE then
					setPlayerStorageValue(cid,3066,1)
					addMarryStatus(fid,sid)
					selfSay('You\'ve just set a wedding date with {' .. p .. '}.', cid)
					talkState[talkUser] = 0
				else
					local partnername = getPlayerNameByGUID(ownstatus)
					selfSay('{' .. p .. '} has already set a wedding date with {' .. partnername .. '}.', cid)
					talkState[talkUser] = 0
				end
			else
				local marryname = getPlayerNameByGUID(marrystatus)
				selfSay('{' .. marryname .. '} has set a wedding date with you. Do you want to {proceed} or {cancel} the wedding?', cid)
				talkState[talkUser] = 4
			end
		else
			local pname = getPlayerNameByGUID(pmarriage)
			selfSay('Sorry, but {' .. p .. '} is already married to {' .. pname .. '}.', cid)
			talkState[talkUser] = 0
		end
	end

elseif talkState[talkUser] == 4 then
	if msgcontains(msg, 'proceed') then
		local fid = getPlayerGUID(cid)
		local sid = getMarryStatus(fid)
		local marryname = getPlayerNameByGUID(sid)
		local pid = getPlayerByNameWildcard(marryname)
		if isOnline(fid) == TRUE and isOnline(sid) == TRUE then
			local tmf = getCreaturePosition(cid)
			local	tms = getCreaturePosition(pid)
			local text = {'I love you!','My love!','Baby dear!'}
			local chance1 = math.random(1,table.getn(text))
			local chance2 = math.random(1,table.getn(text))
			if getDistanceBetween(tmf, tms) <= 3 then
				setPlayerStorageValue(cid,3066,2)
				setPlayerStorageValue(pid,3066,2)
				doCancelMarryStatus(fid)
				doCancelMarryStatus(sid)
				setPlayerPartner(cid,sid)
				setPlayerPartner(pid,fid)
				doCreatureSay(cid, text[chance1], TALKTYPE_ORANGE_1)
				doCreatureSay(pid, text[chance2], TALKTYPE_ORANGE_1)
				doSendMagicEffect(tmf, 35)
				doSendMagicEffect(tms, 35)
				selfSay('Congratulations! Now you may kiss your partner! Everytime you wanna make this effect, just say {love}. You must be close to your partner.', cid)
				talkState[talkUser] = 0
			else
				selfSay('Your partner must be close to you so you can marry!', cid)
				talkState[talkUser] = 0
			end
		else
			selfSay('You and your new partner must be online at the same time.', cid)
			talkState[talkUser] = 0
		end

	elseif msgcontains(msg, 'cancel') then
		local fid = getPlayerGUID(cid)
		local sid = getMarryStatus(fid)
		local marryname = getPlayerNameByGUID(sid)
		local pid = getPlayerByNameWildcard(marryname)
		if isOnline(sid) == TRUE then
			setPlayerStorageValue(pid,3066,-1)
		end
		doCancelMarryStatus(sid)
		selfSay('You just canceled your wedding date with {' .. marryname .. '}.', cid)
		talkState[talkUser] = 0
	end

elseif talkState[talkUser] == 5 then
	if msgcontains(msg, 'cancel') or msgcontains(msg, 'yes') then
		local fid = getPlayerGUID(cid)
		setPlayerStorageValue(cid,3066,-1)
		doCancelMarryStatus(fid)
		talkState[talkUser] = 0
	end

elseif talkState[talkUser] == 6 then
	if msgcontains(msg, 'yes') then
		local fid = getPlayerGUID(cid)
		local sid = getPlayerPartner(cid)
		local marryname = getPlayerNameByGUID(sid)
		local pid = getPlayerByNameWildcard(marryname)
		if (isOnline(fid) == TRUE and isOnline(sid) == TRUE) then
			setPlayerStorageValue(cid,3066,-1)
			setPlayerStorageValue(pid,3066,-1)
			setPlayerPartner(cid,0)
			setPlayerPartner(pid,0)
			selfSay('You\'ve just divorced of your old partner.', cid)
			talkState[talkUser] = 0
		else
			selfSay('You and your new partner must be online at the same time.', cid)
			talkState[talkUser] = 0
		end
	end
end
return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Agora, adicione para seu MySQL database o que está escrito abaixo:

 

 ALTER TABLE `players` ADD `marrystatus` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `marriage`;

 

Em data/talkactions/talkactions.xml adicione:

 

 <talkaction words="love" script="love.lua"/>

 

Em data/talkactions/scripts crie um arquivo chamado love.lua e adicione:

 

 function onSay(cid, words, param)
-- Exhausted Settings --
local exhausted_seconds = 1 -- How many seconds player will be exhausted --
local exhausted_storagevalue = 9847 -- Storage Value to store exhaust. It MUST be unused! --
-- Exhausted Settings END --


local text = {'I love you!','My love!','Baby dear!'}
local chance1 = math.random(1,table.getn(text))
local chance2 = math.random(1,table.getn(text))
local sid = getPlayerPartner(cid)
if sid > 0 then
	if isOnline(sid) == TRUE then
		local sname = getPlayerNameByGUID(sid)
		local pid = getPlayerByNameWildcard(sname)
		local tmf = getCreaturePosition(cid)
		local	tms = getCreaturePosition(pid)
		if getDistanceBetween(tmf, tms) <= 3 then
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
			doCreatureSay(cid, text[chance1], TALKTYPE_ORANGE_1)
			doCreatureSay(pid, text[chance2], TALKTYPE_ORANGE_1)
			doSendMagicEffect(tmf, 35)
			doSendMagicEffect(tms, 35)
else
doPlayerSendCancel(cid, "You are exhausted.")
			return TRUE
		end
	end
end
end
end

 

Foi adicionado exhaust para que os chars não façam SPAM, e dê lag no server.

 

Pronto!

 

Como funciona?

 

PLAYER1 Vai para o NPC e começa a conversa...
PLAYER1: Hi
PLAYER1: marry
PLAYER1: yes
PLAYER1: Nome do player 2 para adicionar "status de casado", e o player 2 começa a conversa....
PLAYER2: Hi
PLAYER2: marry
PLAYER2: yes
PLAYER2: proceed

 

Você pode se divorciar caso o "fogo da paixão" acabe xD

 

Script funciona com gesior acc maker (Apenas mostra se o char está casado ou não)

 

Todos os créditos para Godely.

 

Coments :party:

Olá XTibiano:

Sua assinatura estava com um problema na TAG SPOILER e foi movida para a parte "Sobre mim".
Agradecemos a sua compreensão.

Atenciosamente,
JV Chequer

makabrotaliban

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 08/01/09Posts: 331Char no Tibia: Orcshaball

Excelente o script, funfa perfeitamente!

Porém uma dúvida, o sistema troca a outfit dpois de casados? e o ring de pós married é criado após o casamento ou não está adicionado ao script?

 

Grato pelo post!

 

SEM MAIS

- Xtibia.com seu site de Tibia e OTServer ! -

delton

Ex-Xtibian
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 16/11/07Posts: 389Gênero: MasculinoChar no Tibia: Tiger Darm

Como eu disse no início do tópico o script é antigo, porém adaptado para 8.50 =))

 

 

Delton~~

Olá XTibiano:

Sua assinatura estava com um problema na TAG SPOILER e foi movida para a parte "Sobre mim".
Agradecemos a sua compreensão.

Atenciosamente,
JV Chequer

GoDTrinity

Psy Rapper
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 15/12/08Posts: 14

Funfa certinho...Vlw ! Gostei ;p

By Psy Victor ! ;)

drigao13

Zoropa Ot server
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 30/09/07Posts: 1Char no Tibia: Rhyrus Tera

eu usei o seu script aki no meu ot porem quando o player vai la e fala 1 fala

 

hi

marry

 

na parte do yes quando ele fala n acontece nada sera que no seu script n ta faltando a parte do sim?

godviollator

Admin at Draferia Online
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 11/07/07Posts: 50Gênero: MasculinoChar no Tibia: Drafenous

Onde está esse function ?

E como adiciona o status no site/mysql ?

Draferia Online:

http://draferia.com.br

draferia-468x60.jpg

brunomera

avatar
Banidos
Banidos

INFOS

Grupo: BanidosRegistrado: 07/02/08Posts: 25Char no Tibia: Volis Xedria

Meu tambem dá o mesmo erro do Drigao

 

 

ele para ' yes '

 

e depois nao fala mais nada :surprised:

4907567.png

 

 

Sou Fãn de:

 

ubd8101of9vd0bp5.jpg

ubda2166ew9sf8.gif

dgprado

GOLIMAR!!!
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 06/07/08Posts: 206Char no Tibia: Nao Jogo tibia

[08/08/2009 21:25:59] Lua Script Error: [Npc interface] 
[08/08/2009 21:25:59] data/npc/scripts/casamento.lua:onCreatureSay

[08/08/2009 21:25:59] luaGetPlayerNameByGUID(). Player not found

[08/08/2009 21:25:59] Lua Script Error: [Npc interface] 
[08/08/2009 21:25:59] data/npc/scripts/casamento.lua:onCreatureSay

[08/08/2009 21:25:59] data/npc/scripts/casamento.lua:58: attempt to concatenate local 'marryname' (a nil value)
[08/08/2009 21:25:59] stack traceback:
[08/08/2009 21:25:59] 	data/npc/scripts/casamento.lua:58: in function 'callback'
[08/08/2009 21:25:59] 	data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[08/08/2009 21:25:59] 	data/npc/scripts/casamento.lua:8: in function <data/npc/scripts/casamento.lua:8>

 

Alguem sabe o que esta errado ae ?

Best Server

 

Servidor resetado após 4 anos sem reset!!!
10.1 muitas quests, war system global, quests exclusivas, monstros exclusivos, sempre online 24h por dia 7 dias por semana, estabilidade absoluta, draken tower e muito mais.

Todas as novas áreas 9.81, criaturas , items, montaria, outfit.

Npc Otokkar, Broken Servant Sentry, Mad Mages, Golden, Iron e Diamond Servants, invasao de Feverish citzen, outfits e addons novos, sistema que enche a vida e mana toda quando upa lv, valor colorido de quanto vc regenerou e mmmuiiito mais.

Bestserver aqui você sempre encontra as últimas novidades do Open Tibia.

Montros, items, outfits e mounts 10.1

Magias 8.7, montarias funcionando exatamente como no global, todos os novos monstros, items de domar adocionados aos loots dos monstros, raids dos novos monstros para domar, cooldowns 100% com exausteds reconfigurados de modo a não tirar a jogabilidade, em fim praticamente 100% das features do global.

yohanaugusto

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 18/03/08Posts: 10Char no Tibia: Manfz

MEU DEU O MESMO ERRO DE CIMA /\

 

COMO ARRUMA?

dgprado

GOLIMAR!!!
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 06/07/08Posts: 206Char no Tibia: Nao Jogo tibia

Agora consegui ir ate a parte q fala o nome da noiva mas quando eu axei q daria certo fui surpreendido por este erro ;/

 

[19/08/2009 01:20:59] Lua Script Error: [Npc interface] 
[19/08/2009 01:20:59] data/npc/scripts/casamento.lua:onCreatureSay

[19/08/2009 01:20:59] luaGetPlayerNameByGUID(). Player not found

[19/08/2009 01:20:59] Lua Script Error: [Npc interface] 
[19/08/2009 01:20:59] data/npc/scripts/casamento.lua:onCreatureSay

[19/08/2009 01:20:59] data/npc/scripts/casamento.lua:87: attempt to concatenate local 'partnername' (a nil value)
[19/08/2009 01:20:59] stack traceback:
[19/08/2009 01:20:59] 	data/npc/scripts/casamento.lua:87: in function 'callback'
[19/08/2009 01:20:59] 	data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[19/08/2009 01:20:59] 	data/npc/scripts/casamento.lua:8: in function <data/npc/scripts/casamento.lua:8>

[19/08/2009 01:22:18] Lua Script Error: [Npc interface] 
[19/08/2009 01:22:18] data/npc/scripts/casamento.lua:onCreatureSay

[19/08/2009 01:22:18] data/lib/function.lua:465: attempt to concatenate local 'player' (a nil value)
[19/08/2009 01:22:18] stack traceback:
[19/08/2009 01:22:18] 	data/lib/function.lua:465: in function 'getPlayerMarriage'
[19/08/2009 01:22:18] 	data/npc/scripts/casamento.lua:76: in function 'callback'
[19/08/2009 01:22:18] 	data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[19/08/2009 01:22:18] 	data/npc/scripts/casamento.lua:8: in function <data/npc/scripts/casamento.lua:8>

Fiz tudo q c falo delton tabela, npc, talkaction , mas n fumfo,e obviamante se fumfasse 100% c tinha posto o npc no thyrania, mas e isso uma hora ele fumfa xD thx.

 

 

Olha Denton tenho maior respeito por vc, em primeiro lugar por eu ser gaucho como vc,ou por vc ser gaucho como eu ja q tenho 28 anos =p, mas em fim isso n importa, em segundo por vc se dedicar para um projeto amplo e complexo como o thyrania, mas sinceramente se for pra abandonar os topicos como voce tem feito, seria mais responsavel e humano colar o link do otland. Compreendo que teoricamente, eu disse teoricamente ning tem o direito de te cobrar nada ja q vc esta trazendo uma info, com os devidos creditos, mas por outro lado e meio estranho voce trazer com tamanha magnitude uma info que eu testei de todas as formas possiveis, inclusive na sua plataforma (que ja n uso mais).Seria ate um tanto obvio ja que seu thyrania tem as funçoes, npc, que tivessee este recurso implantado no mapa, porem n tem.Dae vem meu menisfesto, estou aki me sentindo um primata, no seu topico, e claro o minimo q eu espero e q vc tenha testado isso, e simplismente n consigo fazer essa joça fumfar, serei eu um ignorante, ja que ninguem se presta a compartilhar experiencia alguma comigo ou sera voce precipitado de postar algo q voce n tenha 100% de conhecimento, nao digo nem 100% de conhecimento, mas pelo menos testado ou se nao assumir alguma responsa por ter trazido a info ao xtibia e me dar algum tipo de retorno, por mais humeilde q seja, como por exemplo , n sei cara!!!

Best Server

 

Servidor resetado após 4 anos sem reset!!!
10.1 muitas quests, war system global, quests exclusivas, monstros exclusivos, sempre online 24h por dia 7 dias por semana, estabilidade absoluta, draken tower e muito mais.

Todas as novas áreas 9.81, criaturas , items, montaria, outfit.

Npc Otokkar, Broken Servant Sentry, Mad Mages, Golden, Iron e Diamond Servants, invasao de Feverish citzen, outfits e addons novos, sistema que enche a vida e mana toda quando upa lv, valor colorido de quanto vc regenerou e mmmuiiito mais.

Bestserver aqui você sempre encontra as últimas novidades do Open Tibia.

Montros, items, outfits e mounts 10.1

Magias 8.7, montarias funcionando exatamente como no global, todos os novos monstros, items de domar adocionados aos loots dos monstros, raids dos novos monstros para domar, cooldowns 100% com exausteds reconfigurados de modo a não tirar a jogabilidade, em fim praticamente 100% das features do global.

leleos

::.Voltei.::
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/01/08Posts: 41Char no Tibia: Gripi Suina

Aqui funfo de boa quanto no TFS 3.4 quanto no 3.5, ah e funfo tambem no thyranic 8.5 que o delton posto na sesçao de download.

 

Por mim o script ta aprovado!

 

Att, Leleo

HolyMaN

HolyMaN
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 23/05/07Posts: 207Gênero: Masculino

@delton

po tem como me ajudar a transformar esse codigo em sqlite?

ta em mysql...

ALTER TABLE `players` ADD `marrystatus` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `marriage`;

Dobol

MATHEUSP.COM.BR
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 18/10/09Posts: 246Gênero: MasculinoChar no Tibia: Aran Than

Onde tem que adicionar esse

ALTER TABLE `players` ADD `marrystatus` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `marriage`;

 

Eu sei que é no MySQL, mais explica melhor ai.

 

Aqui eu flao Yes, depois ele não fala mais nada.

Antigo TheSleeper (Mapper) voltando para a área de jogos como Dobol ;)

Meus Trabalhos
• Annihilator Full Global
Talkaction - !aol
 

MaxxJuba

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/12/07Posts: 60Char no Tibia: Supremo Black

Nem adianta pedir ajuda galera..

O delton nos abandonou...

;/

Não precisa me dar +Rep, se eu te ajudo, com certeza não é pra ganhar nada em troca..



 

69.gif

70.gif

 

xdun9d.gif

 

Entrem e se divirtam, soulflix o melhor server global

;)