• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [Configurable] !buy System

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,984
Solutions
2
Reaction score
120
Location
Germany
GitHub
Shawak
Hello,

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.

Change...
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},
	}
...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},
        ["leather legs"] = {id = XXX, count = 1, cost = XXX},
	}
... and so on!
Warning:
"count = .." work only with stackable items.

~Enjoy~

Regards,
Shawak
 
Nice idea...
from my teleport script?

They seem quite similar.
It's okay, just want to know.
 
Nice idea...
from my teleport script?

They seem quite similar.
It's okay, just want to know.

I saw the script, and got the idea ^_^.

Regards,
Shawak
 
Last edited:
Back
Top