• 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 Furniture lever shop

fracek91

Member
Joined
May 30, 2008
Messages
423
Reaction score
8
Hi, I wanted to make a furniture shop for my ot where players can see the items before they buy. So it looks like this (note: players can't step onto levers so there's only one position from which they can use lever, that's item's position + 0x,2y,0z)
furnishop.jpg


Next, I've made an action script, but I didn't know what to put in at least to places (they're bold), and please don't complain about that text in polish, that's just info that you bought/error occured. Item id's are from constructionkit.lua, but reversed, with doubles removed.
Code:
local CONSTRUCTIONS = {
	[1650] = 3901 , [1658] = 3902, [1666] = 3903, [1670] = 3904, [3813] = 3905, [3817] = 3906, [2093] = 3907, [2603] = 3908, [1614] = 3909, [1615] = 3910,
	[1616] = 3911, [1619] = 3912, [3805] = 3913, [3807] = 3914, [1740] = 3915, [1774] = 3916, [2084] = 3917, [2095] = 3918, [3809] = 3919, [3832] = 3920,
	[1714] = 3921, [2107] = 3922, [2104] = 3923, [7670] = 3924, [2080] = 3926, [2098] = 3927, [1676] = 3928, [2101] = 3929, [1739] = 3930,
	[2105] = 3931, [1724] = 3932, [1728] = 3933, [1732] = 3934, [1775] = 3935, [3812] = 3936, [2064] = 3937, [6371] = 3938, [1738] = 5086, [1741] = 5087, [1770] = 5088,
	[2106] = 6114, [2034] = 6115, [3811] = 6372, [1736] = 6373, [1750] = 7503, [5928] = 7700, [3821] = 7960, [2582] = 7962, [8688] = 8692, [7486] = 8693
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

playerpos = getPlayerPosition(cid)
[B]itempos = {playerposx,playerposy-2,playerposz,stackpos=1}
getitem = getthingfrompos(itempos)[/B]


[B]if(isInArray(CONSTRUCTIONS, getitem.itemid) == TRUE)[/B] then
	if(doPlayerRemoveMoney(cid, 100000) == TRUE) then
	doPlayerAddItem(cid,CONSTRUCTIONS[getitem.itemid],1)
	doSendMagicEffect(fromPosition, CONST_ME_HEARTS)
	else
	doPlayerSendTextMessage(cid, 22, "Potrzeba 100k zeby kupic ten przedmiot.")
	end
else
doPlayerSendTextMessage(cid, 22, "Jezeli widzisz te wiadomosc to cos poszlo zle. Zglos to do admina.")
end
	return true
end
 
Last edited:
Yeah, I know I can name them properly in items.xml, but I'd prefer this option, it'd allow people to see what they buy before they buy.See... every lever has the same action id so I want it to look like this:
-Function selects id of item which position is player position -(0x,2y,0z)
-It finds which id of kit is equal to id of that item
-It gives player the kit.

Is it really hard to make it? I thought It's easy and the only problem were those two bold parts


why do you need it from one position only? ;o does it matter

I think it matters because script can take player's position and then it finds what is 2 squares to the north and select its ID. Hope you understand.

btw would it work?

Code:
itempos = playerpos - {x=0,y=2,z=0}
 
Last edited:
Back
Top