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

How to check condition in script [Help]

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
Hey,
im trying to make a item that recovers some MP, but in order to use, you must be out of battle (without the icon when u go into a battle and appear 2 small swords).
Here's what im trying to the script check:
Code:
function onUse(cid, item, frompos, item2, topos)
if item.itemid == "itemid" then
	if getCreatureCondition(cid, CONDITION_INFIGHT) == 0 then
		doPlayerAddMana(cid,100)
		doRemoveItem(item.uid, 1)
		doSendMagicEffect(getPlayerPosition(cid),10)
	else
		doPlayerSendCancel(cid,"You must be out of fight to recover mana.")
	end
end
end
right now, it's not working...any sugestion? thanks
 
Are you sure that getCreatureCondition returns a number?

Try to test that out some other way. You may be right, but it's just a thought.
 
What I do when I'm testing new stuff:

I take an item that is not usable. Then I create a script so that I am the only one who can trigger it. And then I use it to test the codes.

So, take the BoHs as an example, you almost always were them, even on a GM.

Then create a function like this maybe:
Code:
function onUse(cid, item)
   if item.actionid == 1001 then
      doCreatureSay(cid,getCreatureCondition(cid, CONDITION_INFIGHT),1)
   end
end
With this, you know what the function returns and then you know how to build the script.

Be aware of one thing. Some Lua errors may cause the server to crash, so I recommend testing things on a separate server.
 
Last edited:
Just remember to give the item you want to test with that actionid and I also corrected an error I had put in the script.

(if item.actionid == 1001 then)
Red = correction :)
 
spammer /\ ? :O

what executable you are using ?
do you see the parameters in global.lua ?
i think it will help alot..
 
Back
Top