Pokurwieniec
New Member
- Joined
- Feb 1, 2016
- Messages
- 43
- Reaction score
- 1
Hi guys i have this marriage script but it allows to merry the same sex! Can somebody add to this condition which allow merry only opposite sex
Part 1.
Part 1.
Code:
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, 24, 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