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

~Protection Doll~

killing

Member
Joined
Feb 23, 2012
Messages
815
Reaction score
11
Location
BIH
~Hello~ :D

Is it possible to make This..
explanation:

I want to someone create a Script Protection Doll~
Hmm
When player Enter in the game and player wants to be Protect.
Hmm This ID: (Doll) 2322 When player is out of the pz and when use this Doll ID:2322 player can not be attacked..Nobody can attack that player..
I hope you understand what i want..And that Last for 15 seconds..and the player that use that Doll even he cant Attack!(i want to it Works only For Players not Monsters!)
Im Using 0.3.6

- - - Updated - - -

So no one can help me?
 
Not sure how you want this, should the doll get deleted or should there be some kind of exhaustion?
Well this is what I have so far.

actions.xml
XML:
<action itemid="2322" event="script" value="other/doll.lua"/>

doll.lua
Lua:
local storage = 11989
local protectiontime = 15

local function endProtection(cid)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Protection ended.")
end
	
function onUse(cid, item, fromPosition, itemEx, toPosition)

	if getPlayerStorageValue(cid, storage) >= os.time() then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are still protected by this doll.")
		return true
	end
	setPlayerStorageValue(cid, storage, os.time()+protectiontime)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You are now protected by this doll for 15 seconds.')
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
	addEvent(endProtection, 15000, cid)
	return true
end

creaturescripts.xml
XML:
<event type="combat" name="Immortal" event="script" value="immortal.lua"/>

Add the name to login.lua
Lua:
registerCreatureEvent(cid, "Immortal")

immortal.lua
Lua:
function onCombat(cid, target)

local storage = 11989
	
	if isPlayer(cid) and isPlayer(target) then
		if getPlayerStorageValue(cid, storage) >= os.time() then
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can\'t attack players while you\'re under protection.")
			return false
		elseif getPlayerStorageValue(target, storage) >= os.time() then
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can\'t attack this player. This player is under protection by a doll.")
			return false
		end
	end
	return true
end
 
Thnaks

- - - Updated - - -

How to add exhaustion= 10000

- - - Updated - - -

I need just need that in the Script

- - - Updated - - -

How to add exhaustion= 6000
Limos =)

- - - Updated - - -

Yes there should be some exhaustion= 7000

- - - Updated - - -

Yes there should be some exhaustion= 7000

- - - Updated - - -

- - - Updated - - -

How to add exhaustion= 7000
To This!!!!!

Lua:
local storage = 11989
local protectiontime = 15
 
local function endProtection(cid)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Protection ended.")
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	if getPlayerStorageValue(cid, storage) >= os.time() then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are still protected by this doll.")
		return true
	end
	setPlayerStorageValue(cid, storage, os.time()+protectiontime)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You are now protected by this doll for 15 seconds.')
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
	addEvent(endProtection, 15000, cid)
	return true
end
 
Last edited:
Lua:
local config = {
	storage = 11989,
	protectiontime = 15,
	exhausttime = 7000, -- time in seconds
	exhauststorage = 2307
}
	
local function endProtection(cid)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Protection ended.")
end
	
function onUse(cid, item, fromPosition, itemEx, toPosition)

	if getPlayerStorageValue(cid, config.storage) >= os.time() then
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You are still protected by this doll.")
		return true
	end

	if exhaustion.check(cid, config.exhauststorage) then
		local time = exhaustion.get(cid, config.exhauststorage)
		local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
		if time >= 7200 then
			text = ""..hours.." hours, "..minutes.." minutes and "..seconds.." seconds"
		elseif time >= 3600 then
			text = ""..hours.." hour, "..minutes.." minutes and "..seconds.." seconds"
		elseif time >= 60 then
			text = ""..minutes.." minutes and "..seconds.." seconds"
		else
			text = ""..seconds.." seconds"
		end
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) 
		doPlayerSendCancel(cid, "You need to wait "..text.." before you can use this doll again.")
		return true
	end

	setPlayerStorageValue(cid, config.storage, os.time()+config.protectiontime)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You are now protected by this doll for 15 seconds.')
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
	exhaustion.set(cid, config.exhauststorage, config.exhausttime) 
	addEvent(endProtection, 15000, cid)
	return true
end

Edit: Don't test it with a god character, they don't have exhaustion.
 
Last edited:
Back
Top