• 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 Killed by.. Please help with my barbaric sintaxis

Demonatti

Member
Joined
May 13, 2010
Messages
89
Solutions
1
Reaction score
14
Im relatively new to LUA and im trying to make a code so when a player dies it sends an orange msg saying
"Killed by X.." , im trying to use onPrepareDeath for the event and getCreatruename but I cant seem to find the
0.4 rev .3777 functions lists so Im making a disaster with the parameters. Please help


Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
  
                doCreatureSay(cid, "Killed by "..lastHitKiller.getCreatureName, TALKTYPE_ORANGE_1)
      
        return true
        end

I know this is absolutely barbaric but im doing this blindfolded, thank you in advance

Im kinda sure that I also need getCreaturePostition since the message should appear in the tile wich the player died, it should work with mobs and players
 
Last edited by a moderator:
Solution
Im relatively new to LUA and im trying to make a code so when a player dies it sends an orange msg saying
"Killed by X.." , im trying to use onPrepareDeath for the event and getCreatruename but I cant seem to find the
0.4 rev .3777 functions lists so Im making a disaster with the parameters. Please help


Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
 
                doCreatureSay(cid, "Killed by "..lastHitKiller.getCreatureName, TALKTYPE_ORANGE_1)
    
        return true
        end

I know this is absolutely barbaric but im doing this blindfolded, thank you in advance

Im kinda sure that I also need getCreaturePostition since the message should appear in the tile wich the player died, it should work with...
Im relatively new to LUA and im trying to make a code so when a player dies it sends an orange msg saying
"Killed by X.." , im trying to use onPrepareDeath for the event and getCreatruename but I cant seem to find the
0.4 rev .3777 functions lists so Im making a disaster with the parameters. Please help


Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
 
                doCreatureSay(cid, "Killed by "..lastHitKiller.getCreatureName, TALKTYPE_ORANGE_1)
    
        return true
        end

I know this is absolutely barbaric but im doing this blindfolded, thank you in advance

Im kinda sure that I also need getCreaturePostition since the message should appear in the tile wich the player died, it should work with mobs and players

Please do not double post, edit your posted insted.
I merged the post but think about it in the future :)

Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    doCreatureSay(cid, "Killed by " .. getCreatureName(lastHitKiller), TALKTYPE_ORANGE_1)
    return true
end

That should work, but you should add a check if the lastHitKiller is a player or not (could be a monster), unless you wanna display it for all kinds of creatures.
Lua:
isPlayer(lastHitKiller)

The thing you did wrong was pretty much use metatables (as the 1.x versions use) lastHitKiller:getName() when you should have used getCreatureName(lastHitKiller)
 
Last edited by a moderator:
Solution
You're the best thank you, and yes you are right i'll edit it next time

Edit : Well, Thanks for the help, it couldn't work because the creature cant cast the string if he's dead sooooo I replaced with :

Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    
doSendAnimatedText(pos, "Killed by " .. getCreatureName(lastHitKiller) .. "", TALKTYPE_ORANGE_1)

return true

end
Buut I cant figure out how to fill the pos , something like getCreaturePos? please help :)

Lua:
doSendAnimatedText(pos, "Killed by " .. getCreatureName(lastHitKiller) .. "", TALKTYPE_ORANGE_1)
 
Last edited:
Back
Top