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

RevScripts implement to xml monster

Moody

Member
Joined
Feb 8, 2020
Messages
60
Reaction score
5
how i implement this to xml monster not revscripts 1
@Xikini
 
Solution
in monster
XML:
<script>
    <event name="onHealthChange_Training_Dummy" />
</script>
data/creaturescripts
XML:
<event type="healthchange" name="onHealthChange_Training_Dummy" script="onHealthChange_Training_Dummy.lua"/>
Lua:
local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not Player(creature) then...
in monster
XML:
<script>
    <event name="onHealthChange_Training_Dummy" />
</script>
data/creaturescripts
XML:
<event type="healthchange" name="onHealthChange_Training_Dummy" script="onHealthChange_Training_Dummy.lua"/>
Lua:
local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not Player(creature) then
        return false
    end
    
    local monsterID = monster:getId()
    local playerID = creature:getId()
    
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
    
    if not DPS_info[monsterID][playerID] then
        addEvent(send_dps_info, dps_check_time * 1000, playerID, monsterID)
    end

    DPS_info[monsterID][playerID] = (DPS_info[monsterID][playerID] or 0) + primaryDamage + secondaryDamage
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end
 
Solution
very good script but one thing can i make it show normal damage on trainers? why it show only dps and hide main tibia damage?
 
very good script but one thing can i make it show normal damage on trainers? why it show only dps and hide main tibia damage?
Because my monster only had 1 hp and no healing. xP

change both
return false

to
return primaryDamage, primaryType, secondaryDamage, secondaryType
 
Back
Top