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

Action - Take damage and hide "container frame"

Hultin

Member
Joined
Dec 2, 2008
Messages
262
Reaction score
17
Hello!

I'm creating a "sacred" grave to fit my storyline where the king lies.

I'm using a grave of item id: 1412(top) 1411(bottom) and when using the top, I want players to be brought down to 1hp, and that the container frame which shows by default to be hidden.

Also, the text above the head that will show (see script below), is there anyway to make that orange?

Here's my current script:
PHP:
function onUse(cid)
	local condition = createConditionObject(CONDITION_FIRE)
	local damage = getCreatureHealth(cid) - 1
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Touching the kings grave is forbidden!")
	addDamageCondition(condition, 1, 1, -damage)
end
 
addDamageCondition isnt the right function to deal direct damage.

Here is your request. Rep me ;D
return true prevents that the "container window" opens.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local damage = -getCreatureHealth(cid)+1
	doSendMagicEffect(getThingPos(item.uid), 2)
	doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage, damage, CONST_ME_HITBYFIRE)
	doPlayerSay(cid, "Touching the kings grave is forbidden!", TALKTYPE_MONSTER)
	return true
end
 
ah, thanks alot. I realised that after a while, just before I saw your post I edited it to this (if you were intrested)
PHP:
function onUse(cid)
	local condition = createConditionObject(CONDITION_FIRE)
	local damage = getCreatureHealth(cid) - 1
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Touching the kings grave is forbidden!")
	doCreatureAddHealth(cid, -damage)
end

Thanks alot, and rep'd
 
Tried to make it so that when a player clicks, he get a storage id saved which if he clicks another time, will kill him.

But it instantly kill the player instead of firsttime giving him a warning:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local hasTouched = getCreatureStorage(cid, 55555)
	local damage = -getCreatureHealth(cid)
	doSendMagicEffect(getThingPos(item.uid), 2)
	if(hasTouched == null) then
		doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage+1, damage+1, CONST_ME_HITBYFIRE)
		doPlayerSay(cid, "Touching the kings grave is forbidden! Next time you will be killed!", TALKTYPE_MONSTER)
		doSetStorage(55555, 1)
	else
		doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage, damage, CONST_ME_HITBYFIRE)
		doPlayerSay(cid, "You were warned!", TALKTYPE_MONSTER)
	end
	return true
end
 
Edited Summe's script
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local hasTouched = getCreatureStorage(cid, 55555)
    	local damage = -getCreatureHealth(cid)+1
    if hasTouched == -1 then
        	doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage, damage, CONST_ME_HITBYFIRE)
        doPlayerSay(cid, "Touching the kings grave is forbidden! Next time you will be killed!", TALKTYPE_MONSTER)
        setPlayerStorageValue(cid,55555, 1)
    else
			doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -90000, -90000, CONST_ME_HITBYFIRE)
        doPlayerSay(cid, "You were warned!", TALKTYPE_MONSTER)
    end
    return true
end
I know, it could be better.
 
Last edited:
Mind me asking, why do you put a minus sign before the integer? Talking about hasTouched == -1, and why not hasTouched == 1?

And thank you for the help!

Edit: Didn't work, trying to figure out why. It just make you able to click forever.
 
Here without ifs (^^) and without high fail numbers (-90000)
Code:
local config = {
	text = {[-1] = "Touching the kings grave is forbidden!", [1] = "You were warned!"},
	storage = 3956,
	warntime = 5
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage = getPlayerStorageValue(cid, config.s)
	local damage = -getCreatureHealth(cid)+(storage >= os.time() and 0 or 1)
	
	doSendMagicEffect(getThingPos(item.uid), 2)
	doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage, damage, CONST_ME_HITBYFIRE)
	doPlayerSay(cid, config.text[(storage >= os.time() and 1 or -1)], TALKTYPE_MONSTER)
	
	setPlayerStorageValue(cid, config.s, (storage >= os.time() and -1 or os.time()+config.warntime))
	return true
end
Config:
text = {[-1] = "Touching the kings grave is forbidden!", [1] = "You were warned!"}, --normal text, warn text
storage = 3956, --some storage
warntime = 5 --if a player uses the grave he is warned for 5 seconds, so it cant happen that a player uses it and 5 days later he is still signed as "warned" and dies..
 
Didn't work, trying to figure out why. It just make you able to click forever. I checked my database, and it doesn't seem like the storage is getting saved, for some reason.

Edit: doSetStorage(55555, 1) should be doSetStorage(cid, 55555, 1).
Edit2: Still doesn't work. :S
 
Well I like ? : operator (C++) and it is possible in LUA too (and or) and training ;D

So instead of:
Code:
if a == 1 then 
print("a = 1") 
elseif a == 2 then
print("a = 2")
else
print("a = something else")
end
You can use:
Code:
print((a == 1 and "a = 1" or a == 2 and "a = 2" or "a = something else"))
--> condition and value or condition and value or value..

Btw: I need a shortcut to write "
Code:
-tag" in quick replay -.....- ffs
 
Just found a bug, I've got no real clue how to fix it. If the player has manashield up he/she wont take the proper ammount of damage.
 
Then replace:
doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, damage, damage, CONST_ME_HITBYFIRE)
with:
doCreatureAddHealth(cid, damage)
doSendMagicEffect(getThingPos(cid), CONST_ME_HITBYFIRE)
 
That did work. I just wonder one thing, if say I log out or even just let it be more than a few seconds between the clicks, the first message appears again. I'm sorry for all the questiosn but I just have no idea at this point what to do. What I thought I could handle with ease myself has turned into a nightmare.
 
That did work. I just wonder one thing, if say I log out or even just let it be more than a few seconds between the clicks, the first message appears again. I'm sorry for all the questiosn but I just have no idea at this point what to do. What I thought I could handle with ease myself has turned into a nightmare.

Then it should be done with storages.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local hasTouched = getCreatureStorage(cid, 55555)
    	local damage = -getCreatureHealth(cid)+1
		    	local damage2 = -getCreatureHealth(cid)
    if hasTouched == -1 then
        	doCreatureAddHealth(cid, damage)
                doSendMagicEffect(getThingPos(cid), CONST_ME_HITBYFIRE) 
		doPlayerSendTextMessage(cid,22,"Touching the kings grave is forbidden! Next time you will be killed!")
                setPlayerStorageValue(cid,55555, 1)
    else
        	doCreatureAddHealth(cid, damage2)
                 doSendMagicEffect(getThingPos(cid), CONST_ME_HITBYFIRE) 
		doPlayerSendTextMessage(cid,22,"You were warned!")
                setPlayerStorageValue(cid,55555, -1)
    end
    return true
end
 
Last edited:
Reset the storage to -1 on else statement or it will kill player instantly next time..
 
Back
Top