-
Notifications
You must be signed in to change notification settings - Fork 9
/
command-refill.xml
103 lines (89 loc) · 2.68 KB
/
command-refill.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
<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-refill" version="1.0" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
<description>
This mod adds a new command to the server, that can be used to refill (more precisely: change one id to another id
for fixed price). More items can be added by modifying 'items' table.
</description>
<config name="command-refill-config"><![CDATA[
items = {
["soft"] = { -- soft boots
id = 10021,
new_id = 2640,
price = 10000,
message = "Soft boots has been refilled."
},
["firewalker"] = { -- firewalker boots
id = 10022,
new_id = 9932,
price = 50000,
message = "Firewalker boots has been refilled."
}
}
]]></config>
<lib name="command-refill-lib"><![CDATA[
domodlib('command-refill-config')
command_refill = {
items = items,
buy = function (cid, name)
local item = command_refill.items[name]
if(not item) then
print('command-refill.xml - invalid item name used (' .. name .. ')')
return false
end
if(getPlayerItemCount(cid, item.id) >= 1) then
if(getPlayerMoney(cid) >= item.price) then
if(doPlayerRemoveItem(cid, item.id, 1)) then
doPlayerBuyItem(cid, item.new_id, 1, item.price, 1)
if(item.message) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, item.message)
end
return true
end
else
doPlayerSendCancel(cid, "Not enough money.")
end
else
doPlayerSendCancel(cid, "Item not found in your inventory.")
end
return false
end
}
]]></lib>
<talkaction words="!refill" event="script"><![CDATA[
domodlib('command-points-lib')
function onSay(cid, words, param, channel)
param = param:lower():trim()
if(param == '') then
local str = ""
for name, item in pairs(command_refill.items) do
str = str .. "!refill " .. name .. "\n"
end
doPlayerPopupFYI(cid, str)
return true
end
local item = command_refill.items[param]
if(not item) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid option.")
return true
end
command_refill.buy(cid, item.name)
return true
end
]]></talkaction>
<!-- uncomment this to shorten command to be used (for example, only '!soft' instead of '!refill soft'
<talkaction words="!soft" event="script"><![CDATA[
domodlib('command-refill-lib')
function onSay(cid, words, param, channel)
command_refill.buy(cid, "soft")
return true
end
]]></talkaction>
<talkaction words="!firewalker" event="script"><![CDATA[
domodlib('command-refill-lib')
function onSay(cid, words, param, channel)
command_refill.buy(cid, "firewalker")
return true
end
]]></talkaction>
-->
</mod>