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

[Help] click and buy system (single item)

Zerville

New Member
Joined
Sep 19, 2008
Messages
47
Reaction score
0
How can i do in a click and buy system to get only 1 single item and no bps or such? :confused:

This is with a bp:
Code:
function onUse(cid, item, frompos, item2, topos)
req = 45
cost = 6000
container = doPlayerAddItem(cid, 2003, 1)

if item.itemid == 1285 and doPlayerRemoveMoney(cid,cost) == 1 and getPlayerLevel(cid) >= req then
	for i = 1,20 do
	doAddContainerItem(container, 2268, 5)
	doPlayerSendTextMessage(cid, 24, "You bought a bp of runes")
	doSendMagicEffect(topos,12)
	end
 
else
doPlayerSendCancel(cid,"A backpack of rune costs 6000 gps.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

return 1
end
 
Code:
function onUse(cid, item, frompos, item2, topos)
req = 45
cost = 6000
item = xxxx
item_c = 1
container = doPlayerAddItem(cid, 2003, 1)

if item.itemid == 1285 and doPlayerRemoveMoney(cid,cost) == 1 and getPlayerLevel(cid) >= req then
	doPlayerAddItem(cid, item, item_c)
	doSendMagicEffect(topos,12)
	end
 
else
doPlayerSendCancel(cid,getItemNameById(item).." cost "..cost)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

return 1
end

If you are using tfs 0.2 change getItemNameById to getItemName
 
[15/10/2008 21:03:31] Warning: [Event::loadScript] Can not load script. data/actions/scripts/shop/amulet of loss.lua
[15/10/2008 21:03:31] data/actions/scripts/shop/amulet of loss.lua:12: 'end' expected (to close 'function' at line 1) near 'else'

About the same happened when I tried myself <_<
 
I wasnt looking for bugs before, here you got it fixed:
Code:
function onUse(cid, item, frompos, item2, topos)
    local req = 45
    local cost = 6000
    local item = xxxx
    local item_c = 1
    if item.itemid == 1285 and doPlayerRemoveMoney(cid,cost) == 1 and getPlayerLevel(cid) >= req then
        doPlayerAddItem(cid, item, item_c)
	doSendMagicEffect(topos,12)
    else
        doPlayerSendCancel(cid,getItemNameById(item).." cost "..cost)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
Ok i will just take this in the same thread

With this script all works fine, I get a bp of 20 great spririt potions but i want it to msg me the item name when i buy, it does too... BUT It looks for the items I bought so it msges me 20 times rofl.
Possible to do this in another way or fix it? :p
Code:
		doPlayerSendTextMessage(cid, 24, "You bought a bp of "..getItemName(pot).."s.")
Code:
function onUse(cid, item, frompos, item2, topos)

req = 80
cost = 3800
pot = 8472
itemc = 1
bp = 1988

if item.itemid == 1285 and doPlayerRemoveMoney(cid,cost) == 1 then
	if getPlayerLevel(cid) >= req then
		container = doPlayerAddItem(cid, bp, 1)
		for i = 1,20 do
		doAddContainerItem(container, pot, itemc)
		doPlayerSendTextMessage(cid, 24, "You bought a bp of "..getItemName(pot).."s.")
		doSendMagicEffect(topos,12)
		end
	else
		doPlayerSendCancel(cid,"You need lvl: ".. req .." or more for this.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendCancel(cid,"You need ".. cost .." gps for that.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		end
	return 1
end
 
Try with
`
Code:
		doPlayerSendTextMessage(cid, 24, "You bought a bp of "..getItemNameById(pot).."s.")
 
As I can see your script is just for one type of potion, you dont need to do it like that then, just replace:
"..getItemName(pot).."
with the item name, health potion, or w/e it is.
 
No i figured out the problem... it was the "for i = 1, 20 do" so i just putted the msg thinga before that line and it worked fine. :)
Thx
 
Back
Top