Lurk
Active Member
- Joined
- Dec 4, 2017
- Messages
- 336
- Reaction score
- 48
Hello, I'm using tfs 0.4 and I have this 2 functions on my source
I want to block the player from trowing the items let's 2160, 2161, 2162 (an array of items) to the ground IF he has x storageValue == 1. I found some threads where this was answered but my move function on source is different than theirs so I was trying to just print stuff like this
just to understand what is going on but I'm stuck and I'm getting this console error
can anyone help? I have this moveItem2 code that blocks players from trowing stuff on depot so it might help to understand what's possible with the function
Lua:
onMoveItem(moveItem, frompos, position, cid)
Lua:
onMoveItem2(cid, item, count, toContainer, fromContainer, fromPos, toPos)
I want to block the player from trowing the items let's 2160, 2161, 2162 (an array of items) to the ground IF he has x storageValue == 1. I found some threads where this was answered but my move function on source is different than theirs so I was trying to just print stuff like this
Lua:
function onMoveItem2(cid, item, count, toContainer, fromContainer, fromPos, toPos)
print("Item id: " ..item.itemid)
print("From pos x:" ..frompos.x)
print("From pos y:" ..frompos.y)
print("From pos z:" ..frompos.z)
print("To pos x:" ..toPos.x)
print("To pos y:" ..toPos.y)
print("To pos z:" ..toPos.z)
print("From Container?:" ..fromContainer)
end
Code:
1:18:01.352] [Error - CreatureScript Interface]
[1:18:01.355] data/creaturescripts/scripts/petGround.lua:onMoveItem2
[1:18:01.360] Description:
[1:18:01.362] data/creaturescripts/scripts/petGround.lua:10: attempt to index global 'frompos' (a nil value)
[1:18:01.369] stack traceback:
[1:18:01.371] data/creaturescripts/scripts/petGround.lua:10: in function <data/creaturescripts/scripts/petGround.lua:3
Lua:
local depottiles = {} --piso pra n jogar
local depots = {2591, 2589, 2590, 2592} --id dos dps
local group = 3 --id dos group 6 é todos.
local function checkIfThrow(pos,topos)
if topos.x == 0xffff then
return false
end
local thing = getThingFromPos(pos)
if isInArray(depottiles,thing.itemid) then
if not isInArea(topos,{x=pos.x-1,y=pos.y-1,z=pos.z},{x=pos.x+1,y=pos.y+1, z=pos.z}) then
return true
end
else
for i = 1, #depots do
if depots[i] == getTileItemById(topos,depots[i]).itemid or getTileInfo(topos).actionid == 7483 then
return true
end
end
end
return false
end
function onMoveItem2(cid, item, count, toContainer, fromContainer, fromPos, toPos)
if isPlayer(cid) then
local pos = getThingPos(cid)
if getPlayerGroupId(cid) > group then
return true
end
if checkIfThrow({x=pos.x,y=pos.y,z=pos.z,stackpos=0},toPos) then
doPlayerSendCancel(cid,"You can't throw items there.")
doSendMagicEffect(getThingPos(cid),CONST_ME_POFF)
return false
end
end
return true
end