Eldora
Member
- Joined
- Oct 19, 2009
- Messages
- 581
- Reaction score
- 22
Right now, this .lua script removes 1 charge and adds 1 point per charge to the account.
I want the script to remove the item completely and add amount of points equal to the amount of charges that the item had when being used.
Basically, if (item1) has 50 charges, then on use, it should remove the item completely and add 50 points to the account.
I want the script to remove the item completely and add amount of points equal to the amount of charges that the item had when being used.
Basically, if (item1) has 50 charges, then on use, it should remove the item completely and add 50 points to the account.
Lua:
local addpoints = 1 -- amount of points to add
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if isPlayer(player) and item:getCharges() and doRemoveItem(item.uid, 1) then
db.query("UPDATE znote_accounts SET points = points + "..addpoints.." WHERE account_id = '" ..player:getAccountId().. "';")
doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..addpoints.." Points has been added to your account.")
return true
else
return false
end
end