• 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 Lever shop

skenchu

New Member
Joined
Mar 14, 2009
Messages
218
Reaction score
0
Location
Holland, Rotterdam
im using a lever shop i copy the script from otland.net

i added only 3 items at it and now it say: [error -luascriptinterface::loadfile] data/actions/scripts/runes.lua:9 ') expected (to close '(' at line "2) near '['
[warning - event::loadscript] cannot load script (data/actions/scripts/runes.lua}
data/actions/scripts/runes.lua:9:')' expted (to close '(' at line 2) near '['


This script i use now for it:

Lua:
 function onUse(cid, item, fromPosition, itemEx, toPosition)
	local shop = {
		[1000] = {
			id = 2268, container = 2003, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1001] = {
			id = 2273, container = 2002, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
		[1002] = {
			id = 2304, container = 2000, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
		[1003] = {
			id = 2313, container = 2001, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
		[1004] = {
			id = 2280, container = 1995, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
	}
	local v = shop[item.actionid]
	local weight = getItemWeightById(v.id, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
	if(getPlayerFreeCap(cid) >= weight) then
		if(getPlayerMoney(cid) >= v.cost) then
			local bp = doCreateItemEx(cid, v.container, 1)
			if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
				doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
			else
				for i = 1, tonumber(getItemInfo(v.container).maxItems) do
					doAddContainerItem(bp, v.id, v.charges or 1)
				end
				doPlayerRemoveMoney(cid, v.cost)
				doSendMagicEffect(getThingPos(cid), v.effect)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have purchased a backpack of " .. getItemInfo(v.id).plural .. ".")
			end
		else
			doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold.")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you need " .. weight:format("%.2f") .. " oz. to carry this container of " .. getItemInfo(v.id).plural .. ".")
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local shop = {
		[1000] = {
			id = 2268, container = 2003, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1001] = {
			id = 2273, container = 2002, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1002] = {
			id = 2304, container = 2000, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1003] = {
			id = 2313, container = 2001, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1004] = {
			id = 2280, container = 1995, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
	}
	local v = shop[item.actionid]
	local weight = getItemWeightById(v.id, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
	if(getPlayerFreeCap(cid) >= weight) then
		if(getPlayerMoney(cid) >= v.cost) then
			local bp = doCreateItemEx(cid, v.container, 1)
			if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
				doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
			else
				for i = 1, tonumber(getItemInfo(v.container).maxItems) do
					doAddContainerItem(bp, v.id, v.charges or 1)
				end
				doPlayerRemoveMoney(cid, v.cost)
				doSendMagicEffect(getThingPos(cid), v.effect)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have purchased a backpack of " .. getItemInfo(v.id).plural .. ".")
			end
		else
			doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold.")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you need " .. weight:format("%.2f") .. " oz. to carry this container of " .. getItemInfo(v.id).plural .. ".")
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top