Action Blessings

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
The Forgotten Server 0.3.5
Tested & Working.

data/actions/actions.xml
PHP:
<action uniqueid="1000" event="script" value="blessings.lua"/>
data/actions/scripts/blessings.lua
Lua:
local cost = 50000
function onUse(cid, item, fromPosition, itemEx, toPosition)
    for i = 1,5 do
	if (getPlayerBlessing(cid, i) == true) then
	    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	    doCreatureSay(cid, "You have already been blessed.", TALKTYPE_ORANGE_1)
	elseif (getPlayerMoney(cid) < cost) then
            doSendAnimatedText(getCreaturePosition(cid), "$$$", TEXTCOLOR_WHITE)
	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need atleast ".. cost .." gold coins to be blessed.")
	else
            doPlayerRemoveMoney(cid, cost)
	    doPlayerAddBlessing(cid, i)
	    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
            doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been blessed by all five of the gods.")
	end
	return true
    end
end
 
Last edited:

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
It'll take 50k for each bless, it'll send message You have been blessed by all five of the gods. 5x

Here's fix (Not tested :p):
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local cost = 50000
	for i = 1, 5 do
		if (getPlayerBlessing(cid, i) == TRUE) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have been already blessed.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			break
		end

		if (getPlayerMoney(cid) < cost) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You don't have enough gold coins.")
			break
		end

		doPlayerAddBlessing(cid, i)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been blessed.")
		doPlayerRemoveMoney(cid, math.floor(cost/5))
	end
	return true
end
 
Last edited:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
You mean, another version?
Not fix :p
 

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
833
Best answers
0
Reaction score
26
Location
Poland/ Wroclaw
chojrak is right! xD

you have this:
Lua:
  elseif doPlayerRemoveMoney(cid, cost) == TRUE then
executed 5 times! so takes 250 k :).

and you don't have to write "== true" you can use:
Lua:
elseif doPlayerRemoveMoney(cid, cost) then
but Good Work ;)


EDIT: @Chojrak

Yours will take 50k each bless too! xD

should be doRemovePlayerMoney(cid,cost/5) ;)
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
chojrak is right! xD

you have this:
Lua:
  elseif doPlayerRemoveMoney(cid, cost) == TRUE then
executed 5 times! so takes 250 k :).

and you don't have to write "== true" you can use:
Lua:
elseif doPlayerRemoveMoney(cid, cost) then
but Good Work ;)
It doesn't take 250k.
It works.
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Bump.
 

exiT

Member
Joined
May 28, 2009
Messages
248
Best answers
0
Reaction score
19
Rep for you i was need this:)
 
Top