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

Solved Very Easy problem with lua code

Bilip

New Member
Joined
Apr 15, 2009
Messages
41
Reaction score
0
Lua:
local POTIONS = {


	[6542] = {health = {3500, 4000}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion --SUPER DUPER HP


	[6543] = {mana = {1800, 2700}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- SUPER DUPER MANA


	[6541] = {health = {1000, 2000}, mana = {550, 1000}, level = 500, vocations = {3, 7}, vocStr = "paladins"} -- SUPER spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = POTIONS[item.itemid]
	if(not potion) then
		return false
	end


	if(hasCondition(cid, CONDITION_EXHAUST)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end

	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(cid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end



	local health = potion.health
	if(health and not doCreatureAddHealth(cid, math.ceil(math.random(health[1], health[2]) ))) then
		return false
	end

	local mana = potion.mana
	if(mana and not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2]) ))) then
		return false
	end

	doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
	

	doAddCondition(cid, exhaust)
	doRemoveItem(item.uid, 1)



	return true
end

over and over I get bug:
Code:
 '<eof>' expected near 'end'

The hell is wrong!?!
I'm using Notepad++ so I purely see I have correct nr of 'ends'
I Lost something but I don't know what
=)

Sorry For DOUBLE POST, PLEASE DELETE the second ONE, It was coused by a lag ;/

This code for food instead potion (without use with, just use)
 
Last edited:
Try this.
Lua:
local POTIONS = {
 
 
	[6542] = {health = {3500, 4000}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion --SUPER DUPER HP
 
 
	[6543] = {mana = {1800, 2700}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- SUPER DUPER MANA
 
 
	[6541] = {health = {1000, 2000}, mana = {550, 1000}, level = 500, vocations = {3, 7}, vocStr = "paladins"} -- SUPER spirit potion
}
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = POTIONS[item.itemid]
	if(not potion) then
		return false
	end
 
 
	if(hasCondition(cid, CONDITION_EXHAUST)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end
 
	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(cid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end
 
 
 
	local health = potion.health
	if(health and not doCreatureAddHealth(cid, math.ceil(math.random(health[1], health[2]) ))) then
		return false
	end
 
	local mana = potion.mana
	if(mana and not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2]) ))) then
		return false
	end
 
	doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
 
 
	doAddCondition(cid, exhaust)
	doRemoveItem(item.uid, 1)
 
 
 
	return true
end
 
Even more Errors now :p
checking this out...
@Edit.
There was one "(" missing, but this wans't any problem.
I still have same Error:
Code:
'<eof>' expected near 'end'
 
Lua:
local POTIONS = {
	[6542] = {health = {3500, 4000}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion --SUPER DUPER HP
	[6543] = {mana = {1800, 2700}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- SUPER DUPER MANA
	[6541] = {health = {1000, 2000}, mana = {550, 1000}, level = 500, vocations = {3, 7}, vocStr = "paladins"} -- SUPER spirit potion
}
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = POTIONS[item.itemid]
	if(not potion) then
		return false
	end
	if(hasCondition(cid, CONDITION_EXHAUST)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end
	if (potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(cid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end
	local health = potion.health
	if(health and not doCreatureAddHealth(cid, math.ceil(math.random(health[1], health[2]) ))) then
		return false
	end
	local mana = potion.mana
	if(mana and not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2]) ))) then
		return false
	end
	doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
	doAddCondition(cid, exhaust)
	doRemoveItem(item.uid, 1)
	return true
end

- - - Updated - - -

Your error:

Lua:
if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then
 
So clooose :p
Can't find error in your line, just few unnecessairy bracets but no error, anyway, with your code same error
Code:
 <eof> expected near end
i don't really get it, cause this error means: There are too many "ends" but I counted "ends" about milion times, and the number is correct. This must be even more stupid that's why is still unsolved :p


OK, I rebuild whole code complitely and now it works. I don't post it here cause I don't think anybody needs this.
SOLVED!

Guys Up /\ Thanks for trying =)
 
Last edited:
Back
Top