-
Notifications
You must be signed in to change notification settings - Fork 9
/
command-buy.xml
53 lines (46 loc) · 1.43 KB
/
command-buy.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
<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-buy" version="1.0" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
<config name="command-buy-config"><![CDATA[
items = {
['aol'] = {cost = 50000, id = 2173},
['backpack'] = {cost = 25, id = 1988},
['rope'] = {cost = 50, id = 2120},
['shovel'] = {cost = 50, id = 2554},
['machete'] = {cost = 40, id = 2420},
['fishing rod'] = {cost = 150, id = 2580}
}
]]></config>
<!--
TODO:
- buying items for premium_points
-->
<talkaction words="!buy;/buy" event="script"><![CDATA[
domodlib('command-buy-config')
local config = {
items = items
}
function onSay(cid, words, param, channel)
if(param == '') then
local str = ""
for name, options in pairs(config.items) do
str = str .. "\n" .. name
end
doPlayerPopupFYI(cid, "!buy\n\n:" .. str)
return true
end
local item = config.items[param]
if(item ~= nil) then
if(not doPlayerRemoveMoney(cid, item.cost)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Not enough money to buy " .. param .. ".\n(" .. item.cost .. "gp)")
return true
end
local amount = item.amount and item.amount or 1
doPlayerAddItem(cid, item.id, amount)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
else
doPlayerSendCancel(cid, "Item not found. Use '!buy' to see the list.")
end
return true
end
]]></talkaction>
</mod>