• 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 Own Loot Backpack

Idk what happend scripts work no bugs on console but anybody can move and open backpack so?
 
PHP:
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
change the return to TRUE or 1..
move part idk
 
Sorry im lazzy just set return TRUE wihout return 0like it:

PHP:
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
It work! On the TFS 0.3b3
Thank's man!
But on the movements don't work TRUE or 1, have any idea? And normal player cannot create ownbp :(
 
Last edited:
#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.

You are correct. Does anyone know how to make it so the backpack isn't moveable and /clean doesnt remove it? TFS 0.3.4pl2
 
Code:
<?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.

You can for if it's on the ground. Edit items.otb and pick any deprecated item you like. give it a unique cid. set NotMoveable and lookThrough. Spawn on top of backpack with action id for a script destroys this invisible block if the owner uses it, but just gives some error message for anyone else. Even more pro would be exploiting lookThrough by having the backpack add even more additional info to it's nameDescription like 'a sigillus has locked the backpack in place'
 
...
Removed ownTime, because it can't work (only with uids, but TFS is missing function for checking if item exists).
Should work:
PHP:
function isItemExist(uid)
  if(type(getThingPosition(uid)) == boolean) then
    return false
  end
  return true
end
not tested (based on 0.3.6pl1.r83 sources only)
PHP:
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;
}
 
What I meant to say was, it isn't possible to check if item exists without getting a console error, and removing that error would require a source edit.
 
[15/05/2011 15:34:40] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/ownbp.lua:23: '}' expected near '='
[15/05/2011 15:34:40] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/ownbp.lua)}


?? help.
 
Back
Top