• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Advanced !bless command

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
Hello!
I wrote a script that will buy us a blessing with the command LOLOL. The script buy only blessings for which to be, which fulfills the requirements (premium account) and only those who have not taken out ... When you use a command is sent to us the message of the report, which bought a blessing for which we can not afford that were previously taken out and those that do not meet requirements. I decided to publish it because it is a little more advanced than those of simple, published long ago in the forum.


data/talkactions/scripts/blessing.lua:
PHP:
-- // config // --
local bless = {
	{cost = 10000, premium = "no", name="First"},
	{cost = 10000, premium = "no", name="Second"},
	{cost = 10000, premium = "no", name="Third"},
	{cost = 10000, premium = "yes", name="Fourth"},
	{cost = 10000, premium = "yes", name="Fifth"},

}
-- // end // --



-- // do not touch! // --
local blessings = {}
local cost = 0
local msg = "Blessing buying report: "
-- // Blessing command script by ersiu // --
function onSay(cid, words, param)
	for i, blessing in ipairs(bless) do
		if getPlayerBlessing(cid, i) == TRUE then
			if doPlayerRemoveMoney(cid, blessing.cost) == TRUE then
				if (isPremium(cid) == TRUE or string.lower(blessing.premium) == "no") then
					msg = msg.."\n "..blessing.name.." bought successfuly"
					cost = cost+blessing.cost
					table.insert(blessing, i)
				else
					msg = msg.."\n "..blessing.name.." not bought, to get you need premium."
				end
			else
				msg = msg.."\n "..blessing.name.." not bought, to get you need "..blessing.cost.." gp."
			end
		else
			msg = msg.."\n "..blessing.name.." already bought."
		end
	end
	
	for _, addBless in ipairs(blessings) do
		doPlayerAddBlessing(cid, addBless)
	end
	
	doPlayerSendTextMessage(cid, 19, msg..".\n Total Cost: "..cost.." gp.")
	return TRUE
end
-- // END // --

data/talkactions/talkactions.xml
PHP:
<talkaction log="no" words="!bless" access="0" event="script" value="blessing.lua"/>

To buy bless use only: !bless

Yours,
Azi.
 
Last edited:
Nice. But I will improve it a bit before using (ofcourse IF I WOULD USE :f).
 
[29/06/2009 02:04:44] Lua Script Error: [TalkAction Interface]
[29/06/2009 02:04:44] data/talkactions/scripts/blessing.lua:eek:nSay

[29/06/2009 02:04:44] data/talkactions/scripts/blessing.lua:38: bad argument #1 to 'ipairs' (table expected, got nil)
[29/06/2009 02:04:44] stack traceback:
[29/06/2009 02:04:44] [C]: in function 'ipairs'
[29/06/2009 02:04:44] data/talkactions/scripts/blessing.lua:38: in function <data/talkactions/scripts/blessing.lua:19>


how to fix? :blink:
 
[02/07/2009 19:27:31] Lua Script Error: [TalkAction Interface]
[02/07/2009 19:27:31] data/talkactions/scripts/blessing.lua:eek:nSay

[02/07/2009 19:27:31] data/talkactions/scripts/blessing.lua:38: bad argument #1 to 'ipairs' (table expected, got nil)
[02/07/2009 19:27:32] stack traceback:
[02/07/2009 19:27:32] [C]: in function 'ipairs'
[02/07/2009 19:27:32] data/talkactions/scripts/blessing.lua:38: in function <data/talkactions/scripts/blessing.lua:19>

[02/07/2009 19:27:36] Lua Script Error: [TalkAction Interface]
[02/07/2009 19:27:37] data/talkactions/scripts/blessing.lua:eek:nSay

[02/07/2009 19:27:37] data/talkactions/scripts/blessing.lua:38: bad argument #1 to 'ipairs' (table expected, got nil)
[02/07/2009 19:27:37] stack traceback:
[02/07/2009 19:27:37] [C]: in function 'ipairs'
[02/07/2009 19:27:37] data/talkactions/scripts/blessing.lua:38: in function <data/talkactions/scripts/blessing.lua:19>
Help
 
Code:
[09/07/2009 03:02:05] Lua Script Error: [TalkAction Interface] 
[09/07/2009 03:02:05] data/talkactions/scripts/blessing.lua:onSay

[09/07/2009 03:02:05] data/talkactions/scripts/blessing.lua:38: bad argument #1 to 'ipairs' (table expected, got nil)
[09/07/2009 03:02:05] stack traceback:
[09/07/2009 03:02:05] 	[C]: in function 'ipairs'
[09/07/2009 03:02:05] 	data/talkactions/scripts/blessing.lua:38: in function <data/talkactions/scripts/blessing.lua:19>

ölolololol
 
Code:
[09/07/2009 03:02:05] Lua Script Error: [TalkAction Interface] 
[09/07/2009 03:02:05] data/talkactions/scripts/blessing.lua:onSay

[09/07/2009 03:02:05] data/talkactions/scripts/blessing.lua:38: bad argument #1 to 'ipairs' (table expected, got nil)
[09/07/2009 03:02:05] stack traceback:
[09/07/2009 03:02:05] 	[C]: in function 'ipairs'
[09/07/2009 03:02:05] 	data/talkactions/scripts/blessing.lua:38: in function <data/talkactions/scripts/blessing.lua:19>

ölolololol

Fixed.
Lua:
-- // config // --
local bless = {
    {cost = 10000, premium = "no", name="First"},
    {cost = 10000, premium = "no", name="Second"},
    {cost = 10000, premium = "no", name="Third"},
    {cost = 10000, premium = "yes", name="Fourth"},
    {cost = 10000, premium = "yes", name="Fifth"},

}
-- // end // --



-- // do not touch! // --
local blessings = {}
local cost = 0
local msg = "Blessing buying report: "
-- // Blessing command script by ersiu // --
function onSay(cid, words, param)
    for i, blessing in ipairs(bless) do
        if getPlayerBlessing(cid, i) == TRUE then
            if doPlayerRemoveMoney(cid, blessing.cost) == TRUE then
                if (isPremium(cid) == TRUE or string.lower(blessing.premium) == "no") then
                    msg = msg.."\n "..blessing.name.." bought successfuly"
                    cost = cost+blessing.cost
                    table.insert(blessing, i)
                else
                    msg = msg.."\n "..blessing.name.." not bought, to get you need premium."
                end
            else
                msg = msg.."\n "..blessing.name.." not bought, to get you need "..blessing.cost.." gp."
            end
        else
            msg = msg.."\n "..blessing.name.." already bought."
        end
    end
    
    for _, addBless in ipairs(blessings) do
        doPlayerAddBlessing(cid, addBless)
    end
    
    doPlayerSendTextMessage(cid, 19, msg..".\n Total Cost: "..cost.." gp.")
    return TRUE
end
-- // END // --

@ Azi:
Change..
Lua:
    for _, addBless in ipairs(blessing) do
        doPlayerAddBlessing(cid, addBless)
    end
..to..
Lua:
    for _, addBless in ipairs(blessings) do
        doPlayerAddBlessing(cid, addBless)
    end

(blessings)

Regards,
Shawak
 
Back
Top