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

CreatureEvent Deathnote! (onTextEdit example)

fatelord

New Member
Joined
Aug 7, 2007
Messages
56
Reaction score
1
Hello to everyone!
Im here to post my new useless script! :p

Anyone heard about Deathnote? Well, its a book where you write the name of the person and the person dies. In original Death Note anime, it takes 40 seconds to kill, but im too lazy to add timers, so I made it instant.

Lets Start!
First, check your items.xml. These 2 items MUST be like this:
PHP:
	<item id="1955" article="a" name="book">
		<attribute key="weight" value="1000"/>
	</item>
	<item id="1972" article="a" name="book">
		<attribute key="weight" value="1000"/>
		<attribute key="writeable" value="1"/>
		<attribute key="maxTextLen" value="512"/>
		<attribute key="writeOnceItemId" value="1955"/>
	</item>
If they aren't like this, you cant write on the books :p
Btw, if your server is running, you edit this and try reload it wont work (at least it didnt work for me), so you'll need to restart server.

Ok. Now on creaturescripts.xml:
PHP:
<event type="textedit" name="DeathNote" event="script" value="deathnote.lua"/>

Create a file in creaturescripts/scripts named "deathnote.lua"
PHP:
function onTextEdit(cid, item, newText)
	if item.actionid == 9202 then
	doCreatureAddHealth(getCreatureByName(newText), -100000)
    	end
return TRUE
end

And now on login.lua:
PHP:
registerCreatureEvent(cid, "DeathNote")


How it works? Simple. Open the book with item id 1972. Write the name of a player. If the actionid of the book is 9202, the player you wrote the name dies. Simple like that. If you write the name of a monster instead, the first monster that spawned with that name (if you got 2 rats on the map, the first one on the spawn list is the unlucky one) dies. The script removes 100000 hp from the creature, so except for that super uber master monsters, anything should die. Immune to mana shield, since it directly removes the hp.

Tested on TFS 0.3.4

Reply if you liked it!

PS: Know bugs
1. If you write the name of an inexistent player or monster, the book gets written and nothing else happens. (You lost it noob! :p)
2. Just the first line works. If you write more than one line, nothing happens beside the written book.
3. It will only work for one creature. Dont even bother trying to use commas (,) to multi use it

Soon someone will post an "advanced deathnote", so maybe it will get bug fixed.

:)
 
lol it kills the person instantly
you should add a price so it costs like 1 mill to kill the player
something like this i duno lol
Lua:
local money = 1000000

function onTextEdit(cid, item, newText) 
    if item.actionid == 9202 and doRemoveMoney(cid, money) then
    doCreatureAddHealth(getCreatureByName(newText), -100000) 
        end 
return TRUE 
end
 
Well, its just to test the onTextEdit event. but sky is the limit baby! :p
 
I think this could be better

*This kill the player in 60 seconds (Like the anime)

Lua:
function onTextEdit(cid, item, newText)

local time, param, player = (60*1000), {newText = newText}, getCreatureByName(newText)

	if item.actionid == 9202 and isPlayer(player) then 
		addEvent(killPlayer, time, param) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. newText .. " will be killed in " .. time/1000 .. " seconds.")
	end 
	return TRUE 
end

function killPlayer(p)
	local player = getCreatureByName(p.newText)
	doCreatureAddHealth(player, -getCreatureHealth(player))
end

(60*1000) = 60 seconds.
 
Wow. Great!
I think that param thing is working on my mind now.. never understood how to make it work.

Btw, why the killplayer functon got that (p)? i dont get it.. Function scripting is soo advanced to me :p
 
p is neccesairy to use "param" (p is replaced for param when the script is executed), of course you can change it to s, k, l, m , c or what do you want.

The unique that you don't need to change is "param = {newText = newText}"
 
makeing like how he can die?
by 10 demons summoning around him?
by big magic effect?
and so on?
that would be funny? :thumbup:
anyway nice script
 
Great script, havent tested it but sounds really cool and interesting :thumbup:

Here are some ideas that could go with it. Im wondering if its possible (dont think so but still) that maybe when the person writes the name of the victim on the book and clicks Ok (or Accept or w/e it is lol), the victim would receive battle marks (so he cant logout) and a message (not a PM ofc, just something like a normal doPlayerSendTextMessage) saying something like:

PHP:
"Warning! Player " .. nameofkiller .. " has just paid to send you a Death Note. You will be killed in 10 seconds so you better find an AOL now!"

If the battle marks part isnt possible, logging out would save the person right?

Another idea would be to make an item that "cancels" the Death Note effect, so if the player happens to have the item and he happens to have fast reflexes when he sees the message ;) he can be saved from it.

Dunno if any of those is possible at all, but well, just throwing random ideas ;)

Also, is it possible to make it so Monsters are not affected? Only players? Just wondering, not too important.

+Repped Keep it up.
 
Last edited:
To make it player only its easy.. just addin an "if isPlayer(cid) = TRUE then" somewhere in the code. I am trying an Advanced Deathnote thing.. W8 for it ^^
 
To make it player only its easy.. just addin an "if isPlayer(cid) = TRUE then" somewhere in the code. I am trying an Advanced Deathnote thing.. W8 for it ^^
Well if isPlayer(cid) is not nessesary, becouse creatures won't use the book. I don't get your point.
 
Well if isPlayer(cid) is not nessesary, becouse creatures won't use the book. I don't get your point.

In first post of this thread it says this:

If you write the name of a monster instead, the first monster that spawned with that name (if you got 2 rats on the map, the first one on the spawn list is the unlucky one) dies.

Thats why he talks about isPlayer(cid), so that ^ doesnt happen.

@fatelord:

That'd be fantastic :thumbup:
 
when i add to login.lua


i get this error

PHP:
[19/09/2009 20:23:40] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)
[19/09/2009 20:23:40] data/creaturescripts/scripts/login.lua:44: '<eof>' expected near 'end'


how do i fix?
 
Deathnote was a fucking amazing series. Good work, though not sure how useful it is in Tibia.

@Up
Your missing something on line 44

__________________
 
Last edited:
hmm can you tell me what it should look like this is my login.lua now :/ im a noob at this i know


PHP:
local config = {
	loginMessage = getConfigValue('loginMessage')
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")
	registerCreatureEvent(cid, "Idle")
	registerCreatureEvent(cid, "SkullCheck")
	registerCreatureEvent(cid, "ReportBug")
	return true
end

where in the script do i add it?
 
PHP:
"Warning! Player " .. nameofkiller .. " has just paid to send you a Death Note. You will be killed in 10 seconds so you better find an AOL now!"

If the battle marks part isnt possible, logging out would save the person right?

Another idea would be to make an item that "cancels" the Death Note effect, so if the player happens to have the item and he happens to have fast reflexes when he sees the message ;) he can be saved from it.

Dunno if any of those is possible at all, but well, just throwing random ideas ;)

Also, is it possible to make it so Monsters are not affected? Only players? Just wondering, not too important.

+Repped Keep it up.

Awesome idea, like the player can pay 100k, to cancel the death note. :thumbup:
 
Back
Top