<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Skull System" version="1.0" author="GarQet" contact="https://otland.net/members/garqet.30076/" enabled="yes">
<description>
Add those two functions to your lib/050-function.lua:
function getPlayerTemporaryKills(cid)
local frags = db.getResult("SELECT `kills` FROM `players` WHERE `id` = '"..getPlayerGUID(cid).."';")
if(frags:getID() == -1) then
return 0 and true
end
kills = frags:getDataInt("kills")
frags:free()
return kills
end
function addTemporaryKill(cid, amount)
return db.executeQuery("UPDATE `players` SET `kills` = `kills` + ".. amount .." WHERE `id` = '"..getPlayerGUID(cid).."';")
end
Add those two lines to your creaturescripts/login.lua:
registerCreatureEvent(cid, "SkullLogin")
registerCreatureEvent(cid, "SkullKill")
Add this to your database:
ALTER TABLE `players` ADD `kills` INT( 11 ) NOT NULL DEFAULT '0';
</description>
<config name="Skulls"><![CDATA[
config = {
kills = {
[1] = {0, 5, "Yellow"}, -- [1 - yellow skull] = {min_amount_of_kills to get this skull, max...}
[2] = {5, 10, "Green"},
[3] = {10, 15, "White"},
[4] = {15, 20, "Red"},
[5] = {20, 100, "Black"}
},
storage = 666
}
]]></config>
<event type="login" name="SkullLogin" event="script"><![CDATA[
domodlib('Skulls')
function onLogin(cid)
setPlayerStorageValue(cid, config.storage, 0)
for skull, info in pairs(config.kills) do
if getPlayerTemporaryKills(cid) >= info[1] and getPlayerTemporaryKills(cid) < info[2] and getPlayerStorageValue(cid, config.storage) ~= skull then
doCreatureSetSkullType(cid, skull)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have ".. getPlayerTemporaryKills(cid) .." frags without death, in form of reward you received ".. info[3] .." Skull!")
setPlayerStorageValue(cid, config.storage, skull)
end
end
return true
end
]]></event>
<event type="kill" name="SkullKill" event="script"><![CDATA[
domodlib('Skulls')
function onKill(cid, target)
if isPlayer(cid) and isPlayer(target) then
addTemporaryKill(cid, -getPlayerTemporaryKills(cid))
setPlayerStorageValue(cid, config.storage, 0)
addTemporaryKill(target, 1)
for skull, info in pairs(config.kills) do
if getPlayerTemporaryKills(target) >= info[1] and getPlayerTemporaryKills(target) < info[2] and getPlayerStorageValue(target, config.storage) ~= skull then
doCreatureSetSkullType(target, skull)
doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You have ".. getPlayerTemporaryKills(target) .." frags without death, in form of reward you received ".. info[3] .." Skull!")
setPlayerStorageValue(target, config.storage, skull)
end
end
end
return true
end
]]></event>
</mod>