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

Ned help Amulet seller

zyirc

New Member
Joined
Jul 15, 2008
Messages
175
Reaction score
0
Location
Sweden
Hey when i buy an amulet in my own ot it says you dont have space?? and i have space

here is code

local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end

local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v) == TRUE) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end

local itemWindow = {
-- amulet of loss
{id=2173, subtype=0, buy=10000, sell=5000},
-- ancient amulet
{id=2142, subtype=0, buy=1600, sell=800},
-- broken amulet
{id=2196, subtype=0, buy=15000, sell=5000},
-- bronze amulet
{id=2172, subtype=0, buy=100, sell=50},
-- bronzen necklace
{id=2126, subtype=0, buy=300, sell=70},
-- crystal necklace
{id=2125, subtype=0, buy=250, sell=50},
-- dragon necklace
{id=2201, subtype=0, buy=400, sell=50},
-- garlic necklace
{id=2199, subtype=0, buy=450, sell=50},
-- golden amulet
{id=2130, subtype=0, buy=3000, sell=50},
-- platinum amulet
{id=2171, subtype=0, buy=3500, sell=50},
-- protection amulet
{id=2200, subtype=0, buy=300, sell=50},
-- elven amulet
{id=2198, subtype=0, buy=500, sell=50},
-- ruby necklace
{id=2133, subtype=0, buy=2000, sell=50},
-- scarab amulet
{id=2135, subtype=0, buy=1300, sell=50},
-- scarf
{id=2135, subtype=0, buy=500, sell=50},
-- silver amulet
{id=2170, subtype=0, buy=300, sell=50},
-- silver necklace
{id=2132, subtype=0, buy=1000, sell=50},
-- star amulet
{id=2131, subtype=0, buy=1200, sell=50},
-- stone skin amulet
{id=2197, subtype=0, buy=3000, sell=50},
-- strange symbol
{id=2319, subtype=0, buy=200, sell=50},
-- strange talisman
{id=2161, subtype=0, buy=350, sell=50},
-- wolves teeth chain
{id=2129, subtype=0, buy=50, sell=50},
}

local items = {}
for _, item in ipairs(itemWindow) do
items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, subtype = item.subtype}
end

local function getPlayerMoney(cid)
return ((getPlayerItemCount(cid, 2160) * 10000) +
(getPlayerItemCount(cid, 2152) * 100) +
getPlayerItemCount(cid, 2148))
end

local onBuy = function(cid, item, subtype, amount)
if(items[item] == nil) then
selfSay("Ehm.. sorry... this shouldn't be there, I'm not selling it.", cid)
return
end

if(getPlayerMoney(cid) >= amount*items[item].buyPrice) then
local itemz, i = doPlayerAddItem(cid, item, subtype, amount)
if(i < amount) then
if(i == 0) then
selfSay("Sorry, but you don't have space to take it.", cid)
else
selfSay("I've sold some for you, but it seems you can't carry more than this. I won't take more money than necessary.", cid)
doPlayerRemoveMoney(cid, i*items[item].buyPrice)
end
else
selfSay("Thanks for the money!", cid)
doPlayerRemoveMoney(cid, amount*items[item].buyPrice)
end
else
selfSay("Stfu noob, you don't have money.", cid)
end
end

local onSell = function(cid, item, subtype, amount)
if(items[item] == nil) then
selfSay("Ehm.. sorry... this shouldn't be there, I'm not buying it.", cid)
end

if(subtype < 1) then
subtype = -1
end
if(doPlayerRemoveItem(cid, item, amount, subtype) == TRUE) then
doPlayerAddMoney(cid, items[item].sellPrice*amount)
selfSay("Here you are.", cid)
else
selfSay("No item, no deal.", cid)
end
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
removeFocus(cid)
if(isPlayer(cid) == TRUE) then --Be sure he's online
closeShopWindow(cid)
end
end
end

function onCreatureSay(cid, type, msg)
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Welcome, ".. getCreatureName(cid) .."I sell and buy all amulets.", cid, TRUE)
selfSay("Do you want to see my {amulets}?", cid)
addFocus(cid)
elseif((isFocused(cid)) and (msg == "amulets" or msg == "trade")) then
selfSay("Pretty nice, right?", cid)
openShopWindow(cid, itemWindow, onBuy, onSell)
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Goodbye!", cid, TRUE)
closeShopWindow(cid)
removeFocus(cid)
end
end

function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
closeShopWindow(cid)
removeFocus(cid)
end
end

function onPlayerEndTrade(cid)
selfSay("It was a pleasure doing business with you.", cid)
end

function onThink()
for i, focus in pairs(focuses) do
if(isCreature(focus) == FALSE) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
selfSay("Hmph!")
closeShopWindow(focus)
removeFocus(focus)
end
end
end
lookAtFocus()
end
 
Back
Top