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

Action own backpack

Wazzap

Killing Elite
Joined
Jun 15, 2010
Messages
124
Reaction score
4
Location
London / Poland
actions.xml
<action actionid="1567" event="script" value="ownbp.lua"/>
ownbp.lua:
function onUse(cid, item, fromPos, itemEx, toPos)
if (getItemAttribute(item.uid, "aid") == 1567) then
if (getItemAttribute(item.uid, "uid") ~= (getPlayerGUID(cid) + 1000)) then
doPlayerSendTextMessage(cid, 22, "This is not your backpack.")
return true
end
end
return false
end
NPC to buy own bp
local focuses = {}
local talkState = {}
local cost = 50000
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)) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function onCreatureSay(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Hello my friend. How can I help you?", cid)
addFocus(cid)
elseif(isFocused(cid) and(msg == "special backpack" or msg == "backpack" or msg == "own backpack")) then
selfSay("Yes I have it, but it really expensive item. Do you want to buy it for "..cost.." gold coins?", cid)
talkState[talkUser] = 1
elseif(isFocused(cid) and msg == "yes" and talkState[talkUser] == 1) then
if (doPlayerRemoveMoney(cid, cost) == true) then
local item = doPlayerAddItem(cid, 1988)
doItemSetAttribute(item, "aid", 1567)
doItemSetAttribute(item, "uid", (getPlayerGUID(cid) + 1000))
doItemSetAttribute(item, "description", "It is "..getCreatureName(cid).." own backpack.")
selfSay("Here you are", cid)
else
selfSay("You don\'t have enough money.", cid)
end
elseif(isFocused(cid) and msg == "yes" and talkState[talkUser] == 1) then
selfSay("Ohh, ok.", cid)
elseif(isFocused(cid) and (msg == "bb" or msg == "bye")) then
selfSay("Bye!", cid)
removeFocus(cid)
else
selfSay("I cannot understand what you say, reapeat please.", cid)
end
return true
end
function onThink()
for i, focus in pairs(focuses) do
if(not isCreature(focus)) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
selfSay("")
removeFocus(focus)
end
end
end
lookAtFocus()
end
Cost of own bp
 
Back
Top