• 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 getCreaturePos quick fix, please hlep

Demonatti

Member
Joined
May 13, 2010
Messages
89
Solutions
1
Reaction score
14
Well, with some help we made this short script but it couldn't work with because :

Lua:
doCreatureSay(cid, "Killed by " .. getCreatureName(lastHitKiller) .. "", TALKTYPE_ORANGE_1)

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)
 
Solution
Okay, at least im getting an error now . And yes I added it to login :)

Code:
[22:0:39.284] [Error - CreatureScript Interface]
[22:0:39.285] data/creaturescripts/scripts/killedby.lua:onPrepareDeath
[22:0:39.287] Description:
[22:0:39.288] (LuaInterface::luaGetCreatureName) Creature not found

My srcript =

Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
                doCreatureSay(cid, "Owned" , TALKTYPE_ORANGE_1)
        return true
        end

Except that when it is like this it works, but if I replace the "Owned" with getCreatureName(lastHitKiller) it throws that error. Thanks for the constant replies

Your code just needs...
Animated text has a text length limit. Can't remember how much but I'm pretty sure you're exceeding it. You can use doCreatureSay with a position too.
 
the creature cant cast the string if he's dead

doCreatureSay works with onPrepareDeath & even works with onDeath because they are executed before onDeath returns true which is when the creature actually dies.
 
doCreatureSay works with onPrepareDeath & even works with onDeath because they are executed before onDeath returns true which is when the creature actually dies.

Neither worked, i dont know what im missing, im using TFS 0.4 rev 3777 and the console shows nothing. No bugs or such but it doesnt do anything either. Help ?

The script :
Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    
doSendAnimatedText(getPlayerPosition(cid), "Killed by " .. getCreatureName(lastHitKiller) .. "", TEXTCOLOR_RED)
    
return true

end

The call:
XML:
<event type="preparedeath" name="charge amulet" event="script" value="killedby.lua"/>
 
did you register it in login.lua?

Okay, at least im getting an error now . And yes I added it to login :)

Code:
[22:0:39.284] [Error - CreatureScript Interface]
[22:0:39.285] data/creaturescripts/scripts/killedby.lua:onPrepareDeath
[22:0:39.287] Description:
[22:0:39.288] (LuaInterface::luaGetCreatureName) Creature not found

My srcript =

Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
                doCreatureSay(cid, "Owned" , TALKTYPE_ORANGE_1)
        return true
        end

Except that when it is like this it works, but if I replace the "Owned" with getCreatureName(lastHitKiller) it throws that error. Thanks for the constant replies
 
Code:
onPrepareDeath(cid, deathList)
There is no lastHitKiller, mostDamageKiller.

You can test this by printing it.
Code:
print(lastHitKiller, mostDamageKiller)
I'm 99% sure you'll get nil as a result, (or rather.. you'll get an error.. because deathList would return a table I assume.)

Try printing some stuff to find out what value that gives..

or use onKill instead.

Code:
function onKill(cid, target, damage, flags)
   if bit.band(flags, 1) == 1 then -- 1, last; 2, justified; 4, unjustified
       if isPlayer(cid) and isPlayer(target) then
           local pos = getCreaturePosition(target)
           doSendMagicEffect(pos, CONST_ME_FIREAREA)
           doCreatureSay(cid, "Killed by " .. getCreatureName(cid) .. "." , TALKTYPE_ORANGE_1, nil, nil, pos)
       end
   end
   return true
end
 
Code:
onPrepareDeath(cid, deathList)
There is no lastHitKiller, mostDamageKiller.

You can test this by printing it.
Code:
print(lastHitKiller, mostDamageKiller)
I'm 99% sure you'll get nil as a result, (or rather.. you'll get an error.. because deathList would return a table I assume.)

Try printing some stuff to find out what value that gives..

or use onKill instead.

Code:
function onKill(cid, target, damage, flags)
   if bit.band(flags, 1) == 1 then -- 1, last; 2, justified; 4, unjustified
       if isPlayer(cid) and isPlayer(target) then
           local pos = getCreaturePosition(target)
           doSendMagicEffect(pos, CONST_ME_FIREAREA)
           doCreatureSay(cid, "Killed by " .. getCreatureName(cid) .. "." , TALKTYPE_ORANGE_1, nil, nil, pos)
       end
   end
   return true
end

Holly, it looks way more better than mine, i didnt knew about the bit.band( ). Thanks for the help! I will surely test it in the morning and come back with the results.
 
Okay, at least im getting an error now . And yes I added it to login :)

Code:
[22:0:39.284] [Error - CreatureScript Interface]
[22:0:39.285] data/creaturescripts/scripts/killedby.lua:onPrepareDeath
[22:0:39.287] Description:
[22:0:39.288] (LuaInterface::luaGetCreatureName) Creature not found

My srcript =

Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
                doCreatureSay(cid, "Owned" , TALKTYPE_ORANGE_1)
        return true
        end

Except that when it is like this it works, but if I replace the "Owned" with getCreatureName(lastHitKiller) it throws that error. Thanks for the constant replies

Your code just needs a lil tweaking

Lua:
function onPrepareDeath(cid, deathList)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
    doCreatureSay(cid, "Owned by ".. getCreatureName(deathList[1]), TALKTYPE_ORANGE_1)
    return true
end

deathList works like this. deathList[1] returns the id of the last hit killer. deathList[2] and so forth will return the id of all assisting killers in descending order going by damage dealt.
 
Solution
Your code just needs a lil tweaking

Lua:
function onPrepareDeath(cid, deathList)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREAREA)
    doCreatureSay(cid, "Owned by ".. getCreatureName(deathList[1]), TALKTYPE_ORANGE_1)
    return true
end

deathList works like this. deathList[1] returns the id of the last hit killer. deathList[2] and so forth will return the id of all assisting killers in descending order going by damage dealt.


Ran smooth as a baby's ass
 
Back
Top