botter1234
Member
- Joined
- Jun 20, 2008
- Messages
- 103
- Reaction score
- 7
All set fully functional
Lua:
local amuletid = {
[1] = 7890, -- Inferno
[2] = 7887, -- Nature
[3] = 2198, -- Ice Shard
[4] = 2196 -- Newborn Scarabs
}
local successchance = 90 -- Percent out of 100 / Chance to Succeed
local extrachance = 60 -- Percent out of 100 / Chance to add an extra charge
function onUse(cid, item, frompos, item2, topos)
local amulet, lefthand, righthand = getPlayerSlotItem(cid, CONST_SLOT_NECKLACE), getPlayerSlotItem(cid, CONST_SLOT_LEFT), getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if(item.itemid == 1945) or (item.itemid == 1946) then
if not isInArray(amuletid, amulet.itemid) then
local info = "You can use these amulets.\n\n"
for i=1, #amuletid do
info = info .. getItemNameById(amuletid[i]) .. "\n"
end
info = info .. "\nEquip the amulet that you would like to charge."
info = info .. "\nPut an amulet with only one charge in each hand of the same type."
info = info .. "\n\nIf you fail it will destroy the amulets in your hands. Success Rate: " .. successchance .. "%"
info = info .. "\n\nUsing 2 amulets (one in each hand) has a " .. extrachance .. "% chance to add an extra charge."
return doPlayerPopupFYI(cid, info)
elseif getItemAttribute(amulet.uid, 'charges') >= 100 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cool, I have max charges on this amulet")
return false
end
for i=1, #amuletid do
if amulet.itemid == amuletid[i] then
if amulet.itemid == lefthand.itemid or amulet.itemid == righthand.itemid then
-- Both Hands Two Amulets
if isInArray(amuletid, lefthand.itemid) and isInArray(amuletid, righthand.itemid) then
if getItemAttribute(lefthand.uid, 'charges') > 1 or getItemAttribute(righthand.uid, 'charges') > 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Oh, the amulets in my hands can only have one charge")
return false
end
if(math.random(1,100) <= successchance) then
if(math.random(1,100) <= extrachance) then
doChangeTypeItem(amulet.uid, amulet.type + 3)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Great, I got an extra charge, 3 charges added.")
else
doChangeTypeItem(amulet.uid, amulet.type + 2)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Success 2 charges added.")
end
doRemoveItem(lefthand.uid)
doRemoveItem(righthand.uid)
else
doRemoveItem(lefthand.uid)
doRemoveItem(righthand.uid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Darn, I failed.")
end
-- Left Hand One Amulet
elseif isInArray(amuletid, lefthand.itemid) then
if getItemAttribute(lefthand.uid, 'charges') > 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Oh, the amulets in my hands can only have one charge")
return false
end
if(math.random(1,100) <= successchance) then
doChangeTypeItem(amulet.uid, amulet.type + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Success 1 charge added.")
doRemoveItem(lefthand.uid)
else
doRemoveItem(lefthand.uid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Darn, I failed.")
end
-- Right Hand One Amulet
elseif isInArray(amuletid, righthand.itemid) then
if getItemAttribute(righthand.uid, 'charges') > 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Oh, the amulets in my hands can only have one charge")
return false
end
if(math.random(1,100) <= successchance) then
doChangeTypeItem(amulet.uid, amulet.type + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Success 1 charge added.")
doRemoveItem(righthand.uid)
else
doRemoveItem(righthand.uid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Darn, I failed.")
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "I forgot to put the same amulet type with only one charge in each hand.")
end
end
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
end
Last edited: