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

Klick and ..

vejsa

Banned User
Joined
Nov 3, 2007
Messages
434
Reaction score
0
Hello Im back once again with a diffrent question.. this time I got this problem:
28rhyxz.jpg


When you klick on the "Holes" in this case the 5 red dots, you will recive a backpack of sd or uh or mwall.. wich will cost.. So if any one knows how I can do it.. if its even possible could you maybe help me out?

Thanks :)
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg =
{
    [23001] = {backpackid = 2000, rune = 7618, charges = 1, cost = 1000},
    [23002] = {backpackid = 2001, rune = 7620, charges = 1, cost = 1000},
    [23003] = {backpackid = 2002, rune = 7588, charges = 1, cost = 2000},
    [23004] = {backpackid = 2003, rune = 7589, charges = 1, cost = 1600},
    [23005] = {backpackid = 2004, rune = 7591, charges = 1, cost = 3800},
    [23006] = {backpackid = 5949, rune = 7590, charges = 1, cost = 2400},
    [23007] = {backpackid = 1998, rune = 8472, charges = 1, cost = 3800},
    [23008] = {backpackid = 1999, rune = 8473, charges = 1, cost = 6200},
    [23009] = {backpackid = 3940, rune = 2268, charges = 7, cost = 6520},
    [23010] = {backpackid = 7342, rune = 2293, charges = 7, cost = 7000},
    [23011] = {backpackid = 10519, rune = 2260, charges = 1, cost = 200}
}
-- Variables --
local price = cfg[item.uid].cost
local types = cfg[item.uid].rune
local count = cfg[item.uid].charges
local bag = cfg[item.uid].backpackid
local name = getItemNameById(types)
local backpack_weight = getItemWeightById(bag,1)
local potions_weight = getItemWeightById(types,20)
local total_weight = backpack_weight + potions_weight
-- End --

	if getPlayerMoney(cid) > price then
		if getPlayerFreeCap(cid) > total_weight then
			addBackpack = doCreateItemEx(bag,1)
			for i=1,20 do
				doAddContainerItem(addBackpack, types, count)
			end
			local addItemToPlayer = doPlayerAddItemEx(cid, addBackpack , 0)
			if addItemToPlayer == RETURNVALUE_NOERROR then
				doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
				doSendAnimatedText(fromPosition, "Bought!", TEXTCOLOR_RED)
				doPlayerRemoveMoney(cid, price)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. price .." gold.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. total_weight .." oz. to take a backpack of ".. name .."s.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. price .." gold coins for a backpack of ".. name .."s.")
	end

	return TRUE
end
 
The script goes to actions/scripts/something.lua

and in actions.xml:
Code:
<action uniqueid="23001-23011" event="script" value="something.lua"/>
also you have to add all the unique ids in the mapeditor on that red dots
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg =
{
    [23001] = {backpackid = 2000, rune = 7618, charges = 1, cost = 1000},
    [23002] = {backpackid = 2001, rune = 7620, charges = 1, cost = 1000},
    [23003] = {backpackid = 2002, rune = 7588, charges = 1, cost = 2000},
    [23004] = {backpackid = 2003, rune = 7589, charges = 1, cost = 1600},
    [23005] = {backpackid = 2004, rune = 7591, charges = 1, cost = 3800},
    [23006] = {backpackid = 5949, rune = 7590, charges = 1, cost = 2400},
    [23007] = {backpackid = 1998, rune = 8472, charges = 1, cost = 3800},
    [23008] = {backpackid = 1999, rune = 8473, charges = 1, cost = 6200},
    [23009] = {backpackid = 3940, rune = 2268, charges = 7, cost = 6520},
    [23010] = {backpackid = 7342, rune = 2293, charges = 7, cost = 7000},
    [23011] = {backpackid = 10519, rune = 2260, charges = 1, cost = 200}
}
-- Variables --
local price = cfg[item.uid].cost
local types = cfg[item.uid].rune
local count = cfg[item.uid].charges
local bag = cfg[item.uid].backpackid
local name = getItemNameById(types)
local backpack_weight = getItemWeightById(bag,1)
local potions_weight = getItemWeightById(types,20)
local total_weight = backpack_weight + potions_weight
-- End --

	if getPlayerMoney(cid) > price then
		if getPlayerFreeCap(cid) > total_weight then
			addBackpack = doCreateItemEx(bag,1)
			for i=1,20 do
				doAddContainerItem(addBackpack, types, count)
			end
			local addItemToPlayer = doPlayerAddItemEx(cid, addBackpack , 0)
			if addItemToPlayer == RETURNVALUE_NOERROR then
				doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
				doSendAnimatedText(fromPosition, "Bought!", TEXTCOLOR_RED)
				doPlayerRemoveMoney(cid, price)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. price .." gold.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, [B][COLOR="Red"]"You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.")[/COLOR][/B]
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. total_weight .." oz. to take a backpack of ".. name .."s.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. price .." gold coins for a backpack of ".. name .."s.")
	end

	return TRUE
end
"You don\'t need this here."
unless you do it like this;
'You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.'
 
and if i want to add like mana fluids, or health pots.. what do i write insted of "runes" ? like this:
Code:
[23008] = {backpackid = 2000, fluid = 8476, charges = 1, cost = 5500},
?
 
"You don\'t need this here."
unless you do it like this;
'You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.'

I propably had ' ' in beta version of this script, this is a reason why xP You're Right.

@up

LUA:
    [UID] = {backpackid = BP_ID, rune = FLUID/RUNE_ID, charges = IF_RUNE_THEN_CHARGES, cost = COST_IN_GP},

And ofcourse

'You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.'

you meant
Code:
'You don\'t have enough space in your backpack to put there a backpack of [COLOR="Red"][B]'[/B][/COLOR].. name ..[COLOR="Red"][B]'[/B][/COLOR]s.'
 
Last edited:
Back
Top