sabodden
Member
- Joined
- Sep 27, 2019
- Messages
- 138
- Reaction score
- 18
I wanna make UH as action, not spell, but i got a problem:
How get useWith, target
I mean, it u use this UH in other player, not yourself
actions/scripts/uh.lua
How get useWith, target
I mean, it u use this UH in other player, not yourself
Code:
local target = cid
-- 1 how to check if rune was used in a real player? i mean, not only cid, others players/monsters
if target == 0 then
doPlayerSendCancel(cid, "You need to have a target to use this rune.")
return true
end
actions/scripts/uh.lua
Code:
local maglv = 3
function onGetFormulaValues(cid)
local min = ( (((getPlayerMagLevel(cid)) * 100) * 0.5 ) + (40) )
local max = ( (((getPlayerMagLevel(cid)) * 100) * 1.0 ) + (40) )
local value = math.random(min, max)
return value
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local target = cid
-- 1 how to check if rune was used in a real player? i mean, not only cid, others players/monsters
if target == 0 then
doPlayerSendCancel(cid, "You need to have a target to use this rune.")
return true
end
if(os.time() - getPlayerStorageValue(cid, spellcfg_actions_exausted_storage)) < spellcfg_actions_exausted_secs then
doPlayerSendCancel(cid, "You are exausted.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return true
end
if getPlayerMagLevel(cid) < maglv then
doPlayerSendCancel(cid, "You do not have enought magic level.")
return true
end
doSendMagicEffect(getThingPos(target), CONST_ME_MAGIC_BLUE)
local dmg = onGetFormulaValues(cid)
doCreatureAddHealth(cid, dmg)
setPlayerStorageValue(cid, spellcfg_actions_exausted_storage, os.time())
doRemoveItem(item.uid, 1)
return TRUE
end