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

Blessing lever script sucking

Status
Not open for further replies.

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,631
Reaction score
33
Location
United States
Code:
local bless =  {1, 2, 3, 4, 5}
local maxlevel = 1000000000
local maxlevel = 45
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
local lvl = getPlayerLevel(cid)
local new_cost = 50000
local target = getPlayerGUID(cid)


        for i = 1, table.maxn(bless) do
                if(getPlayerBlessing(cid, bless[i])) then
                        doPlayerSendCancel(cid, "You have already have been blessed.")
                        return TRUE
                end
        end
       
	   if(item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
		end
		
        if (getPlayerLevel(cid) >= maxlevel)  then
                if(doPlayerRemoveMoney(cid, new_cost) == TRUE) then
                        for i = 1, table.maxn(bless) do
						doPlayerPopupFYI(cid, "You have been successfully blessed!")
                        doPlayerAddBlessing(cid, bless[i])
						doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
						end
                else
                doPlayerPopupFYI(cid, "It costs 50,000 gold coins to be blessed.")
                end
       
        elseif(getPlayerLevel(cid) < maxlevel) then
                if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                        for i = 1, table.maxn(bless) do
						doPlayerPopupFYI(cid, "You have been successfully blessed!")
                        doPlayerAddBlessing(cid, bless[i])
						doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
                        end
                else
                        doPlayerPopupFYI(cid, "It costs 50,000 gold coins to be blessed.")
                end
        end
        return FALSE
end

It doesn't check to transform the lever back to 1945, and I don't understand why theres a max level. And the main thing is when it sends the FYI message, it sends it 5 times for some reason so I have to click OK 5 times to make it go away. I tried moving the popup message earlier in the list of events it does but it doesn't make a difference, it still sends it 5 times. If anyone could help me fix this it would be great
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerBlessing(cid, 1) or getPlayerBlessing(cid, 2) or getPlayerBlessing(cid, 3) or getPlayerBlessing(cid, 4) or getPlayerBlessing(cid, 5) then
        doPlayerSendCancel(cid,'God has already blessed you.')
    else
        if doPlayerRemoveMoney(cid, 60000) == TRUE then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
            doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE,'You have been blessed by the Gods.')
        else
            doPlayerSendCancel(cid, "You need 10 crystal coin to get blessed!")
        end
    end    
    return 1
end
 
Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
	end

	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			return doPlayerSendCancel(cid, "You have already have been blessed.")
		end
	end

	if doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been successfully blessed!")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		for i = 1, 5 do
			doPlayerAddBlessing(cid, i)
		end
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "It costs " .. cost .. " gold coins to be blessed.")
	end
	return true
end
 
Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
	end

	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			return doPlayerSendCancel(cid, "You have already have been blessed.")
		end
	end

	if doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been successfully blessed!")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		for i = 1, 5 do
			doPlayerAddBlessing(cid, i)
		end
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "It costs " .. cost .. " gold coins to be blessed.")
	end
	return true
end


Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
				doSendMagicEffect(toPosition, CONST_ME_POFF)
	end

	
		if getPlayerStorageValue(cid, 4901) == 1 then
			doPlayerPopupFYI(cid, "You have already been blessed!")
		end
	end

	if doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been blessed! You will lose less experience and no items.")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 1 * 10)
		setPlayerStorageValue(cid, 4901, 1)
		end
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "You need 50,000 gold to be blessed.")
	end
	return true
end

[21/03/2010 17:25:07] data/actions/scripts/blessings lever.lua:6: 'end' expected (to close 'if' at line 4) near 'doSendMagicEffect'
 
Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
		doSendMagicEffect(toPosition, CONST_ME_POFF)
	end
	
	if getPlayerStorageValue(cid, 4901) == 1 then
		doPlayerPopupFYI(cid, "You have already been blessed!")
	end
	
	if doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been blessed! You will lose less experience and no items.")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 1 * 10)
		setPlayerStorageValue(cid, 4901, 1)
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "You need 50,000 gold to be blessed.")
	end
return true
end

EDIT: Just read the script and it's %!%&"!, why don't you use cyko's?
Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, item.itemid - 1)
	end

	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then
			return doPlayerSendCancel(cid, "You have already have been blessed.")
		end
	end

	if doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been successfully blessed!")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		for i = 1, 5 do
			doPlayerAddBlessing(cid, i)
		end
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "It costs " .. cost .. " gold coins to be blessed.")
	end
	return true
end
 
[21/03/2010 17:33:26] data/actions/scripts/blessings lever.lua:6: 'end' expected (to close 'if' at line 4) near 'doSendMagicEffect'
 
Code:
local cost = 50000

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		doTransformItem(item.uid, item.itemid - 1)
	elseif getPlayerStorageValue(cid, 4901) == 1 then
		doPlayerPopupFYI(cid, "You have already been blessed!")
	elseif doPlayerRemoveMoney(cid, cost) then
		doPlayerPopupFYI(cid, "You have been blessed! You will lose less experience and no items.")
		doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 1 * 10)
		setPlayerStorageValue(cid, 4901, 1)
		doTransformItem(item.uid, 1946)
	else
		doPlayerPopupFYI(cid, "You need 50,000 gold to be blessed.")
	end
	return true
end
 
I didn't really understand what you wanted, so I just made a basic blessings script. It is easy to modify it, if you wish.

Code:
local cost = 50000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid = 1945) then
		for i = 1, 5 do
			if(getPlayerBlessing(cid, i)) then
				doPlayerSendCancel(cid, "You already have all of the blessings.")
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			elseif(getPlayerMoney(cid) < cost) then
				doPlayerSendCancel(cid, "You do not have enough money.")
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			else
				doPlayerAddBlessing(cid, i)
				doPlayerRemoveMoney(cid, cost)
			        doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've received all of the blessings!")
			end
		end
	elseif(item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end
	return true
end
 
I didn't really understand what you wanted, so I just made a basic blessings script. It is easy to modify it, if you wish.

Code:
local cost = 50000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid = 1945) then
		for i = 1, 5 do
			if(getPlayerBlessing(cid, i)) then
				doPlayerSendCancel(cid, "You already have all of the blessings.")
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			elseif(getPlayerMoney(cid) < cost) then
				doPlayerSendCancel(cid, "You do not have enough money.")
				doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			else
				doPlayerAddBlessing(cid, i)
				doPlayerRemoveMoney(cid, cost)
			        doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've received all of the blessings!")
			end
		end
	elseif(item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end
	return true
end
*facepalm*
You're looping way too many things.
 
Status
Not open for further replies.
Back
Top