-
Notifications
You must be signed in to change notification settings - Fork 9
/
command-promotion.xml
49 lines (40 loc) · 1.85 KB
/
command-promotion.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
<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-promotion" version="1.0" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
<config name="command-promotion-config"><![CDATA[
-- how much gold coins does it cost
cost = 20000
-- required level to buy a promotion
minLevel = 20
-- need premium account to use command?
needPremium = "yes"
-- maximum promotion level player can advance to (default = 1). Can be ignored if there are not any new vocations on the server.
maxPromotionLevel = 1
]]></config>
<talkaction words="!promotion" event="script"><![CDATA[
domodlib('command-promotion-config')
local config = {
cost = cost,
minLevel = minLevel,
needPremium = needPremium,
maxPromotionLevel = maxPromotionLevel
}
config.needPremium = getBooleanFromString(config.needPremium)
function onSay(cid, words, param, channel)
if(config.needPremium and not isPremium(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a premium account to get promotion.")
return true
end
if(getPlayerPromotionLevel(cid) >= config.maxPromotionLevel) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are already promoted.")
elseif(getPlayerLevel(cid) < config.minLevel) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. config.minLevel .. " to get promotion.")
elseif(doPlayerRemoveMoney(cid, config.cost) ~= TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enought money! (Promotion cost " .. config.cost .. " gold coins.")
else
setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
end
return true
end
]]></talkaction>
</mod>