function onSay(cid, words, param)
-- Config
Itemid = 2160 // where id of item
Charge = 1 // where charge of item reward
PorcentOFWin = 25 // % of change win
ManaRequest = 300 // mana
-- Config
if(getCreatureMana(cid) < ManaRequest) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You do not have enough mana.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return true
end
if(math.random(1, 100) >= PorcentOFWin) then
doCreatureAddMana(cid, -ManaRequest)
doPlayerAddItem(cid, Itemid, Charge)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Spell Bloke, FAIL...")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return false
end
<talkaction words="spellsss nammee" event="script" value="xxxx.lua"/>
function onCastSpell(cid, var)
local Itemid = 12531
local Charge = 1
local PorcentOFWin = 75
if(math.random(1, 100) >= PorcentOFWin) then
doPlayerAddItem(cid, Itemid, Charge)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
else
doPlayerSendCancel(cid, "Sorry, you failed.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return false
end
I tried this. It worked nice, thx!Code:function onCastSpell(cid, var) local Itemid = 12531 local Charge = 1 local PorcentOFWin = 75 if(math.random(1, 100) >= PorcentOFWin) then doPlayerAddItem(cid, Itemid, Charge) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED) else doPlayerSendCancel(cid, "Sorry, you failed.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) end return false end