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

Action Perfect Addon Lever!

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
Hello, today I wanted to present to you the script, which gives us the addons for the items, using the drag lever.
The script is distinguished by unique features ...
A first of which is that items can be placed in
not turn stackpos, and the second is that by double-clicking to show us a list of addons and items that are needed to get the addon.

Items needed addons and you have set themselves in Config, because I do not have the time ... :)

data/actions/scripts/addons.lua:
PHP:
	local addons = { -- addons setting
		{
		which="Second",
		name="Citizen",
		addon = 2,
		outfits = {128,136},
		storage=9100,
		items = {
			{5890, 100},
			{5902, 50}
			}
		},
		
		{
		which="First",
		name="Citizen",
		addon = 1,
		outfits = {128,136},
		storage=9101,
		items = {
			{5910, 100},
			{5911, 50},
			{5912, 75}
			}
		}, 
	
	}
local config = {
	itemsPos = {986, 1080, 7}, --  items table position
	stackpos = {2,3,4,5,6,7,8,9,10} -- stackpos to scan for items.
}
local addonID = 0
local getItems = 0
local timer = (timer~=nil) and timer or 0
local str=""
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPremium(cid) == FALSE then
		doPlayerSendCancel(cid, "Sorry, only premium players may use addon lever.")
		return TRUE
	end
	
	for id,addon in ipairs(addons) do
		local needItems = #addon.items
		for i=1, #addon.items do
			for j=1,#config.stackpos do
				local getAddonItems = getThingfromPos({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3],stackpos=config.stackpos[j]})
				if getAddonItems.itemid > 0 then
					if addon.items[i][1] == getAddonItems.itemid and addon.items[i][2] == getAddonItems.type then
						getItems = getItems+1
						break
					end
				end
			end
			if getItems == needItems then
				addonID = id
				break
			end
		end
	end
	
	
	if addonID ~= 0 then
		if getPlayerStorageValue(cid,addons[addonID].storage) == -1 then	
			for i=1,getItems do
				local getItem = getThingfromPos({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3],stackpos=2})
				if getItem.itemid > 0 then
					doRemoveItem(getItem.uid,getItem.type)
				else
					break
				end
			end
			setPlayerStorageValue(cid,addons[addonID].storage,1)
			for i=1, #addons[addonID].outfits do
				doPlayerAddOutfit(cid,addons[addonID].outfits[i],addons[addonID].addon)
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, You have unlocked "..addons[addonID].which.." "..addons[addonID].name.." addon!")
			doSendMagicEffect({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3]}, CONST_ME_HITBYFIRE)
			if(item.itemid == 1945) then
				doTransformItem(item.uid, 1946)
			elseif(item.itemid == 1946) then
				doTransformItem(item.uid, 1945)
			end
		else
			doPlayerSendCancel(cid, "You arleady have "..addons[addonID].which.." "..addons[addonID].name.." addon!")
		end
	else
		if (os.time()-timer) > 0 then
			timer = os.time()
			doPlayerSendCancel(cid, "Please collect items for addon and go back!")
		else
			timer = 0
			for _, i in ipairs(addons) do
				local status = (getPlayerStorageValue(cid,i.storage) == 1) and " (done) " or ""
				str=str..i.which.." "..i.name.." addon"..status..":"
				for _, j in ipairs(i.items) do
					str=str.."\n - "..j[2].." "..getItemNameById(j[1])
				end
				str=str.."\n\n"
			end
			doShowTextDialog(cid, 6579, str)
		end
	end
	str = ""
	getItems = 0
	addonID = 0
	return TRUE
end

and in data/actions/actions.xml:
PHP:
<action uniqueid="9456" event="script" value="addons.lua"/>
now place in map lever with unique id: 9456 and next from lever table to put items!

Yours,
Azi.
 
Hello. How I can change script to get any addons?
Etc. One Lever can give all addons , not only Citizen?
 
I add next addon - hunter. But when i take items for hunter addon script give me addon citizen.
Who know how I can add in this script all addon?


Code:
local addons = { -- addons setting
        {
        which="Second",
        name="Citizen",
        addon = 2,
        outfits = {128,136},
        storage=9100,
        items = {
            {5890, 100}, -- Chikken Feather
            {5902, 50}     -- Honey Comb
            }
        },
        
        {
        which="First",
        name="Citizen",
        addon = 1,
        outfits = {128,136},
        storage=9101,
        items = {
            {5910, 100} -- Minotaur Leather
            }
        },
        
        {
        which="Second",
        name="Hunter",
        addon = 2,
        outfits = {129,137},
        storage=9102,
        items = {
            {5876, 100}, -- Lizard Leather
            {5948, 100}     -- Red Dragon Leather
            }
        },
        
        {
        which="First",
        name="Hunter",
        addon = 1,
        outfits = {129,137},
        storage=9103,
        items = {
            {5880, 100} -- Sniper Gloves
            }
        },
        
    
    }
local config = {
    itemsPos = {1904, 1235, 6}, --  items table position
    stackpos = {1,2,3,4,5,6,7,8,9,10} -- stackpos to scan for items.
}
local addonID = 0
local getItems = 0
local timer = (timer~=nil) and timer or 0
local str=""
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isPremium(cid) == FALSE then
        doPlayerSendCancel(cid, "Sorry, only premium players may use addon lever.")
        return TRUE
    end
    
    for id,addon in ipairs(addons) do
        local needItems = #addon.items
        for i=1, #addon.items do
            for j=1,#config.stackpos do
                local getAddonItems = getThingfromPos({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3],stackpos=config.stackpos[j]})
                if getAddonItems.itemid > 0 then
                    if addon.items[i][1] == getAddonItems.itemid and addon.items[i][2] == getAddonItems.type then
                        getItems = getItems+1
                        break
                    end
                end
            end
            if getItems == needItems then
                addonID = id
                break
            end
        end
    end
    
    
    if addonID ~= 0 then
        if getPlayerStorageValue(cid,addons[addonID].storage) == -1 then   
            for i=1,getItems do
                local getItem = getThingfromPos({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3],stackpos=1})
                if getItem.itemid > 0 then
                    doRemoveItem(getItem.uid,getItem.type)
                else
                    break
                end
            end
            setPlayerStorageValue(cid,addons[addonID].storage,1)
            for i=1, #addons[addonID].outfits do
                doPlayerAddOutfit(cid,addons[addonID].outfits[i],addons[addonID].addon)
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, You have unlocked "..addons[addonID].which.." "..addons[addonID].name.." addon!")
            doSendMagicEffect({x=config.itemsPos[1],y=config.itemsPos[2],z=config.itemsPos[3]}, CONST_ME_HITBYFIRE)
            if(item.itemid == 1945) then
                doTransformItem(item.uid, 1946)
            elseif(item.itemid == 1946) then
                doTransformItem(item.uid, 1945)
            end
        else
            doPlayerSendCancel(cid, "You arleady have "..addons[addonID].which.." "..addons[addonID].name.." addon! Or your items are not in exact quantity!!!")
        end
    else
        if (os.time()-timer) > 0 then
            timer = os.time()
            doPlayerSendCancel(cid, "Please collect items for addon and go back!")
        else
            timer = 0
            for _, i in ipairs(addons) do
                local status = (getPlayerStorageValue(cid,i.storage) == 1) and " (done) " or ""
                str=str..i.which.." "..i.name.." addon"..status..":"
                for _, j in ipairs(i.items) do
                    str=str.."\n - "..j[2].." "..getItemNameById(j[1])
                end
                str=str.."\n\n"
            end
            doShowTextDialog(cid, 6579, str)
        end
    end
    str = ""
    getItems = 0
    addonID = 0
    return TRUE
end
 
Back
Top