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

Lua creating a !bless talkaction

Magictibiaman

New Member
Joined
May 25, 2009
Messages
371
Reaction score
0
This is the final code if anyone is interested.
Thanks to everyone below who helped me.

Code:
function onSay(cid, words, param)
    for i = 1,5 do
		if(getPlayerBlessing(cid, i)) then
			doPlayerSendCancel(cid, "You already have all of the blessings.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return true
		end
	end

    if doPlayerRemoveMoney(cid, 50000) == TRUE then
        for i = 1,5 do
            doPlayerAddBlessing(cid, i)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have pruchased all the blessings!")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_ENERGYAREA)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 50,000 gp in backpack for blessings.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
Last edited:
you could try this

this works for me on cryingdamson3.5p1



Code:
function onSay(cid, words, param)
    if getPlayerBlessing(cid) == 5 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You\'re a dumbass, you already bought blessings.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MORTAREA)
    return TRUE
    end
    if doPlayerRemoveMoney(cid, 50000) == TRUE then
        for i = 1,5 do
            doPlayerAddBlessing(cid, i)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have pruchased all the blessings!")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_ENERGYAREA)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 50,000 gp in backpack for blessings.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
Last edited:
0.3.6pl1

This is working well, I suggest using this.

Code:
function onSay(cid, words, param, channel)
	local blessings, cost = { 1, 2, 3, 4, 5 }, 10000
	for i = 1, #blessings do
		if(getPlayerBlessing(cid, blessings[i])) then
			doPlayerSendCancel(cid, "You already have all of the blessings.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		elseif(getPlayerMoney(cid) < cost) then
			doPlayerSendCancel(cid, "You do not have enough money.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		else
			doPlayerAddBlessing(cid, blessings[i])
			doPlayerRemoveMoney(cid, cost)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORKS)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased all of the blessings.")
		end
		return true
	end
end
 
Last edited:
This is working well, I suggest using this.

Code:
function onSay(cid, words, param, channel)
	local blessings, cost = { 1, 2, 3, 4, 5 }, 10000
	for i = 1,5 do
		if(getPlayerBlessing(cid, blessings[i])) then
			doPlayerSendCancel(cid, "You already have all of the blessings.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		elseif(getPlayerMoney(cid) < cost) then
			doPlayerSendCancel(cid, "You do not have enough money.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		else
			doPlayerAddBlessing(cid, blessings[i])
			doPlayerRemoveMoney(cid, cost)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORKS)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased all of the blessings.")
		end
		return true
	end
end
oWW, you would only get 1 blessing at a time.
 
Umm no it didn't, I tested it.
13:56 You have purchased all of the blessings.

I changed it anyways.
 
ha yah sorry about that i typo'd when adding code but i see the tool to add it now :$ did any of these help you out?:peace:
Code:
    if getPlayerBlessing(cid) == 5 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You\'re a dumbass, you already bought blessings.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MORTAREA)
    return TRUE
    end
That wouldn't work because getPlayerBlessing(cid, blessing) returns boolean (true/false), and has to be used with parameter blessing (ordinal number of the blessing)
 
Ahh your right i just tried it on my server and it allowed me to buy them twice taking money both times and bestowing blessings i have no idea how to fix that part but if it was fix'd the script would work even better than now :p any idea's?
 
ty everyone,
i was able to combine JDB and JKNOT's code together.
so you don't have to rebuy blessings

Cykotitan you helped too. I'm imensely grateful for the thousands of things you have helped me with.

Code:
function onSay(cid, words, param)
    for i = 1,5 do
		if(getPlayerBlessing(cid, i)) then
			doPlayerSendCancel(cid, "You already have all of the blessings.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return true
		end
	end

    if doPlayerRemoveMoney(cid, 50000) == TRUE then
        for i = 1,5 do
            doPlayerAddBlessing(cid, i)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have pruchased all the blessings!")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_ENERGYAREA)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 50,000 gp in backpack for blessings.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 

Similar threads

Back
Top