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

Kill player get 5 platinums

Mister Budex

BudexOT.com
Joined
Jun 22, 2016
Messages
1,547
Solutions
18
Reaction score
378
Hello, can someone give script to me to works like this, When i kill player i want to get 5 platinum coins :D
thanks
 
Solution
yeah was about to post this, i sadly don't remember the old main function arguments, thought onDeath would work (wanted it to only give it to the actual killer, not all players that did damage with onKill)
mmm, I think onKill only works for the person who last hit the target.
I don't have any way to test that though.

.. But we also have "flags"..
Lua:
uint32_t flags = 0;
       if(entry.isLast())
           flags |= 1;

       if(entry.isJustify())
           flags |= 2;

       if(entry.isUnjustified())
           flags |= 4;

So we could alter the code like this...? And it would only work for the player who last hit?
OP will have to test.

Lua:
function onKill(cid, target, damage, flags)
   if bit.band(flags, 1) == 1 then...
playerdeath.lua

Lua:
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    if killer:getPlayer() then
        killer:getPlayer():addItem(coinID,5, false)
    end
[...]
 
Last edited by a moderator:
playerdeath.lua

Code:
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    if killer:getPlayer() then
        killer:getPlayer():addItem(coinID,5, false)
    end
[...]
dont even have playerdeath.lua should i create and copy/paste that code?
 
Lua:
function onDeath(cid, corpse, killer, mostDamageKiller)
    if isPlayer(cid) and isPlayer(killer) then
        doPlayerAddItem(killer, plat coin id, 5)
    end
    return true
end
 
Last edited:
creaturescripts script folder
add in xml
XML:
<event type="death" name="goldkill" event="script" value="scriptname.lua"/>
also register it in your login.lua with
registerCreatureEvent(cid, "goldkill")
 
Last edited by a moderator:
[01/02/2017 18:33:51] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/reward.lua:4: ')' expected near 'coin'
[01/02/2017 18:33:51] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/reward.lua)
[01/02/2017 18:33:51] data/creaturescripts/scripts/reward.lua:4: ')' expected near 'coin'

okey i putted changed id no erros in console but not works.
 
Last edited by a moderator:
[01/02/2017 18:33:51] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/reward.lua:4: ')' expected near 'coin'
[01/02/2017 18:33:51] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/reward.lua)
[01/02/2017 18:33:51] data/creaturescripts/scripts/reward.lua:4: ')' expected near 'coin'

okey i putted changed id no erros in console but not works.

I merged your posts, please.. do not double post, edit your prev. post insted.
 
find "plat coin id" in the script, and change it to the numerical number assigned to "platinum coin" in your server.

Edit, never looked at your screenshots.
 
Problem is with the main function.

//onDeath(cid, corpse, deathList)

You need to use 'onKill' instead.

Lua:
function onKill(cid, target, damage, flags)
    if isPlayer(cid) and isPlayer(target) then
        doPlayerAddItem(cid, 2152, 5)
    end
    return true
end
 
Last edited by a moderator:
Back
Top