Shawak
Intermediate OT User
Hello,
here a useful script, tested on TFS 0.3.4.
Tested and it works.
goto data/talkactions/scripts/buy.lua
After that, goto data/talkactions/talkactions.xml
Yes, you can add more items.
"count = .." work only with stackable items.
~Enjoy~
Regards,
Shawak
here a useful script, tested on TFS 0.3.4.
Tested and it works.
goto data/talkactions/scripts/buy.lua
Code:
--[[
!buy System
by Maxi (Shawak)
-> "count" works only if you use a countable item (like bolts,arrows,gps)
]]--
local items = {
["backpack"] = {id = 1988, count = 1, cost = 10},
["shovel"] = {id = 2554, count = 1, cost = 50},
["rope"] = {id = 2120, count = 1, cost = 50},
["assassin star"] = {id = 7368, count = 100, cost = 2000},
}
function onSay(cid, words, param, channel)
local buyItem = items[param]
if buyItem ~= nil then
if doPlayerRemoveMoney(cid, buyItem.cost) == TRUE then
doPlayerAddItem(cid,buyItem.id,buyItem.count)
doPlayerSendTextMessage(cid,18,"Buy Manager: You bought "..buyItem.count.." "..getItemNameById(buyItem.id).." for "..buyItem.cost.." gold.")
else
doPlayerSendTextMessage(cid,18,"Buy Manager: You need "..buyItem.cost.." gold for "..buyItem.count.." "..getItemNameById(buyItem.id)..".")
end
else
doPlayerSendTextMessage(cid,18,"Buy Manager: Invaild item name.")
end
buyItem = nil
return TRUE
end
After that, goto data/talkactions/talkactions.xml
HTML:
<talkaction words="!buy" event="script" value="test/buy.lua"/>
Yes, you can add more items.
Warning:Change...
...to ...Code:local items = { ["backpack"] = {id = 1988, count = 1, cost = 10}, ["shovel"] = {id = 2554, count = 1, cost = 50}, ["rope"] = {id = 2120, count = 1, cost = 50}, ["assassin star"] = {id = 7368, count = 100, cost = 2000}, }
... and so on!Code:local items = { ["backpack"] = {id = 1988, count = 1, cost = 10}, ["shovel"] = {id = 2554, count = 1, cost = 50}, ["rope"] = {id = 2120, count = 1, cost = 50}, ["assassin star"] = {id = 7368, count = 100, cost = 2000}, ["leather legs"] = {id = XXX, count = 1, cost = XXX}, }
"count = .." work only with stackable items.
~Enjoy~
Regards,
Shawak