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

CreatureEvent TFS 1.0 KDR System!

Is it posible to set the onpd.lua only for pvp? something like that:
  1. function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
  2. ---------> if isPlayer(cid) == true and if isPlayer(lastHitKiller) == true then <----------
  3. db.query("UPDATE `players` SET `deaths` = `deaths` + 1 WHERE id = " .. getPlayerGUID(cid) .. ";")
  4. doCreatureSay(cid, '+1 Death Point!', TALKTYPE_ORANGE_1)
  5. end
  6. return true
  7. end
 
101 Views. No one is using this? I swear I have seen tons of people asking how to see frags, how to see frags....
Tested it and in tfs 1.5 is not working, could you remake it please? would appreciate it.
don't know but im quite sure is
Lua:
data/events/scripts/player.lua

or here, where added final lines of your script but does not work
function Player:onLook(thing, position, distance)
    local description = ""
    if hasEventCallback(EVENT_CALLBACK_ONLOOK) then
        description = EventCallback(EVENT_CALLBACK_ONLOOK, self, thing, position, distance, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
Code:
local ec = EventCallback

ec.onLook = function(self, thing, position, distance, description)
    local description = "You see " .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItem ID: %d", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, Action ID: %d", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, Unique ID: %d", description, uniqueId)
            end

            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecays to: %d", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: %d / %d"
            if thing:isPlayer() and thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
    return description
end

ec:register()
 
Tested it and in tfs 1.5 is not working, could you remake it please? would appreciate it.
don't know but im quite sure is
Lua:
data/events/scripts/player.lua

or here, where added final lines of your script but does not work
function Player:onLook(thing, position, distance)
    local description = ""
    if hasEventCallback(EVENT_CALLBACK_ONLOOK) then
        description = EventCallback(EVENT_CALLBACK_ONLOOK, self, thing, position, distance, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
Code:
local ec = EventCallback

ec.onLook = function(self, thing, position, distance, description)
    local description = "You see " .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItem ID: %d", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, Action ID: %d", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, Unique ID: %d", description, uniqueId)
            end

            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecays to: %d", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: %d / %d"
            if thing:isPlayer() and thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
    return description
end

ec:register()
This system was made for a completely different tfs than what 1.5 is today. If you say all the rest works, and come this far, then I'm hoping you are willing to help yourself as it seems.
You are correct on needing to move the logic to the new event location. Great find, moving along though, did you notice what that function returns? The return is very important!!! In this eventfunction we get a return value of a string for "description". The same one passed to the function in its parameters by the same name. If you make your own EventCallback, just like your example, but write the logic expecting all that other stuff to be done for you (because it is, in the script you posted, from main, so don't touch it!), then all you need to do is to modify "description" to include your information, in this case, KDR.
basically you only need to modify the description to read the same information correctly, kdr, and then when using ec:register() set lower priority to make sure its called after all that other stuff by doing it like this instead ec:register(5) -- 5 being a number way after the first default look scripts.
Post automatically merged:

If anyone wants to test it for me, I would appreciate it. I wrote it quickly and don't have players for testing, its for 1.3+, if we can check that it works, then I'll post a new release thread for it.
Just drop into data/scripts, just the one file, and everything should work, provided you have executed the sql commands in main post first.
 
Last edited:
Back
Top