• 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 Buy Addon Talkaction Request

Norix

Hosting Service !
Joined
Jan 18, 2008
Messages
544
Reaction score
9
Location
Germany
Hi
I have a buyaddon talkaction. On TFS 0.2 it worked perfectly, but on 0.3.2 it doesnt work. No errors, no reaction, just nothing.. plz help :(
Code:
local config = {
    payment = 5952,  -- ID of Item which you need to get one addon.
    amount = 1,      -- Amount of Item which you need to get one addon.
    addons = { -- Addon Name, Addon ID, Addon ID, Addon Type, Storage
		["first citizen"] = { 136, 128, 1, 10001 },
		["second citizen"] = { 136, 128, 2, 10002 },
		["first hunter"] = { 137, 129, 1, 20001 },
		["second hunter"] = { 137, 129, 2, 20002 },
		["first knight"] = { 139, 131, 1, 300001 },
		["second knight"] = { 139, 131, 2, 300002 },
		["first mage"] = { 138, 130, 1, 40001 },
		["second mage"] = { 138, 130, 2, 40002 },
		["first summoner"] = { 141, 133, 1, 50001 },
		["second summoner"] = { 141, 133, 2, 50002 },
		["first barbarian"] = { 147, 143, 1, 60001 },
		["second barbarian"] = { 147, 143, 2, 60002 },
		["first druid"] = { 148, 144, 1, 70001 },
		["second druid"] = { 148, 144, 2, 70002 },
		["first nobleman"] = { 140, 132, 1, 80001 },
		["second nobleman"] = { 140, 132, 2, 80002 },
		["first oriental"] = { 150, 146, 1, 99001 },
		["second oriental"] = { 150, 146, 2, 90002 },
		["first warrior"] = { 142, 134, 1, 100001 },
		["second warrior"] = { 142, 134, 2, 100002 },
		["first wizard"] = { 145, 149, 1, 110001 },
		["second wizard"] = { 145, 149, 2, 110002 },
		["first assassin"] = { 156, 152, 1, 120001 },
		["second assassin"] = { 156, 152, 2, 120002 },
		["first beggar"] = { 157, 153, 1, 130001 },
		["second beggar"] = { 157, 153, 2, 130002 },
    }
}



function onSay(cid, words, param)
	for name, pos in pairs(config.addons) do
		if param == name then
			if getPlayerItemCount(cid,config.payment) >= config.amount then
				addon = getPlayerStorageValue(cid,pos[4])
				if addon == -1 then
					doPlayerAddOutfit(cid, pos[1], pos[3])
					doPlayerAddOutfit(cid, pos[2], pos[3])
					doPlayerRemoveItem(cid,config.payment,config.amount)
					setPlayerStorageValue(cid,pos[4],1)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought the " .. param .. " addon.")
				else
					doPlayerSendCancel(cid, "You already have this addon.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
			else
				doPlayerSendCancel(cid, "You don't have a addon scroll to buy this addon.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
		end
	end
	return TRUE
end

Thanks in advance

Your's ballack13
 
Try with this one, i only changed 1 if work, you can do the rest ^^

PHP:
function onSay(cid, words, param)
  local config = {
    payment = 5952,  -- ID of Item which you need to get one addon.
    amount = 1,      -- Amount of Item which you need to get one addon.
    addons = { -- Addon Name, Addon ID, Addon ID, Addon Type, Storage
    ["firstcitizen"] = { male = 136, female = 128, addon = 1, storage = 10001 },
    }
}
  for name, pos in pairs(config.addons) do
    if param == "name" then
      if getPlayerItemCount(cid,config.payment) >= config.amount then
        addon = getPlayerStorageValue(cid,pos[4])
        if addon == -1 then
          doPlayerAddOutfit(cid, config.male, config.addon)
          doPlayerAddOutfit(cid, config.female, config.addon)
          doPlayerRemoveItem(cid,config.payment,config.amount)
          setPlayerStorageValue(cid, config.storage, TRUE)
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have bought the " .. param .. " addon.")
        else
          doPlayerSendCancel(cid, "You already have this addon.")
          doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
      else
        doPlayerSendCancel(cid, "You dont have a addon scroll to buy this addon.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
      end
    end
  end
  return TRUE
end
 
Better idea make by coin?
Code:
function onSay(cid, words, param)
	removenugget = doPlayerRemoveItem(cid, xxx, 1) -- ID of your donate coin
		if removenugget == 1 then
		doPlayerAddOutfit(cid, 136, 2)
		doPlayerAddOutfit(cid, 137, 2)							doPlayerAddOutfit(cid, 138, 2)
		doPlayerAddOutfit(cid, 139, 2)							doPlayerAddOutfit(cid, 140, 2)
		doPlayerAddOutfit(cid, 141, 2)							doPlayerAddOutfit(cid, 142, 2)
		doPlayerAddOutfit(cid, 147, 2)							doPlayerAddOutfit(cid, 148, 2)
		doPlayerAddOutfit(cid, 149, 2)							doPlayerAddOutfit(cid, 150, 2)
		doPlayerAddOutfit(cid, 155, 2)							doPlayerAddOutfit(cid, 156, 2)
		doPlayerAddOutfit(cid, 157, 2)							doPlayerAddOutfit(cid, 158, 2)
		doPlayerAddOutfit(cid, 252, 2)							doPlayerAddOutfit(cid, 269, 2)
		doPlayerAddOutfit(cid, 270, 2)							doPlayerAddOutfit(cid, 279, 2)
		doPlayerAddOutfit(cid, 128, 2)
		doPlayerAddOutfit(cid, 129, 2)							doPlayerAddOutfit(cid, 131, 2)							doPlayerAddOutfit(cid, 132, 2)
		doPlayerAddOutfit(cid, 133, 2)							doPlayerAddOutfit(cid, 134, 2)
		doPlayerAddOutfit(cid, 143, 2)							doPlayerAddOutfit(cid, 144, 2)
		doPlayerAddOutfit(cid, 145, 2)							doPlayerAddOutfit(cid, 146, 2)
		doPlayerAddOutfit(cid, 151, 2)							doPlayerAddOutfit(cid, 152, 2)
		doPlayerAddOutfit(cid, 153, 2)							doPlayerAddOutfit(cid, 154, 2)
		doPlayerAddOutfit(cid, 251, 2)							doPlayerAddOutfit(cid, 268, 2)
		doPlayerAddOutfit(cid, 273, 2)							doPlayerAddOutfit(cid, 278, 2)
		doPlayerAddOutfit(cid, 136, 1)
		doPlayerAddOutfit(cid, 137, 1)							doPlayerAddOutfit(cid, 138, 1)
		doPlayerAddOutfit(cid, 139, 1)							doPlayerAddOutfit(cid, 140, 1)
		doPlayerAddOutfit(cid, 141, 1)							doPlayerAddOutfit(cid, 142, 1)
		doPlayerAddOutfit(cid, 147, 1)							doPlayerAddOutfit(cid, 148, 1)
		doPlayerAddOutfit(cid, 149, 1)							doPlayerAddOutfit(cid, 150, 1)
		doPlayerAddOutfit(cid, 155, 1)							doPlayerAddOutfit(cid, 156, 1)
		doPlayerAddOutfit(cid, 157, 1)							doPlayerAddOutfit(cid, 158, 1)
		doPlayerAddOutfit(cid, 152, 1)							doPlayerAddOutfit(cid, 169, 1)
		doPlayerAddOutfit(cid, 170, 1)							doPlayerAddOutfit(cid, 179, 1)
		doPlayerAddOutfit(cid, 128, 1)
		doPlayerAddOutfit(cid, 129, 1)							doPlayerAddOutfit(cid, 130, 1)
		doPlayerAddOutfit(cid, 131, 1)							doPlayerAddOutfit(cid, 132, 1)
		doPlayerAddOutfit(cid, 133, 1)							doPlayerAddOutfit(cid, 134, 1)
		doPlayerAddOutfit(cid, 143, 1)							doPlayerAddOutfit(cid, 144, 1)
		doPlayerAddOutfit(cid, 145, 1)							doPlayerAddOutfit(cid, 146, 1)
		doPlayerAddOutfit(cid, 151, 1)							doPlayerAddOutfit(cid, 152, 1)
		doPlayerAddOutfit(cid, 153, 1)							doPlayerAddOutfit(cid, 154, 1)
		doPlayerAddOutfit(cid, 151, 1)							doPlayerAddOutfit(cid, 168, 1)
		doPlayerAddOutfit(cid, 173, 1)							doPlayerAddOutfit(cid, 178, 1)
		doPlayerAddOutfit(cid, 273, 1)							doPlayerAddOutfit(cid, 251, 1)
		doPlayerAddOutfit(cid, 268, 1)


		doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have purchased your set of addons!  Thank you for donating!")
	else
		doPlayerSendCancel(cid, "You do not have enough Donate Coins.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end

If i helped you don't remember

REP++ :D
 
try
Code:
local config = {
    payment = 5952,  -- ID of Item which you need to get one addon.
    amount = 1,      -- Amount of Item which you need to get one addon.
    addons = { -- Addon Name, Addon ID, Addon ID, Addon Type, Storage
        ["first citizen"]    = { 136, 128, 1, 10001 },
        ["second citizen"]    = { 136, 128, 2, 10002 },
        ["first hunter"]    = { 137, 129, 1, 20001 },
        ["second hunter"]    = { 137, 129, 2, 20002 },
        ["first knight"]    = { 139, 131, 1, 300001 },
        ["second knight"]    = { 139, 131, 2, 300002 },
        ["first mage"]        = { 138, 130, 1, 40001 },
        ["second mage"]        = { 138, 130, 2, 40002 },
        ["first summoner"]    = { 141, 133, 1, 50001 },
        ["second summoner"]    = { 141, 133, 2, 50002 },
        ["first barbarian"]    = { 147, 143, 1, 60001 },
        ["second barbarian"]= { 147, 143, 2, 60002 },
        ["first druid"]        = { 148, 144, 1, 70001 },
        ["second druid"]    = { 148, 144, 2, 70002 },
        ["first nobleman"]    = { 140, 132, 1, 80001 },
        ["second nobleman"]    = { 140, 132, 2, 80002 },
        ["first oriental"]    = { 150, 146, 1, 99001 },
        ["second oriental"]    = { 150, 146, 2, 90002 },
        ["first warrior"]    = { 142, 134, 1, 100001 },
        ["second warrior"]    = { 142, 134, 2, 100002 },
        ["first wizard"]    = { 145, 149, 1, 110001 },
        ["second wizard"]    = { 145, 149, 2, 110002 },
        ["first assassin"]    = { 156, 152, 1, 120001 },
        ["second assassin"]    = { 156, 152, 2, 120002 },
        ["first beggar"]    = { 157, 153, 1, 130001 },
        ["second beggar"]    = { 157, 153, 2, 130002 },
    }
}

function onSay(cid, words, param)
    local addons = config.addons[param:lower()]
    if(not addons) then
        doPlayerSendCancel(cid, "The specefied addon does not exist.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    elseif getPlayerItemCount(cid,config.payment) >= config.amount then
        local addon = getPlayerStorageValue(cid,pos[4])
        if addon == -1 then
            doPlayerAddOutfit(cid, pos[1], pos[3])
            doPlayerAddOutfit(cid, pos[2], pos[3])
            doPlayerRemoveItem(cid, config.payment, config.amount)
            setPlayerStorageValue(cid, pos[4], 1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought the " .. param .. " addon.")
        else
            doPlayerSendCancel(cid, "You already have this addon.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    else
        doPlayerSendCancel(cid, "You don't have a addon scroll to buy this addon.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
Back
Top