• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [onUse] Diamond of Life.

Zatjin

Advanced OT User
Joined
Sep 18, 2011
Messages
2,239
Reaction score
228
Location
Norway
Hi there!

This is one of my first scripts so don't flame me :)

LUA:
local gain = 250
function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.uid = 2153 then
	if getPlayerLevel(cid) == 20 then
		doPlayerSendTextMessage(cid, 21, "You have gained some health and mana!")
		doCreatureAddHealth(cid, gain)
		doPlayerAddMana(cid, gain)
	else
		doPlayerSendCancel(cid, "You dont have the required level")
	end
end
return TRUE
end

Add this to your actions.xml
LUA:
<action itemid="2153" event="script" value="diamondoflife.lua"/>
Please do tell if my tabbing is correct o.O I feel it's much cleaner if it's done that way..

It's probably wrong :P

Sincerely,
Zatjin
 
Last edited:
You forgot an end. remember, for each if, loop, and function there must be an end.
Also, if you want the players that are level 20 or higher use getPlayerLevel(cid) >= 20

> doSendPlayerCancel (cid, "You don't have the required level")
there's a space between 'doSendPlayerCancel' and '('
and it's doPlayerSendCancel(cid, "You don't have the required level")
also, doCreatureAddHealth(cid, gain) and doPlayerSendTextMessage(cid, 21, "You have gained some health and mana")
 
You forgot an end. remember, for each if, loop, and function there must be an end.
Also, if you want the players that are level 20 or higher use getPlayerLevel(cid) >= 20

> doSendPlayerCancel (cid, "You don't have the required level")
there's a space between 'doSendPlayerCancel' and '('
and it's doPlayerSendCancel(cid, "You don't have the required level")
also, doCreatureAddHealth(cid, gain) and doPlayerSendTextMessage(cid, 21, "You have gained some health and mana")

Say whaat?
And I want the player to be exactly 20.
It should be like this?
Code:
function onUse (cid, item, fromPosition, ItemEx, toPosition)
local gain = 250
	if item.itemuid ==  2153 and getPlayerLevel(cid) == 20
	doSendPlayerTextMessage (cid,21,"You have gained some health and mana!")
	doAddPlayerHealth(cid,gain)
	doAddPlayerMana(cid,gain)
	end
else
	doSendPlayerCancel (cid,"You don't have the required level")
	return TRUE
end
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local gain = 250
if item.uid = 2153 then
	if getPlayerLevel(cid) == 20 then
		doPlayerSendTextMessage(cid, 21, "You have gained some health and mana!")
		doCreatureAddHealth(cid, gain)
		doPlayerAddMana(cid, gain)
	else
		doPlayerSendCancel(cid, "You dont have the required level")
	end
end
return TRUE
end
 
Last edited:
doPlayerSendCancel(cid, "You dont have the required level"=

>>= ? gzz


doPlayerSendCancel(cid, "You dont have the required level")
 
doPlayerSendCancel(cid, "You dont have the required level"=

>>= ? gzz


doPlayerSendCancel(cid, "You dont have the required level")

Ah, yeah.
a little typo, thanks for pointing it out.
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local gain = 250
if item.uid = 2153 then
	if getPlayerLevel(cid) == 20 then
		doPlayerSendTextMessage(cid, 21, "You have gained some health and mana!")
		doCreatureAddHealth(cid, gain)
		doPlayerAddMana(cid, gain)
	else
		doPlayerSendCancel(cid, "You dont have the required level")
	end
end
return TRUE
end

Thanks Bogart!

I'll update my MP :)
 
Back
Top