ScorpiOOn93
etherno.net
Marriage System for TFS 0.4
Well, Godely created a Marriage system for TFS but it's a little bit old and it's not working on TFS 0.3.5
I've fixed it and now it's working on 0.3.4 & 0.3.5 & 0.4
Add to your function.lua
Now go to data/npc and create file called: Priest.lua
Only for 0.3.5
Now go to data/xml/outfits.xml and add this:
(warning: if you already have a outfit with id 34 you must change this, and outfit id in the npc script)
Only for 0.3.5 (with wedding outfits and wedding rings)
Now go to data/npc/scripts and create file called: wedding.lua
for 0.3.4
Now go to data/npc/scripts and create file called: wedding.lua
Now, add to your MySQL database the following table:
In data/talkactions/talkactions.xml add:
In data/talkactions/scripts create file called love.lua:
I've added exhausted to the talkactions code because players could easly spam and lag the server.
Now everything is done.
How it works?
You can also get a divorce if you don't want to have a wife/husband anymore And if you get a divorce you'll lose your wedding outfit
Script is working with gesior acc maker (It's showing in char info if someone have a wife or husband or not)
All credits goes to Godely.
***Update to 0.3.5***
Now it will give a special wedding outfit, and 2 wedding rings with special description about your partner and marriage date.
Ps: It's not 100% like in rl tibia because I didn't want to do that, but it's realy easy to do that so I can do that when someone will want that.
Well, Godely created a Marriage system for TFS but it's a little bit old and it's not working on TFS 0.3.5
I've fixed it and now it's working on 0.3.4 & 0.3.5 & 0.4
Add to your function.lua
Code:
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
Now go to data/npc and create file called: Priest.lua
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Priest" script="data/npc/scripts/wedding.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>
Only for 0.3.5
Now go to data/xml/outfits.xml and add this:
(warning: if you already have a outfit with id 34 you must change this, and outfit id in the npc script)
Code:
<outfit id="34" default="0">
<list gender="0" lookType="329" name="Wife"/>
<list gender="1" lookType="328" name="Husband"/>
</outfit>
Only for 0.3.5 (with wedding outfits and wedding rings)
Now go to data/npc/scripts and create file called: wedding.lua
Code:
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)
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))
local dateFormat = "%A %d"..getMonthDayEnding(os.date("%d")).." %B %Y"
local ring = doPlayerAddItem(cid,2121,1)
local ring2 = doPlayerAddItem(pid,2121,1)
if isOnline(fid) == TRUE and isOnline(sid) == TRUE then
if getDistanceBetween(tmf, tms) <= 3 then
setPlayerStorageValue(cid,3066,2)
setPlayerStorageValue(pid,3066,2)
doCancelMarryStatus(fid)
doCancelMarryStatus(sid)
setPlayerPartner(cid,sid)
setPlayerPartner(pid,fid)
doPlayerAddOutfitId(cid,34,0)
doPlayerAddOutfitId(pid,34,0)
doSetItemSpecialDescription(ring, "" .. getCreatureName(cid) .. " & " .. getCreatureName(pid) .. " forever - married on " ..os.date(dateFormat).. ".")
doSetItemSpecialDescription(ring2, "" .. getCreatureName(cid) .. " & " .. getCreatureName(pid) .. " forever - married on " ..os.date(dateFormat).. ".")
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)
doPlayerAddOutfitId(cid,34,-1)
doPlayerAddOutfitId(pid,34,-1)
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())
for 0.3.4
Now go to data/npc/scripts and create file called: wedding.lua
Code:
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())
Now, add to your MySQL database the following table:
Code:
ALTER TABLE `players` ADD `marrystatus` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `marriage` ;
In data/talkactions/talkactions.xml add:
Code:
<talkaction words="love" script="love.lua"/>
In data/talkactions/scripts create file called love.lua:
Code:
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
I've added exhausted to the talkactions code because players could easly spam and lag the server.
Now everything is done.
How it works?
PLAYER1 goes to the NPC and start a conversation.
PLAYER1: Hi
PLAYER1: marry
PLAYER1: yes
PLAYER1: NAME_OF_PLAYER2
Now, a "marry status" will be set to PLAYER1 with the ID of the PLAYER2. Now, the PLAYER2 go to the NPC and start a conversation:
PLAYER2: Hi
PLAYER2: marry
PLAYER2: yes
PLAYER2: proceed
You can also get a divorce if you don't want to have a wife/husband anymore And if you get a divorce you'll lose your wedding outfit
FUEATURES:
-You can get a wedding with another player
-You need 2 wedding rings to get a wedding
-After a wedding you get a wedding outfit, special description when onLook, information about your partner in acc maker and a wedding ring like in Rl tibia (playername & playername forever - married on date)
-You can get a divorce
-When you get a divorce you'll lose your wedding outfit (you must relog to loose it), you loose your special description on onLook and information in acc maker that you are a single.
Script is working with gesior acc maker (It's showing in char info if someone have a wife or husband or not)
All credits goes to Godely.
***Update to 0.3.5***
Now it will give a special wedding outfit, and 2 wedding rings with special description about your partner and marriage date.
Ps: It's not 100% like in rl tibia because I didn't want to do that, but it's realy easy to do that so I can do that when someone will want that.
TESTED AND WORKING ON TFS 0.3.5 PL1 !!!!!
Last edited: