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

Using potions only on yourself?

Wiw3K

New Member
Joined
Apr 16, 2008
Messages
371
Reaction score
3
I am trying to make potions only working on yourself , unable to potion someone, here is my script take a look

Code:
local MIN = 100
local MAX = 200
local EMPTY_POTION = 7636

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

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end

	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end

	if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then
		return FALSE
	end

	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end

i tried to change

Code:
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end

to

Code:
pos = getPlayerPosition(cid)

if pos == FALSE then
        return TRUE
        end

but it not work :O
what is wrong? or how to do that?
 
@UP
xD ur fast ;<

A rather simple solution, using getCreatureName:

Lua:
local MIN = 100
local MAX = 200
local EMPTY_POTION = 7636

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

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end
	
	if getCreatureName(itemEx.uid) ~= getCreatureName(cid) then
		doPlayerSendCancel(cid, "You may only use potions on yourself.")
		return TRUE
	end

	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end

	if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then
		return FALSE
	end

	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end
 
Thank You ! :* working wery well ,

btw one more question

i added to my leaver this:

Code:
doPlayerSendTextMessage(cid,22,"You have bought Backpack with Health Potions.")

and there appear message about buying that item, how about an green message , idk how to do that , like in Hotkeys
Code:
13:33 Using one of 328 great mana potions...
 
Back
Top