• 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 Error in script t.t

bolero

MikeHere
Joined
Apr 13, 2009
Messages
1,146
Reaction score
12
Location
Venezuela
I have error, when you buy the bless, When a player gives him more than of 1 click to the lever and has 1 kk it is taking the money from him little by little, it is supposed that if it has all the bless the are of stopping buying and saying that already it has them. You can repair this error? :/?

Code:
--fixed by Dark Rat

local cost = 20000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerPremiumDays(cid) == 0 then
	doPlayerSendCancel(cid, "You need premium to do this.")
	return 1
	end
	
	if(getPlayerMoney(cid) < cost*5) then
				doPlayerSendCancel(cid, "You do not have enough money.")
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return 1
		end
			
		for i = 1, 5 do
			if not(getPlayerBlessing(cid, i)) then
				doPlayerAddBlessing(cid, i)
			end
		end
		
		doPlayerRemoveMoney(cid, cost*5)
		doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received all of the blessings!")
	
		if item.itemid == 1945 then
		doTransformItem(item.uid, item.itemid )
		else
		doTransformItem(item.uid, item.itemid )
		end
		
	return true
end
 
Code:
local cost = 100000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if not isPremium(cid) then
		return doPlayerSendCancel(cid, "Sorry, you need premium.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	
	if not getPlayerMoney(cid) < cost then
		return doPlayerSendCancel(cid, "You do not have enough money.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
			
	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			return doPlayerSendCancel(cid, "Sorry, you already have the blessings.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	end
		
	if doPlayerRemoveMoney(cid, cost) then
		for bless = 1, 5 do
			doPlayerAddBlessing(cid, bless)
		end
		
		doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have received all of the blessing's!")
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Lua:
--fixed by Kekox
local cost = 20000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerPremiumDays(cid) == 0 then
		doPlayerSendCancel(cid, "You need premium to do this.")
		return true
	end
	
	if(getPlayerMoney(cid) < cost*5) then
			doPlayerSendCancel(cid, "You do not have enough money.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		return true
	end
	
	if(getPlayerBlessing(cid) == 5) then
			doPlayerSendCancel(cid, "You have already the five blessings.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		return true
	end
	
	for i = 1, 5 do
		if not(getPlayerBlessing(cid, i)) then
			doPlayerAddBlessing(cid, i)
		end
	end
		
	doPlayerRemoveMoney(cid, cost*5)
	doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received all of the blessings!")
	
	if item.itemid == 1945 then
		doTransformItem(item.uid, item.itemid )
	else
		doTransformItem(item.uid, item.itemid )
	end
	return true
end
 

Similar threads

Back
Top