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

Click Chest and Hits yourself X HP

krotus

New Member
Joined
Jul 15, 2009
Messages
65
Reaction score
3
I'd like that a chest located in somewhere of map which hits yourself if you click on it and would a red /orange message saying: "You has lost 500 hp!"

The idea is that you enter in a room which there are a lot of chests but only one is the correct and the rest are erroneous.
Greetings,
 
@J.Dre
Lua:
doCreatureAddHealth(cid, getCreatureHealth(cid) - 500)

That script heals me...

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doCreatureAddHealth(cid, getCreatureHealth(cid) -500)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong chest, You lost 500HP.")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
    return true
end

- - - Updated - - -

@amiroslo

try with this

doTargetCombatHealth(cid, getPlayerPosition(cid), 1, -500, -500, 11)

That script says error log:
[Error - Action Interface]
data/actions/scripts/chesthits/chestHit.lua:eek:nUse
Description:
<luaDoTargetCombatHealth> Creature not found
 
Last try

Lua:
function doRemoveHP(cid) -- Removes 500HP
    db.executeQuery("UPDATE `players` SET `health` = `health` - 500 WHERE id = " .. getPlayerGUID(cid) .. ";") 
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	doRemoveHP(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong chest, You lost 500HP.")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
    return true
end
 
Last try

Lua:
function doRemoveHP(cid) -- Removes 500HP
    db.executeQuery("UPDATE `players` SET `health` = `health` - 500 WHERE id = " .. getPlayerGUID(cid) .. ";") 
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	doRemoveHP(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong chest, You lost 500HP.")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
    return true
end

But player need logout for gain damage?
 
@amiroslo

The script doesn't work, all fine, less the HP thing...

- - - Updated - - -

@ J.Dre It still healing me, don't remove my HP.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doCreatureAddHealth(cid, (getCreatureHealth(cid) - 500))
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong chest, You lost 500HP.")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
    return true
end
 
Yes, as says @amiroslo, the monster, hit and kill me but when I'm near from it, but I wanted on click, It attacks me...

I saw this script that someone posted on another forum, and he says that it works fine, but I tested it and don't get results, just everything works, less hp doesn't go down:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local health = 150
if math.random(1,100) > 50 then
   doSendMagicEffect(getCreaturePosition(cid), 15, true)
   doCreatureAddHealth(cid, -health, TRUE)
   doCreatureSay(cid, " SII. ", TALKTYPE_ORANGE_1)
else
   doCreatureSay(cid, " NOO. ", TALKTYPE_ORANGE_1)
end 
return true 
end

Why!! It's my server, maybe I've to erase everything from my folders or is just libraries that needs to be replace ? :(

Could be applied the function:
Code:
addDamageCondition(condition, 1, 3000, -45)

I think that this function is for NPC but someone could to explain me about it, or if it could be applied as actions to use on chest.
 
Last edited:
Back
Top