TomCrusher
Jeg er ingenting
Idk what happend scripts work no bugs on console but anybody can move and open backpack so?
function onUse(cid, item, fromPosition, itemEx, toPosition)
local playerID = getPlayerGUID(cid)
local owner = item.actionid-100
if(owner > 0)then
if(owner ~= playerID)then
doPlayerSendCancel(cid, 'You aren\'t owner of this container.')
return 0
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local playerID = getPlayerGUID(cid)
local owner = item.actionid-100
if(owner > 0)then
if(owner ~= playerID)then
doPlayerSendCancel(cid, 'You aren\'t owner of this container.')
return TRUE
end
end
end
#OWN BACKPACK IS NOT MOVEABLE!
Here it comes, I'm not sure whether it works, because I do not know too much about performance of the functions.
Not tested, but should work.
movements.xml:
Code:<movevent event="AddItem" tileitem="1" itemid="2000" script="ownbp.lua"/>
movements/scripts/ownbp.lua:
Code:function onAddItem(moveitem, tileitem, position) if(moveitem.actionid > 0)then return 0 end end
Yours,
ersiu.
Well, if this will work, you won't get message, since "cid" returns nil. Also, if you remove this message, even the player that owns the backpack will not be able to move it.
Is it possible that solely V.I.P.'s are able to buy such a backpack?
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Own Loot Backpack" enabled="yes">
<config name="ownbp_config"><![CDATA[
config = {
itemid = 2000,
cost = 1000
}
]]></config>
<talkaction words="!ownbp" event="buffer"><![CDATA[
domodlib('ownbp_config')
if doPlayerRemoveMoney(cid, config.cost) then
local backpack = doPlayerAddItem(cid, config.itemid, 1)
doItemSetAttribute(backpack, "description", getPlayerName(cid) .. ' owns this container.')
return doItemSetAttribute(backpack, "aid", getPlayerGUID(cid) + 1000)
end
return doPlayerSendCancel(cid, "You don't have enough money, it costs " .. config.cost .. " gold.")
]]></talkaction>
<action itemid="2000" event="buffer"><![CDATA[
_result = item.actionid >= 1000 and item.actionid - 1000 ~= getPlayerGUID(cid) and doPlayerSendCancel(cid, 'You\'re not owner of this container.')
]]></action>
</mod>
Removed ownTime, because it can't work (only with uids, but TFS is missing function for checking if item exists).
I tried to do it but it's not possible in Lua.Rep ++
Possible to do this container not moveable ?
I tried to do it but it's not possible in Lua.
I tried to do it but it's not possible in Lua.
Should work:...
Removed ownTime, because it can't work (only with uids, but TFS is missing function for checking if item exists).
function isItemExist(uid)
if(type(getThingPosition(uid)) == boolean) then
return false
end
return true
end
int32_t LuaScriptInterface::luaGetThingPosition(lua_State* L)
{
//getThingPosition(uid)
ScriptEnviroment* env = getEnv();
if(Thing* thing = env->getThingByUID(popNumber(L)))
{
Position pos = thing->getPosition();
uint32_t stackpos = 0;
if(Tile* tile = thing->getTile())
stackpos = tile->__getIndexOfThing(thing);
pushPosition(L, pos, stackpos);
}
else
{
errorEx(getError(LUA_ERROR_THING_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}