• 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!

TalkAction !buyitem

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
it's my simple !buyitem function, you can add many items, it's so easy.

buyitem.lua
Code:
-- simple !buyitem system fully working made by ersiu(Azi). -- 
function onSay(cid, param, words)
 local items = {{'backpack', 1980, 10}, {'amulet of loss', 2173, 50000}} -- items for sell.

for x = 1, #items do
if(param == items[x][1])then
pos = x
end
end

if(doPlayerRemoveMoney(cid, items[pos][3]) == TRUE)then
doPlayerAddItem(cid, items[pos][2])
doPlayerSendTextMessage(cid, 19, 'You bought '..items[pos][1]..' for '..items[pos][3]..', thank you!')
else
doPlayerSendTextMessage(cid, 19, 'Sorry, that\'s too expensive for you.')
end

if(param == 'selling list')then
local items_count = table.getn(items)
local list_nr = 1
while(1 <= items_count)do
doPlayerSendTextMessage(cid, 19, '-'..list_nr..'. '..items[list_nr][1]..' costs: '..list_nr..'. '..items[list_nr][3]..'\n.')
list_nr = list_nr+1
end
end
end
talkactions.xml
Code:
<talkaction words="!buyitem" script="buyitem.lua"/>
you adding items to show by table items("{{'name', itemid, cost}}")
if player say with param item name and have money, he's buy it, if param is 'selling list' to script send to player list of items that shop offering.
 
Last edited:
Back
Top