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

Lua Broadcasting Kills

oska2

New Member
Joined
Aug 18, 2013
Messages
36
Reaction score
0
Hi otland, I hope I will be getting help this time, I didn't get any last time I asked for it.

So here's the script I need.

If Player called " Esa " kills player called " Jonne " who is level 20, it would broadcast that " Jonne has been killed by Esa at level 20 " but it would only make a red text in the "Default" chat, and be seen by everybody. I think the "Esa" and "Jonne" will be replaced with "cid"? Well, I hope I get help this time, since there are many good scripters in Otland.

Peace
 
data/creaturescripts/scripts/deathbc.lua
Code:
function onDeath(cid, corpse, killer)
if isPlayer(cid) then
doBroadcastMessage("".. getPlayerName(cid) .." has been killed by ".. getCreatureName(killer) .." at level ".. getPlayerLevel(cid) ..".", 17)
end
return TRUE
end

Depends which version of OTServ your using, if you use Avesta for example, this wouldnt work as I remember they dont have onDeath, so try onDie then and corpse, killer could be replace by lasthitkiller, mostdamagekiller
 
Thank you, and sorry I forgot to mention that I'm using TFS 0.3.6, does that script broadcast it like /b or just in default chat? =)
 
Its same like /B execpt it says no player name...
Like:
Code:
Last World: Jonas has been killed by Michael at level 20.
The Script will broadcast like:
Code:
Jonas has been killed by Michael at level 20.

Every player will read this, remember this is a "has been killed"-script, not a "killed" one
 
Ok, I just would have done rep+ to you! :) also if you can see my post about "Megabless and Spell Damage", I would be really thankful!
 
Ummm it seems not to work? :D Do I have to do anything else but just make a new .Lua file to the creaturescripts/scripts folder and paste tghe script inside?
 
Example how to add it in creaturescripts.xml.
Code:
<event type="death" name="Deathbc" event="script" value="deathbc.lua"/>

You have to register the name of all player creaturescripts in login.lua (except from login scripts).
Code:
registerCreatureEvent(cid, "Deathbc")
Add this under the other registerCreatureEvent lines in login.lua.

If you are not sure how to add a creaturescript, you can choose the name and the name of the Lua file.
The name (name="Deathbc") should be registered in login.lua.
If you don't know the type, it looks alot like the main function.
function onDeath = type death
function onKill = type kill
function onPrepareDeath = type preparedeath
function onLogin = type login
etc.

You can also find them in the folder doc in file SCRIPTSYSTEM_HELP.

Okay thanks! 1 more thing, how to rep+ people here? :D
Reputation doesn't exist anymore, it's changed to likes, so you can like his post.
 
creautrescripts.xml
Code:
<event type="death" name="Deathbc" event="script" value="deathbc.lua"/>

login.lua
Code:
registerCreatureEvent(cid, "Deathbc")

creaturescripts/scripts/deathbc.lua (create a lua file)
Code:
function onDeath(cid, corpse, killer)
if isPlayer(cid) then
doBroadcastMessage("".. getPlayerName(cid) .." has been killed by ".. getCreatureName(killer) .." at level ".. getPlayerLevel(cid) ..".", 17)
end
return TRUE
end


Just saw Limos came befor me :)
 
getting this
Code:
[26/11/2013 19:20:15] [Error - CreatureScript Interface]
[26/11/2013 19:20:15] data/creaturescripts/scripts/deathbc.lua:onDeath
[26/11/2013 19:20:15] Description:
[26/11/2013 19:20:15] (luaGetCreatureName) Creature not found

[26/11/2013 19:20:15] [Error - CreatureScript Interface]
[26/11/2013 19:20:15] data/creaturescripts/scripts/deathbc.lua:onDeath
[26/11/2013 19:20:15] Description:
[26/11/2013 19:20:15] data/creaturescripts/scripts/deathbc.lua:3: attempt to concatenate a boolean value
[26/11/2013 19:20:15] stack traceback:
[26/11/2013 19:20:15]    data/creaturescripts/scripts/deathbc.lua:3: in function <data/creaturescripts/scripts/deathbc.lua:1>
and the corp isn't there, tfs 0.3.6
 
Code:
doBroadcastMessage("".. getPlayerName(cid) .." has been killed by ".. isPlayer(killer) or isCreature(killer) and getCreatureName(killer) or "a field" .." at level ".. getPlayerLevel(cid) ..".", 17)
 
Back
Top