• 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] Script Problem

Status
Not open for further replies.

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
Sup guys.
I'm using this script:

Lua:
local cost = 1000000
local newItem = {7388, 1}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        if doPlayerRemoveMoney(cid, cost) == FALSE then
                doPlayerSendTextMessage(cid, 26, "You need "..cost.." gold coins for "..newItem[2].."x "..getItemNameById(newItem[1])..".")
                doSendMagicEffect(getCreaturePosition(cid), 2)
                return TRUE
        end
       
        if item.itemid == 1945 then
                doTransformItem(item.uid, 1946)
        else
                doTransformItem(item.uid, 1945)
        end

        doPlayerAddItem(cid, newItem[1], newItem[2])
        doPlayerSendTextMessage(cid, 22, "You bought "..newItem[2].."x "..getItemNameById(newItem[1]).." for "..cost..".")
        return TRUE
end

for shop levers but the problem is even if the player doesnt have money to buy the item he will get the item anyway ...

Example: You dont got money and you still get the item without paying.

Can some1 help me fixing it?

Thanks for every1 that helps
Rep++ for every1 that helps to.

Regards
Lava Titan
 
What are you trying to do now?
If you remove 2 items, you get something else?
 
Lua:
local coin = 9770
local items = {
	[1002] = {item_id = 5785, count = 1, coins = 50},
	[1003] = {item_id = 5785, count = 1, coins = 50}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (doPlayerRemoveItem(cid, coin, items[item.uid].coins) == true) then
		doPlayerAddItem(cid, items[item.uid].item_id, items[item.uid].count)
		doPlayerSendTextMessage(cid, 22, "You have purchased ".. getItemNameById(items[item.uid].item_id) ..".")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
	else
		doPlayerSendCancel(cid, "You do not have sufficient funds.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	end
	return true
end

Not tested of course, good luck. :p
 
Try this. then you click on 9770 you will get other item... do wanted that?

Code:
local item1 = {xxxx}  -- item id what you should get by coin

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 9770 then -- coin item id
			count = 1
		end
		doPlayerAddItem(cid, item1, count)
	end
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
	return TRUE
end
 
Make the lever 1001 UNIQUE ID. ;)

Lua:
local coin = 9770
local items = {
    [1001] = {id=5785, count=1, coins=50}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (doPlayerRemoveItem(cid, coin, items[item.uid].coins) == true) then
		doPlayerAddItem(cid, items[item.uid].id, items[item.uid].count)
		doSendAnimatedText(getCreaturePosition(cid), "Purchased", TEXTCOLOR_RED)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
	else
		doPlayerSendCancel(cid, "You have insufficient funds.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	end
	return true
end
 
Status
Not open for further replies.
Back
Top