-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathguild-cast.xml
76 lines (66 loc) · 2.44 KB
/
guild-cast.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
<?xml version="1.0" encoding="UTF-8"?>
<mod name="guild-cast" version="1.0" author="elf, slawkens" contact="otland.net" enabled="yes">
<config name="guild-cast-config"><![CDATA[
exhaust = 10 -- in seconds
storage = 3001 -- storage value used to save exhaustion
storageColor = 3002 -- storage value used to save previously used message color
]]></config>
<talkaction words="!gc" event="script"><![CDATA[
domodlib('guild-cast-config')
local config = {
exhaustion = exhaust,
storage = storage,
storageColor = storageColor
}
function onSay(cid, words, param, channel)
if(exhaustion.check(cid, config.storage)) then
doPlayerSendCancel(cid, "You can broadcast message only one time per " .. config.exhaustion .. " seconds.")
return true
end
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a message to broadcast!")
return true
end
local playerGuild = getPlayerGuildId(cid)
if(playerGuild == FALSE) then
doPlayerSendCancel(cid, "Sorry, you're not in a guild.");
return true
end
if(getPlayerGuildLevel(cid) < GUILDLEVEL_VICE) then
doPlayerSendCancel(cid, "You have to be at least Vice-Leader to guildcast!")
return true
end
local messageType = MESSAGE_STATUS_WARNING
local t = string.explode(param, ";")
if(not t[2]) then
if(getPlayerStorageValue(cid, config.storageColor) ~= -1) then
messageType = getPlayerStorageValue(cid, config.storageColor)
end
else
if(MESSAGE_TYPES[t[1]] ~= nil) then
messageType = MESSAGE_TYPES[t[1]]
end
param = t[2]
end
if(messageType < MESSAGE_FIRST or messageType > MESSAGE_LAST) then
messageType = MESSAGE_STATUS_WARNING
--setPlayerStorageValue(cid, MESSAGE_STATUS_WARNING, messageType)
--doPlayerSendCancel(cid, "Unknown message type.")
--return true
end
local players = getPlayersOnline()
local message = "*Guild* " .. getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "]:\n" .. param
local members = 0
for i, tid in ipairs(players) do
if(getPlayerGuildId(tid) == playerGuild) then
doPlayerSendTextMessage(tid, messageType, message)
members = members + 1
end
end
setPlayerStorageValue(cid, config.storageColor, messageType)
exhaustion.set(cid, config.storage, config.exhaustion)
doPlayerSendCancel(cid, "Message sent to your guild members. (Total: " .. members .. ")")
return true
end
]]></talkaction>
</mod>