<action itemid="5809" event="script" value="blockdamge.lua"/>
local c = {
storage = 48503,
time = 4
}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
local function doBlockEffect(cid)
return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local target = cid
if not isCreature(target) then
doPlayerSendCancel(cid, "Target has to be a player.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end
if exhaustion.check(target, c.storage) then
local n = target == cid and "You are" or getPlayerName(target).." is"
doPlayerSendCancel(cid, n.." already blocking attacks.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return false
end
exhaustion.set(target, c.storage, c.time)
doSendAnimatedText(getPlayerPosition(target), "Blocked", COLOR_RED)
for x = 1, c.time do
addEvent(doBlockEffect, x * 1000, target)
end
return true
end
@heba i want script when i use book it give forever aol and bless for 1 month and when the chr open it says automatic aol+bless can you?try this
Code:<action itemid="5809" event="script" value="blockdamge.lua"/>
Code:local c = { storage = 48503, time = 4 } local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH) local function doBlockEffect(cid) return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED) end function onUse(cid, item, fromPosition, itemEx, toPosition) local target = cid if not isCreature(target) then doPlayerSendCancel(cid, "Target has to be a player.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) return false end if exhaustion.check(target, c.storage) then local n = target == cid and "You are" or getPlayerName(target).." is" doPlayerSendCancel(cid, n.." already blocking attacks.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) return false end exhaustion.set(target, c.storage, c.time) doSendAnimatedText(getPlayerPosition(target), "Blocked", COLOR_RED) for x = 1, c.time do addEvent(doBlockEffect, x * 1000, target) end return true end
local autoBlessStorage = 57927
local autoAOLStorage = 57928
function onLogin(cid)
local templePosition = getTownTemplePosition(getPlayerTown(cid))
local playerPosition = getThingPosition(cid)
local fyi = {}
local msg = {}
if(getDistanceBetween(templePosition, playerPosition) <= 2) then
if(getCreatureStorage(cid, autoAOLStorage) == 1 and getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == 0) then
if(doPlayerRemoveMoney(cid,10000)) then
doPlayerAddItem(cid,2173,1)
doCreatureSay(cid,'AOL',TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPosition(cid),CONST_ME_BATS)
table.insert(msg, 'You have bought Amulet of Loss!')
else
table.insert(fyi, 'You got no money for Amulet of Loss! It cost 1 crystal coin!')
end
end
if(getCreatureStorage(cid, autoBlessStorage) == 1 and not getPlayerBlessing(cid,1)) then
if(doPlayerRemoveMoney(cid,50000)) then
for b=1,5 do
doPlayerAddBlessing(cid,b)
end
doCreatureSay(cid,'BLESS',TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPosition(cid),CONST_ME_HOLYDAMAGE)
table.insert(msg, 'You have been blessed by the gods!')
else
table.insert(fyi, 'You got no money for Bless! It cost 5 crystal coin!')
end
end
end
if(#fyi > 0) then
doPlayerPopupFYI(cid, table.concat(fyi, '\n'))
end
if(#msg > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, table.concat(msg, '\n'))
end
if(#msg > 0 or #fyi > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You can turn off auto buyer by commands:\n!aol off\n!bless off')
end
return true
end
done @heba but what can i do to know it works perfectCode:registerCreatureEvent(cid, "autobuyer")