bizao030188
Member
- Joined
- Jun 4, 2012
- Messages
- 50
- Solutions
- 2
- Reaction score
- 7
Hi!
I want to create a script that does not allow a player carry more than, let's say 3 items of id 100. I did this on player events:
The problem is that "if player then" condition is accessed only when I equip with the item but not when I put it in any bag the player is holding. I want it to check everywhere, what should I change?
I am using TFS 1.2
Thanks in advanced!
I want to create a script that does not allow a player carry more than, let's say 3 items of id 100. I did this on player events:
Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
print("onMoveItem")
if not item.getId() == 100 then return true end
local player = Player(toCylinder)
if player then
local count = player:getItemCount(100)
print(player:getName())
print(count)
if count > 3 then player:sendCancelMessage("Sorry, not possible. You are at maximum capacity") return false end
end
return true
end
The problem is that "if player then" condition is accessed only when I equip with the item but not when I put it in any bag the player is holding. I want it to check everywhere, what should I change?
I am using TFS 1.2
Thanks in advanced!