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

Buy stuff from NPC with tokens

ib0w

teamfiveporject
Joined
Apr 3, 2009
Messages
91
Reaction score
4
Location
Sweden/Ronneby
hey, is it able to buy stuff from a npc with like tokens(itemid 9020)?
instead of paying with gold u pay with tokens.
would be nice if anyone could help me! rep++
 
For trade:

Lua:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end 
function onThink() npcHandler:onThink() end 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local moeda = 9020
local t = {
      [2195] = {price = 15},
      [2493] = {price = 25},
      [2361] = {price = 30},
      [8851] = {price = 20},
      [8925] = {price = 30},
      [2640] = {price = 50},
      [2494] = {price = 100},
      [9932] = {price = 50},
      [2472] = {price = 70},
      [8931] = {price = 100}
      }
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
    if  t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then
          selfSay("you do not have "..t[item].price.." "..getItemNameById(moeda), cid)
             else
        doPlayerAddItem(cid, item)
        selfSay("here your item!", cid)
       end
    return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
            for var, ret in pairs(t) do
                    table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
                end
            openShopWindow(cid, shopWindow, onBuy, onSell)
        end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

[2493] = {price = 25}

[ITEMID] = {price = how much tokens will cost}

ps: need gps in bp

--------------------------------

For Trade-Say
Lua:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end 
function onThink() npcHandler:onThink() end 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
local moeda = 9020
local t = {
      ["boots of haste"] = {15, 2195},
      ["demon helmet"] = {25, 2493},
      ["frozen starlight"] = {30, 2361},
      ["royal crossbow"] = {20, 8851},
      ["solar axe"] = {30, 8925},
      ["soft boots"] = {50, 2640},
      ["demon armor"] = {100, 2494},
      ["firewalker boots"] = {50, 9932},
      ["magic plate armor"] = {70, 2472},
      ["flame blade"] = {100, 8931}
      }

if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
local str = ""
str = str .. "I sell these items: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos[1].." Tokens /"
end
str = str .. "." 
npcHandler:say(str, cid)
elseif t[msg] then
        if doPlayerRemoveItem(cid,moeda,t[msg][1]) then
            doPlayerAddItem(cid,t[msg][2],1)
            npcHandler:say("Here you item ".. getItemNameById(t[msg][2]) .."!", cid)
        else
            npcHandler:say("you do not have "..t[msg][1].." ".. getItemNameById(moeda), cid)
        end
end 
return TRUE 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

["boots of haste"] = {15, 2195}

["item name"] = {how much tokens, item id}
 
Last edited:
TY

For trade:

Lua:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end 
function onThink() npcHandler:onThink() end 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local moeda = 9020
local t = {
      [2195] = {price = 15},
      [2493] = {price = 25},
      [2361] = {price = 30},
      [8851] = {price = 20},
      [8925] = {price = 30},
      [2640] = {price = 50},
      [2494] = {price = 100},
      [9932] = {price = 50},
      [2472] = {price = 70},
      [8931] = {price = 100}
      }
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
    if  t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then
          selfSay("you do not have "..t[item].price.." "..getItemNameById(moeda), cid)
             else
        doPlayerAddItem(cid, item)
        selfSay("here your item!", cid)
       end
    return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
            for var, ret in pairs(t) do
                    table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
                end
            openShopWindow(cid, shopWindow, onBuy, onSell)
        end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

[2493] = {price = 25}

[ITEMID] = {price = how much tokens will cost}

ps: need gps in bp

--------------------------------

For Trade-Say
Lua:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end 
function onThink() npcHandler:onThink() end 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
local moeda = 9020
local t = {
      ["boots of haste"] = {15, 2195},
      ["demon helmet"] = {25, 2493},
      ["frozen starlight"] = {30, 2361},
      ["royal crossbow"] = {20, 8851},
      ["solar axe"] = {30, 8925},
      ["soft boots"] = {50, 2640},
      ["demon armor"] = {100, 2494},
      ["firewalker boots"] = {50, 9932},
      ["magic plate armor"] = {70, 2472},
      ["flame blade"] = {100, 8931}
      }

if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
local str = ""
str = str .. "I sell these items: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos[1].." Tokens /"
end
str = str .. "." 
npcHandler:say(str, cid)
elseif t[msg] then
        if doPlayerRemoveItem(cid,moeda,t[msg][1]) then
            doPlayerAddItem(cid,t[msg][2],1)
            npcHandler:say("Here you item ".. getItemNameById(t[msg][2]) .."!", cid)
        else
            npcHandler:say("you do not have "..t[msg][1].." ".. getItemNameById(moeda), cid)
        end
end 
return TRUE 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

["boots of haste"] = {15, 2195}

["item name"] = {how much tokens, item id}

TY!!!!!!!!!!!!!!!!!
 
Back
Top