-
Notifications
You must be signed in to change notification settings - Fork 9
/
command-marry.xml
124 lines (104 loc) · 4.67 KB
/
command-marry.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-marry" version="1.1" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
<description>
This mod adds a new command to the server that allows peoples to take a wedding using command.
Usage is very simple:
!marry name (one person initiates it, and after that second person have to accept it)
!marry divorce (take a divorce with your partner (if you have any))
</description>
<config name="command-marry-config"><![CDATA[
storage = 3009
allowHomoWedding = false -- allow marriages of players with same gender?
blockedAccess = 3 -- access of the same or higher value can't take a wedding (by default: 4 - don't allow gamemasters)
]]></config>
<!-- Changelog of this mod:
v1.0
- first version, most of the current functionalities
v1.1
- added 2 new configurables: allowHomoWedding and blockedAccess
-->
<talkaction words="!marry" event="script"><![CDATA[
domodlib('command-marry-config')
local config = {
storage = storage,
allowHomoWedding = getBooleanFromString(allowHomoWedding),
blockedAccess = blockedAccess
}
local function hearthEffect(cid)
if(isPlayer(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HEARTS)
end
end
local function internalMarried(cid, pid, guid)
doPlayerSetPartner(cid, guid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "*CONGRATULATIONS!*\nYou are now married with " .. getCreatureName(pid) .. ".")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HEARTS)
end
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.\nUsage: !marry playerName")
return true
end
if(isInArray({"divorce", "leave"}, param:lower())) then
local partnerGUID = getPlayerPartner(cid)
if(not partnerGUID or partnerGUID == 0) then
doPlayerSendCancel(cid, "You're not married yet.")
return true
end
local pid = getPlayerByName(getPlayerNameByGUID(partnerGUID, false, false))
if(not pid or pid == 0) then
doPlayerSendCancel(cid, "Your partner must be online to get divorced.")
else
local targetPartnerGUID = getPlayerPartner(pid)
if(targetPartnerGUID == getPlayerGUID(cid)) then
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "Your marriage has been divorced.")
doPlayerSetPartner(pid, 0)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your marriage has been divorced.")
doPlayerSetPartner(cid, 0)
end
return true
end
local pid = getPlayerByNameWildcard(param)
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
doPlayerSendCancel(cid, "Player " .. param .. " not found.")
return true
end
if(config.blockedAccess > 0 and (getPlayerAccess(pid) >= config.blockedAccess or getPlayerAccess(cid) >= config.blockedAccess)) then
doPlayerSendCancel(cid, "You cannot marry this person.")
return true
end
if(getPlayerGUID(cid) == getPlayerGUID(pid)) then
doPlayerSendCancel(cid, "You cannot be self married.")
return true
end
local sex, targetSex = getPlayerSex(cid), getPlayerSex(pid)
if(not config.allowHomoWedding and sex == targetSex) then
doPlayerSendCancel(cid, "Sorry, for this time we do not allow to take marriage with same gender (sex) as you got. Please marry with someone else.")
doSendMagicEffect(getPlayerPosition(cid),CONST_ME_POFF)
return true
end
local guid, targetGUID = getPlayerGUID(cid), getPlayerGUID(pid)
if(getPlayerPartner(cid) == targetGUID) then
doPlayerSendCancel(cid, "You are already married with this person.")
return true
end
local pos, targetPos = getCreaturePosition(cid), getCreaturePosition(pid)
if(getDistanceBetween(pos, targetPos) > 1) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getCreatureName(cid) .. " tells you to move closer.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end
if(getPlayerStorageValue(pid, config.storage) ~= guid) then
setPlayerStorageValue(cid, config.storage, targetGUID)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your proposition has been sent to " .. getCreatureName(pid) .. ".")
local playerName = getCreatureName(cid)
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, playerName .. " want be married with you. Use '!marry " .. playerName .. "' to accept.")
return true
end
internalMarried(cid, pid, targetGUID)
internalMarried(pid, cid, guid)
return true
end
]]></talkaction>
</mod>