• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Need help with script to buy potion with lever without a bp tfs 8.60

Eternal Life

New Member
Joined
May 15, 2011
Messages
148
Reaction score
1
Location
Aguadilla,Puerto Rico
Hello... I need help with a script that when a player uses it, it gives you potions without a bp, since is 8.60 there is no bp needed couse they all stack in one.

I have this script:

function getPlayerMoney(cid)
gold = getPlayerItemCount(cid,2148)
plat = getPlayerItemCount(cid,2152)*100
crys = getPlayerItemCount(cid,2160)*10000
money = gold + plat + crys
return money
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerMoney(cid) >= 2160 then
doPlayerRemoveMoney(cid,100)
doPlayerAddItem(cid,2002,1)
doSendMagicEffect(getPlayerPosition(cid), 13)
else
doPlayerSendTextMessage(cid,19,"You dont have enough money.")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return TRUE
end

It says there is an error near were it says getplayermoney

Can you guys fix this script?

Thank you for your support!
 
What does this really do? ;p

It looks like , when you use a item it withdraw 100cc and give you 1x of itemid 2002?

Or do you want command to give you x charges potion for money?
 
here is the pot one:

function getPlayerMoney(cid)
gold = getPlayerItemCount(cid,2148)
plat = getPlayerItemCount(cid,2152)*100
crys = getPlayerItemCount(cid,2160)*10000
money = gold + plat + crys
return money
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerMoney(cid) >= 2160 then
doPlayerRemoveMoney(cid,4500)
doPlayerAddItem(cid,7618,100)
doSendMagicEffect(getPlayerPosition(cid), 13)
else
doPlayerSendTextMessage(cid,19,"You dont have enough money.")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return TRUE
end


I want it so when i use the switch i get 100 potions for 45plat and if i have 1cc i get 55plat back
 
Just use "if pay(cid, money)" instead of a wrong function...
LUA:
local pos = getCreaturePostion(cid)
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if pay(cid, 100) then
		doPlayerAddItem(cid, 2002, 1)
		doSendMagicEffect(pos, 13)
	else
		doPlayerSendCancel(cid, "Sorry, not enough money.")
		doSendMagicEffect(pos, 2)
	return true
	end
end
 
try this one:
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
 
umm
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local shop = {
		[1000] = {
			id = 2268, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1001] = {
			id = 2273, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1002] = {
			id = 2304, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1003] = {
			id = 2313, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		},
		[1004] = {
			id = 2280, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
		}
	}
	local v = shop[item.actionid]
	local weight = getItemWeightById(v.id, tonumber(getItemInfo.maxItems)) + getItemWeightById
	if(getPlayerFreeCap(cid) >= weight) then
		if(getPlayerMoney(cid) >= v.cost) then
			local bp = doCreateItemEx(cid)
			if(doPlayerAddItemEx(cid) ~= RETURNVALUE_NOERROR) then
				doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
			else
				for i = 1, tonumber(getItemInfo.maxItems) do
					doAddContainerItem(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  " .. 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