KylerXX
Active Member
- Joined
- Jun 24, 2010
- Messages
- 439
- Reaction score
- 30
Well, I created a base as example, the scripts works:
I want a banana, ok, then I say:
/shop banana, quantity
Depends on the price you've put the banana, and the amount you asked for, will cost you what you need to cost.
Will modify:
Green -> name of the item (!shop name, x)
Red -> itemid of the item.
Blue -> price of the item (only one).
talkactions.xml
I want a banana, ok, then I say:
/shop banana, quantity
Depends on the price you've put the banana, and the amount you asked for, will cost you what you need to cost.
Lua:
local items = {
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500},
["item"] = {itemid = 2882, price = 500}
}
function onSay(cid, words, param, channel) -- script by xaft
local s = string.explode(param, ",")
local shop = items[s[1]]
--
if s[1] == nil and s[2] == nil then
return doPlayerSendCancel(cid, "Please, you must expecificate the item and the quantity.")
elseif s[1] ~= nil and s[2] == nil then
return doPlayerSendCancel(cid, "Please, you must expecificate the quantity.")
end
if s[2] == "0" then
return doPlayerSendCancel(cid, "Please, the quantity will be 1 or higher.")
end
--
if shop then
if getItemWeightById(shop.itemid)*s[2] < getPlayerFreeCap(cid) then
if doPlayerRemoveMoney(cid, shop.price*s[2]) then
for i = 1,s[2] do
doPlayerAddItem(cid, shop.itemid, 1)
end
doPlayerSendTextMessage(cid, 22, "You have received ".. s[2] .." ".. getItemNameById(shop.itemid) .."!")
else
doPlayerSendCancel(cid, "You do not have enough money.")
end
else
doPlayerSendCancel(cid, "You do not have enough capacity.")
end
else
doPlayerSendCancel(cid, "Invalid shop item.")
end
return 0
end
Will modify:
["item"] = {itemid = 2882, price = 500},
Green -> name of the item (!shop name, x)
Red -> itemid of the item.
Blue -> price of the item (only one).
talkactions.xml
XML:
<talkaction words="!shop;/shop" event="script" value="shop.lua"/>