paweleq2000
New Member
- Joined
- Feb 18, 2011
- Messages
- 161
- Reaction score
- 4
Hello, i have problem, this script give reward to player who last hit monster.
Can someone change this script to give reward for player with most damage?
Can someone change this script to give reward for player with most damage?
Code:
local config = {
points = 5, -- how many points winner get?
}
local names = {'earth stone', 'icy stone', 'fire stone', 'wind stone'}
function onDeath(cid, corpse, deathList)
if (isInArray(names, getCreatureName(cid):lower())) then
--local mostdmg = deathList[2] ~= nil and deathList[2] or deathList[1]
local mostdmg = isPlayer(deathList[1]) and deathList[1] or (deathList[2] ~= nil and deathList[2])
if isPlayer(mostdmg) then
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = '".. getAccountByName(getCreatureName(mostdmg)) .."';")
doPlayerSendTextMessage(mostdmg, 22, "You have killed " .. getCreatureName(cid) .. ". You won 5 points to sms shop.")
db.executeQuery("INSERT INTO metin_wins (name, reward, reward_id, stone, date) VALUES ('" .. getCreatureName(mostdmg) .. "', '5 points', '2', '" .. getCreatureName(cid) .. "', " .. os.time() .. ")")
else
doBroadcastMessage("No one has destroyed the stone")
end
end
return TRUE
end