do actions.xml dodajemy:

actions.xml
   <action itemid="ITEM ID" script="pills/soldier.lua"/>
 

tworzymy plik soldier.lua w data/actions i wlejamy:

soldier.lua
function onUse(cid, item, frompos, item2, topos)
   local exhausted_seconds = 1
   local exhausted_storagevalue = 74
   local  mp = 0.20  -- 0.ILE MA DAWAĆ MP W %
    local  hp = 0.20  -- 0.ILE MA DAWAĆ HP W %
 
 
 if isPlayer(cid) then
                if(os.time() <= getPlayerStorageValue(cid, exhausted_storagevalue)) then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                return doPlayerSendCancel(cid, "You are exchausted.")
                end
       if(item.type >= 1) then
doSendMagicEffect(topos,40)
   doCreatureAddMana(cid, math.floor(getCreatureMaxMana(cid)*mp))
   doCreatureAddHealth(cid, math.floor(getCreatureMaxHealth(cid)*hp))
               setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
               doChangeTypeItem(item.uid, item.type - 1)
         else
doSendMagicEffect(topos,40)
   doCreatureAddMana(cid, math.floor(getCreatureMaxMana(cid)*mp))
   doCreatureAddHealth(cid, math.floor(getCreatureMaxHealth(cid)*hp))
               setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
               doRemoveItem(item.uid, 1)
            end
      end
   return true
end
otspub/item_regenerujacy_hp_mp.txt · Last modified: 2011/04/03 21:04 by erexo
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki