• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Marriage System 0.3.6

TheMaX

New Member
Joined
Apr 28, 2010
Messages
114
Reaction score
2
Someone have the scripts for Marriage System for TFS 0.3.6?
I'm needing all the scripts...
The NPC, Outfit Boxes, Wedding Rings, Name Description, etc...

Thanks.
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, Partner = {}, {}

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 say(msg, cid)
	local npc, _msg = getNpcId(), msg:gsub('{', ''):gsub('}', '')
	local pos = getThingPos(npc)
	for _, tid in ipairs(getSpectators(pos, 7, 5, false) or {}) do
		if isPlayer(tid) then
			doCreatureSay(npc, tid ~= cid and _msg or msg, tid == cid and TALKTYPE_PRIVATE_NP or TALKTYPE_SAY, false, tid, pos)
		end
	end
end

local function marry(cid, msg, ext)
	msg = msg:gsub('my heart belongs to ', '')
	local player = getPlayerByName(msg)
	if player then
		if player ~= cid then
			if getPlayerPartner(player) == 0 then
				if getPlayerStorageValue(cid, 46000) == 1 then
					if getPlayerStorageValue(player, 46001) == getPlayerGUID(cid) then
						doCreatureSay(cid, msg, TALKTYPE_SAY)
						say('By the powers of the Gods your souls are now bound together for eternity. As a symbol of your love, receive your engraved wedding rings and festive clothes. ...', cid)
						say('May the Gods watch with grace over your future life as a married couple. Go now and celebrate your honeymoon on the peaceful island of Meluna!', cid)
						for _, pid in ipairs({cid, player}) do
							doPlayerAddOutfitId(pid, 34, 0)
							local v = getCreatureOutfit(pid)
							v.lookType = getPlayerSex(pid) == 0 and 329 or 328
							doCreatureChangeOutfit(pid, v)
							doSendMagicEffect(getThingPos(pid), CONST_ME_HEARTS)
							setPlayerStorageValue(pid, 46002, os.time() + 86400)
						end
						doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
						local nc, np = getCreatureName(cid), getCreatureName(player)
						doItemSetAttribute(doPlayerAddItem(cid, 10502, 1), 'description', np .. ' & ' .. nc .. ' forever - married on ' .. os.date('%b ' .. os.date('*t').day .. ', %Y') .. '.')
						doItemSetAttribute(doPlayerAddItem(player, 10502, 1), 'description', nc .. ' & ' .. np .. ' forever - married on ' .. os.date('%b ' .. os.date('*t').day .. ', %Y') .. '.')
						doPlayerSetPartner(cid, getPlayerGUID(player))
						doPlayerSetPartner(player, getPlayerGUID(cid))
						Topic[cid] = nil
						return true
					elseif ext == 1 then
						say(getCreatureName(cid) .. ', are you sure of your love to ' .. getCreatureName(player) .. ' and wish to bind your souls together for eternity?', cid)
						Topic[cid] = 5
						Partner[cid] = getPlayerGUID(player)
					end
				else
					say('Oh no! Your ring and outfit box are missing! I hope you didn\'t forget them! Can you please give them to me now?', cid)
					Topic[cid] = 8
					return true
				end
			else
				if ext then say('This person is already married to someone.', cid) end
			end
		else
			if ext then say('You cannot marry yourself.', cid) end
		end
	else
		if ext then say('This person is not online.', cid) end
	end
	if ext then doCreatureSay(cid, msg, TALKTYPE_SAY) end
end

function creatureSayCallback(cid, type, msg)
	if msgcontains(msg, 'my heart belongs to') and not npcHandler:isFocused(cid) then
		local v =  marry(cid, msg)
		if v then
			npcHandler:addFocus(cid)
			return true
		end
	elseif (msgcontains(msg, 'hello') or msgcontains(msg, 'hi')) and (not npcHandler:isFocused(cid)) then
		npcHandler:say('Welcome in the name of the Gods, pilgrim '..getCreatureName(cid)..'!', cid)
		npcHandler:addFocus(cid)
		Topic[cid] = nil
	elseif not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:say('Good bye, '..getCreatureName(cid)..'. May the Gods watch over you, my child!', cid)
		Topic[cid] = nil
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'marriage') or msgcontains(msg, 'marry') or msgcontains(msg, 'ceremony') or msgcontains(msg, 'wedding') then
		if getPlayerPartner(cid) ~= 0 then
			say('Yes, indeed, you are married, ' .. getCreatureName(cid) .. '. I hope your love is still blooming and flourishing.', cid)
			Topic[cid] = nil
		elseif getPlayerStorageValue(cid, 46000) < 1 then
			say('Before we can start the marriage ceremony, each of you need to hand me a blank wedding ring and a box with a wedding outfit. ' .. getCreatureName(cid) .. ', do you have these items with you and are you willing to give them to me now?', cid)
			Topic[cid] = 6
		else
			say('Do you wish me to initiate the marriage ceremony now?', cid)
			Topic[cid] = 1
		end
		doCreatureSay(cid, msg, TALKTYPE_SAY)
	elseif Topic[cid] == 1 then
		if msgcontains(msg, 'yes') or (msgcontains(msg, 'i') and msgcontains(msg, 'will')) then
			say('In the name of the Gods of Benevolence, I ask you, ' .. getCreatureName(cid) .. ': are both of you ready and eager to be bound in marriage?', cid)
			Topic[cid] = 2
		else
			say('Perhaps another time, marriage isn\'t a step one should consider without love in the heart.', cid)
			Topic[cid] = nil
		end
		doCreatureSay(cid, msg, TALKTYPE_SAY)
	elseif Topic[cid] == 2 then
		if msgcontains(msg, 'yes') or (msgcontains(msg, 'i') and msgcontains(msg, 'will')) then
			say('A moment of silence please... I hereby invoke the eternal powers who watch over our souls and lives. Please repeat after me: {May the gods bless us}!', cid)
			doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
			Topic[cid] = 3
		end
		doCreatureSay(cid, msg, TALKTYPE_SAY)
	elseif Topic[cid] == 3 then
		if msgcontains(msg, 'may') and msgcontains(msg, 'gods') and msgcontains(msg, 'bless') and msgcontains(msg, 'us') then
			say('I ask thee, ' .. getCreatureName(cid) .. ', what is the name of the person your {heart belongs to}?', cid)
			Topic[cid] = 4
		else
			--
		end
		doCreatureSay(cid, msg, TALKTYPE_SAY)
	elseif Topic[cid] == 4 then
		marry(cid, msg, 1)
	elseif Topic[cid] == 5 then
		if msgcontains(msg, 'yes') or (msgcontains(msg, 'i') and msgcontains(msg, 'will')) then
			say('So by the powers of the Gods, your soul is now bound to your beloved. ' .. getPlayerNameByGUID(Partner[cid]) .. ', now step forward and tell me if your heart belongs to ' .. getCreatureName(cid) .. ' too.', cid)
			setPlayerStorageValue(cid, 46001, Partner[cid])
			Topic[cid] = nil
			doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
		elseif msgcontains(msg, 'no') then
			say('Your neglection of love hurts my heart. Leave now!', cid)
			Topic[cid] = nil
			npcHandler:releaseFocus(cid)
		end
		doCreatureSay(cid, msg, TALKTYPE_SAY)
	elseif Topic[cid] == 6 then
		if msgcontains(msg, 'yes') or (msgcontains(msg, 'i') and msgcontains(msg, 'will')) then
			if getPlayerItemCount(cid, 2121) ~= 0 and doPlayerRemoveItem(cid, 10503, 1) then
				doPlayerRemoveItem(cid, 2121, 1)
				say('Thank you. I\'ll give them back to you when the time is right. Please make sure that BOTH of you have handed me your items before we start the {ceremony}.', cid)
				setPlayerStorageValue(cid, 46000, 1)
			else
				say('I\'m sorry, but you don\'t seem to have a ring and an outfit. I fear you need to visit a jeweller and the tailor in Venore.', cid)
			end
		else
			say('Hm, then not.', cid)
		end
		Topic[cid] = nil
	elseif msgcontains(msg, 'meluna') then
		if getPlayerPartner(cid) ~= 0 then
			if getPlayerSex(cid) == 1 then
				say('You can travel to Meluna with Kamil who you will find to the south of Fibula, but only on the day of your wedding.  This island is protected by the Gods. They will not allow violence there. But on your honeymoon your thoughts should be on things other than violence. ...', cid)
				say(getCreatureName(cid) .. ', just so that you won\'t have to fear an ambush on your wedding day, would you like me to bring you to the boat on Fibula, from where you can travel to Meluna?', cid)
			else
				say('You can travel to Meluna with Kamil south of Fibula, but only on the day of your wedding. This island is protected by the Gods. They will not allow violence there. ...', cid)
				say(getCreatureName(cid) .. ', since you might not want to get your new clothes dirty, would you like me to bring you to the boat on Fibula, from where you can travel to Meluna?', cid)
			end
			Topic[cid] = 7
		else
			npcHandler:say('You can travel to Meluna with Kamil south of Fibula, but only on the day of your wedding. This island is protected by the Gods. They will not allow violence there.', cid)
			Topic[cid] = nil
		end
	elseif Topic[cid] == 7 then
		if msgcontains(msg, 'yes') then
			say(getPlayerSex(cid) == 1 and 'Take care of yourselves!' or 'Enjoy yourselves!', cid)
			Topic[cid] = nil
			doSendMagicEffect(getThingPos(cid), CONST_ME_HEARTS)
			doTeleportThing(cid, {x=32154, y=32456, z=7})
			doSendMagicEffect({x=32154, y=32456, z=7}, CONST_ME_HEARTS)
		else
			say('Hm, then not.', cid)
		end
		Topic[cid] = nil
	elseif Topic[cid] == 8 then
		if msgcontains(msg, 'yes') then
			if getPlayerItemCount(cid, 2121) ~= 0 and doPlayerRemoveItem(cid, 10503, 1) then
				doPlayerRemoveItem(cid, 2121, 1)
				say('Thank you. Now let\'s continue - please tell me again whom your heart belongs to!', cid)
				setPlayerStorageValue(cid, 46000, 1)
				Topic[cid] = 9
				return true
			else
				say('I\'m sorry, but you don\'t seem to have a ring and an outfit. I fear you need to visit a jeweller and the tailor in Venore.', cid)
			end
		else
			say('Hm, then not.', cid)
		end
		Topic[cid] = nil
	elseif Topic[cid] == 9 then
		marry(cid, msg, true)
	elseif msgcontains(msg, 'ring') then
		npcHandler:say('You can buy wedding rings from many jewellers. I recommend Carina in Venore though, since the tailor in Venore also has wedding {outfits} in stock. Or - from Hanna, right here in Thais!', cid)
		Topic[cid] = nil
	elseif msgcontains(msg, 'outfit') then
		npcHandler:say('You can buy a box with your wedding outfit from the tailor Norbert in Venore.', cid)
		Topic[cid] = nil
	elseif msgcontains(msg, 'divorce') then
		npcHandler:say('Oh, what a shameful thought! Marriage is meant to be for eternity! Only the most unscrupulous or drunken priests would carry out a divorce.', cid)
		Topic[cid] = nil
	end
	return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, 'May the Gods be with you!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'May the Gods be with you!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Change this number to the outfit ID of the wedding outfit (check outfits.xml)
Code:
doPlayerAddOutfitId(pid, [B][COLOR="red"]34[/COLOR][/B], 0)
 
It's just like npc Lynda in Thais, pretty much the same yeah just without the rest of conversation.
About 0.4, I think I used it on 0.4 too and it worked fine.
 
Thank you so much.
I'll test now.

-------------------------'
Worked perfect!!
Thanks again! ^^"
 
Last edited:
Code:
elseif msgcontains(msg, 'divorce') then
		npcHandler:say('Oh, what a shameful thought! Marriage is meant to be for eternity! Only the most unscrupulous or drunken priests would carry out a divorce.', cid)

Fuck! D:
I can't divorce? haha'
Someone can do this part please? ._.


------------'
How to 'check' if the player is married or no, and if the player have a wife or a husband?
Like: "IsPlayer"
 
omg man this npc dont give this in rl ;p

? oO'

You can get a divorce in tibia global... paying 10k, or 5, I dont know...

-------'
edit, oh, its true...
another npc give the divorce to you... =D

Lynda, Thais
Player: Hi
Lynda: Welcome in the name of the Gods, pilgrim Player.
Player: Divorce
Lynda: Oh, what a shameful thought! Marriage is meant to be for eternity! Only the most unscrupulous or drunken priests would carry out a divorce.
Note: Lynda will not grant you a divorce.


Brewster, Port Hope
Player: Hi
Brewster: G...greetings <hicks>.
Player: Divorce
Brewster: <hicks> What, a divorce? Do you yearn for the joys of singledom? <hicks> I know it well, my marriage was a battleground... but less of that. Are you unhappily married?
Player: yes
Brewster: There's no justice in the world when a pretty lady like yourself is treated badly. <hicks> Not that I have a special connection to the Gods or anything <hicks> - but I can arrange your d... divorce, if that is what you wish. <hicks> Do you?
Player: yes
Brewster: Hm. You see, uh... I would do it for free, but <hicks> I could in fact use some cash. Do me a favour and 'donate' 5000 gold coins so I can buy some, uhm... bibles. Then I'll do the rest. <hicks> What do you say?
Player: yes
Brewster: No p... problem. And no turning back now! But, just to be certain, <hicks> - are you sure that you want to free yourself from the misery of being tied to the good-for-nothing person you married in a moment of madness?
Player: yes
Brewster: Ehem. <hicks> By the Gods and b... beer and blah blah blah... let this unhappy and mistaken marriage come to an end. All b... <burp> bonds be broken and so on. Thanks for the beer - I mean bible money. <hicks> Don't make the same mistake again!
Note: He will only grant you a divorce if you have 5,000 gold.

If you do not have 5,000 gold pieces Brewster will say:
Brewster: Damn, I bet <hicks> your cheating spouse took all of your money <hicks> from you. You're as poor as a church mouse. <hicks>


Haha! Someone can make this npc please?
 
I dont know how! E_E'

Well you're in luck because here in Otland we have enough scripting resources and tutorials to teach you right in to a coma.
Head over to the Tutorials > Scripting and programming section, and get on reading a couple of tutorials.

Slogan of the day!
"Give a man fish and you will feed him for a day, Teach a man how to fish and you will feed him for a lifetime."
 
[26/06/2011 23:46:20] [Error - LuaScriptInterface::loadFile] data/npc/scripts/wedding.lua:208: ')' expected near '<eof>'
[26/06/2011 23:46:20] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/wedding.lua
[26/06/2011 23:46:20] data/npc/scripts/wedding.lua:208: ')' expected near '<eof>'

help? :(
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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)
	local n
	if not npcHandler:isFocused(cid) then
		if msgcontains(msg, 'hello') or msgcontains(msg, 'hi') then
			npcHandler:say('G...greetings <hicks>.', cid)
			npcHandler:addFocus(cid)
		else
			return false
		end
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:say('Exactly! <hicks>', cid)
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'divorce') and getPlayerPartner(cid) > 0 then
		npcHandler:say('<hicks> What, a divorce? Do you yearn for the joys of singledom? <hicks> I know it well, my marriage was a battleground... but less of that. Are you unhappily married?', cid)
		n = 1
	elseif Topic[cid] == 1 and msgcontains(msg, 'yes') then
		npcHandler:say('There\'s no justice in the world when a pretty lady like yourself is treated badly. <hicks> Not that I have a special connection to the Gods or anything <hicks> - but I can arrange your d... divorce, if that is what you wish. <hicks> Do you?', cid)
		n = 2
	elseif Topic[cid] == 2 and msgcontains(msg, 'yes') then
		npcHandler:say('Hm. You see, uh... I would do it for free, but <hicks> I could in fact use some cash. Do me a favour and \'donate\' 5000 gold coins so I can buy some, uhm... bibles. Then I\'ll do the rest. <hicks> What do you say? ', cid)
		n = 3
	elseif Topic[cid] == 3 and msgcontains(msg, 'yes') then
		npcHandler:say('No p... problem. And no turning back now! But, just to be certain, <hicks> - are you sure that you want to free yourself from the misery of being tied to the good-for-nothing person you married in a moment of madness? ', cid)
		n = 4
	elseif Topic[cid] == 4 and msgcontains(msg, 'yes') then
		if doPlayerRemoveMoney(cid, 5000) then
			npcHandler:say('Ehem. <hicks> By the Gods and b... beer and blah blah blah... let this unhappy and mistaken marriage come to an end. All b... <burp> bonds be broken and so on. Thanks for the beer - I mean bible money. <hicks> Don\'t make the same mistake again!', cid)
			local partner = getPlayerPartner(cid)
			if partner ~= 0 then
				local t = {cid}
				local player = getPlayerByGUID(partner)
				if player then
					table.insert(t, player)
				else
					db.executeQuery("UPDATE `players` SET `marriage` = 0 WHERE `id` = " .. partner)
					db.executeQuery("UPDATE `player_items` SET `itemtype` = 10510 WHERE `player_id` = " .. partner .. " AND `itemtype` = 10502")
				end
				for _, pid in ipairs(t) do
					doPlayerSetPartner(pid, 0)
					local v = getCreatureOutfit(pid)
					if isInArray({328, 329}, v.lookType) then
						v.lookType = getPlayerSex(pid) == 0 and 136 or 128
						doCreatureChangeOutfit(pid, v)
					end
					doPlayerRemoveOutfitId(pid, 34)
					while doPlayerRemoveItem(pid, 10502, 1) do
						doPlayerAddItem(pid, 10510, 1)
					end
				end
			end
		else
			npcHandler:say('Damn, I bet <hicks> your cheating spouse took all of your money <hicks> from you. You\'re as poor as a church mouse. <hicks>', cid)
		end
	end
	Topic[cid] = n
	return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, "Bye ... and now I'll have a quick drink.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye ... and now I'll have a quick drink.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Last edited:
Brewster: There's no justice in the world when a pretty lady like yourself is treated badly. <hicks> Not that I have a special connection to the Gods or anything <hicks> - but I can arrange your d... divorce, if that is what you wish. <hicks> Do you?

- Yes

- Nothing happnends
 
Back
Top