MarkSmartRemark
Lua-Noob in Training :D
- Joined
- Jan 27, 2010
- Messages
- 139
- Reaction score
- 3
Hi,
Im looking for a code that does the following:
EDIT: Spell is working perfectly.
will be reposted on spells section with credits to those who helped and myself, Thanks alot!!
Im looking for a code that does the following:
- Player casts spell and adds 20 of an item into his backpack. (spell)
- Example If he has 89 of these in backpack the spell will only add 11 to his backpack.(part of spell)
- If he already has 100 in backpack, spell will not work.
EDIT: Spell is working perfectly.
Code:
--.::.CONFIG.::.--
local item = 2677 --- Item ID number
local cast_amount = 20 --- How many will spell create
local max_item = 100 --- Maximum allowed in BP
--.::.CONFIG.::.--
function onCastSpell(cid, var)
local difference = (max_item - cast_amount)
if getPlayerItemCount(cid, item) <= difference then
doPlayerAddItem(cid, item, cast_amount, true)
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
elseif getPlayerItemCount(cid, item) > difference and getPlayerItemCount(cid, item) < max_item then
doPlayerAddItem(cid, item,(max_item - getPlayerItemCount(cid, item)))
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
elseif getPlayerItemCount(cid, item) >= max_item then
doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You've reached your limit of "..max_item.." "..getItemNameById(item)..".")
end
return true
end
will be reposted on spells section with credits to those who helped and myself, Thanks alot!!
Last edited: