• 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!

[Spell] Percentage

Nobziin

New Member
Joined
Apr 3, 2011
Messages
3
Reaction score
0
A spell with 25% to create x item and 75% to fail. Can someone help? I'm newbie. :w00t:
 
Code:
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

Code:
<talkaction words="spellsss nammee" event="script" value="xxxx.lua"/>


not tested
 
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
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
I tried this. It worked nice, thx!

weird looked like he said 25% success rate. maybe theres a secret code located in his post or something, idk.
 
Back
Top