• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Block damge script

Elgenady

Veteran OT User
Joined
Aug 5, 2011
Messages
1,663
Solutions
36
Reaction score
371
first block damge for 5 sec i took idea from @Limos but i edite it to work in action not spells and mad some edit this script work in 0.4 and 0.3.6
action.xml
Code:
<action itemid="xxxx" event="script" value="blockdamge.lua"/>

chnage xxxx to items id

now mad script in /date/action/script name blockdamge.lua

Code:
--This script made By herotom-- Heba in otland--
local c = {
   storage = 48503,
   time = 4
}
     local timee = 5000
     local ids = {333} -- put there ids of your outfits
     local function GoBack(cid, hp, mp, pos)
    if(not isPlayer(cid)) then
        return
    end


    doSendMagicEffect(pos, 31)
    local hp_now = getCreatureHealth(cid)
    local mp_now = getCreatureMana(cid)
         doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 0, 0, true)
         doCreatureAddMana(cid, getCreatureMaxMana(cid))
    return true
       end
       local combat = createCombatObject()
       setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
       setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

     local function doBlockEffect(cid)
       doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
        end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = getThingPosition(cid)
    local tile_info = getTileInfo(pos)
    if (tile_info.protection or tile_info.nopvp or tile_info.nologout or tile_info.house or tile_info.hardcore) then
        return doPlayerSendCancel(cid, "Cannot be used in events and special zones!")
    end
     if (not exhaustion.check(cid, 17023)) then
     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)
     exhaustion.set(cid, 17023, 30)
     doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     local outfit = {lookType = ids[math.random(#ids)]}
     doSetCreatureOutfit(cid, outfit, timee)
     for x = 1, c.time do
     addEvent(doBlockEffect, x * 1000, target)
     local hp = getCreatureHealth(cid)
     local mp = getCreatureMana(cid)
     doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 0, 0, true)
     doCreatureAddMana(cid, getCreatureMaxMana(cid))
     addEvent(GoBack,5*1000, cid, hp, mp, pos)
         end
         return true
    else
        doPlayerSendCancel(cid, "You will be able to use this gem again in  "..exhaustion.get(cid, 17023).." seconds.")
     end
     return true
end

now goto creaturescript

creaturescript.xml
Code:
<event type="statschange" name="BlockEffecte" event="script" value="blockeffecte.lua"/>

now date/creaturescript/scripts file name blockeffecte.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)
   if exhaustion.check(cid, 48503) then
     return false
   end
   return true
end
now login
Code:
registerCreatureEvent(cid, "BlockEffecte")
You can post anyscript you want here and i will try to help you
Rep if i helped you
Notice : sorry for my bad english

 
Last edited:
first block damge for 5 sec i took idea from @Limos but i edite it to work in action not spells and mad some edit this script work in 0.4 and 0.3.6

action.xml
Code:
<action itemid="xxxx" event="script" value="blockdamge.lua"/>

chnage xxxx to items id

now mad script in /date/action/script name blockdamge.lua

Code:
--This script made By herotom-- Heba in otland--
local c = {
   storage = 48503,
   time = 4
}
     local timee = 5000
     local ids = {333} -- put there ids of your outfits
     local function GoBack(cid, hp, mp, pos)
    if(not isPlayer(cid)) then
        return
    end


    doSendMagicEffect(pos, 31)
    local hp_now = getCreatureHealth(cid)
    local mp_now = getCreatureMana(cid)
         doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 0, 0, true)
         doCreatureAddMana(cid, getCreatureMaxMana(cid))
    return true
       end
       local combat = createCombatObject()
       setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
       setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

     local function doBlockEffect(cid)
       doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
        end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = getThingPosition(cid)
    local tile_info = getTileInfo(pos)
    if (tile_info.protection or tile_info.nopvp or tile_info.nologout or tile_info.house or tile_info.hardcore) then
        return doPlayerSendCancel(cid, "Cannot be used in events and special zones!")
    end
     if (not exhaustion.check(cid, 17023)) then
     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)
     exhaustion.set(cid, 17023, 30)
     doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     local outfit = {lookType = ids[math.random(#ids)]}
     doSetCreatureOutfit(cid, outfit, timee)
     for x = 1, c.time do
     addEvent(doBlockEffect, x * 1000, target)
     local hp = getCreatureHealth(cid)
     local mp = getCreatureMana(cid)
     doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 0, 0, true)
     doCreatureAddMana(cid, getCreatureMaxMana(cid))
     addEvent(GoBack,5*1000, cid, hp, mp, pos)
         end
         return true
    else
        doPlayerSendCancel(cid, "You will be able to use this gem again in  "..exhaustion.get(cid, 17023).." seconds.")
     end
     return true
end

now goto creaturescript

creaturescript.xml
Code:
<event type="statschange" name="BlockEffecte" event="script" value="blockeffecte.lua"/>

now date/creaturescript/scripts file name blockeffecte.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)
   if exhaustion.check(cid, 48503) then
     return false
   end
   return true
end
now login
Code:
registerCreatureEvent(cid, "BlockEffecte")
You can post anyscript you want here and i will try to help you
Rep if i helped you
Notice : sorry for my bad english
Hmm i didn't try it yet but may you make this item with voc? :D
 
u can use this cod
Code:
if(isKnight(cid)) then
        return doPlayerSendCancel(cid, "Knights are not able to use clock gem!")
    end
under
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
Back
Top