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

trying revscript doesnt work?

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,391
Solutions
7
Reaction score
550
Hi Otland,

Just started playing around with scripting again with lockdown and all... I'm playing around with the new revscripts but i cant seem to understand it? I assumed they are basically modules you can add instead of registering the files on multiple scripts so i went ahead and tried it with a dpsCheck script i made awhile back. I have added the following:

/scripts/creaturescripts/dpsCheck.lua
Code:
local creatureevent = CreatureEvent("dpsCheck")

local dps = {}
local ms = 5000 -- time between dps checks

local function sayDPS(cid, guid)
    local player = Player(cid)
    if player then
        local dps = math.floor((dps[guid].damage / (ms / 1000)) + 0.5)
        player:say("DPS: ".. dps, TALKTYPE_MONSTER_SAY, false, player)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your damage per second is "..dps)
    end
    dps[guid] = {damage = 0, event = false}
end


function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if creature:getName() ~= 'Training Monk' then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    local player = attacker:getPlayer()
    if player then
        local guid = player:getGuid()
        local cid = player:getId()
        if not dps[guid] or not dps[guid].event then
            dps[guid] = {damage = 0, event = true}
            addEvent(sayDPS, ms, cid, guid)
        end
        dps[guid].damage = dps[guid].damage + (primaryDamage + secondaryDamage)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureevent:register()

reloaded the server and can see it has indeed registered:
Code:
>> ["creaturescripts"]
> gs_wyda_death.lua [loaded]
> scarab_death.lua [loaded]
> dpsCheck.lua [loaded]

But when the monster tries to load it it says:
Code:
[Warning - Monster::Monster] Unknown event name: dpsCheck

Am i missing something? Can revscripts not be used in this way?
 
Solution
Well you are missing to asign the onStatsChange to the creatureevent method
Lua:
creatureevent.onStatsChange = function(...)
that's the step you're missing
Well you are missing to asign the onStatsChange to the creatureevent method
Lua:
creatureevent.onStatsChange = function(...)
that's the step you're missing
 
Solution
Well you are missing to asign the onStatsChange to the creatureevent method
Lua:
creatureevent.onStatsChange = function(...)
that's the step you're missing

god damn it.... How did i miss that? thanks dude! this is great!

incase anyone wants it :)
Lua:
local creatureevent = CreatureEvent("dpsCheck")

local dps = {}
local ms = 5000 -- time between dps checks

local function sayDPS(cid, guid)
    local player = Player(cid)
    if player then
        local dps = math.floor((dps[guid].damage / (ms / 1000)) + 0.5)
        player:say("DPS: ".. dps, TALKTYPE_MONSTER_SAY, false, player)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your damage per second is "..dps)
    end
    dps[guid] = {damage = 0, event = false}
end

function creatureevent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if creature:getName() ~= 'Training Monk' then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    local player = attacker:getPlayer()
    if player then
        local guid = player:getGuid()
        local cid = player:getId()
        if not dps[guid] or not dps[guid].event then
            dps[guid] = {damage = 0, event = true}
            addEvent(sayDPS, ms, cid, guid)
        end
        dps[guid].damage = dps[guid].damage + (primaryDamage + secondaryDamage)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureevent:register()
 
Back
Top