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

DPS script TFS 1.2

Fantasma24

New Member
Joined
Feb 15, 2018
Messages
43
Solutions
1
Reaction score
0
Hello so iam really bad at programming. Could anyone make a script that would calculate player's dps? Basically what would i want is to player attack a dummy or something w/e for like 10 seconds for example and that code could print out my dps(damage per second).
Thanks in advance.
 
Solution
Got it! Mods have to edit my post so before they do that, here it is. Original thread updated.
Make sure you change everything, even .xml for that dummy, removed few lines there.

  1. Open data/creaturescripts/creaturescripts.xml
  2. Add <event type="healthchange" name="EventDPS" script="dps.lua" />
  3. Open data/events/events.xml
  4. Enable onTargetCombat
  5. Open data/events/scripts/creature.lua
  6. Find function Creature:onTargetCombat(target)
  7. Add before return RETURNVALUE_NOERROR
    Lua:
    if target:getName() == "Training Dummy" then
        target:registerEvent("EventDPS")
    end
  8. Create file data/creaturescripts/scripts/dps.lua with this code
    Lua:
    DPS_STORAGE = 50392...
Half the script is missing.

But, im asking about this error:
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
data/events/scripts/creature.lua:10: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/events/scripts/creature.lua:10: in function <data/events/scripts/creature.lua:9>

And it:
Lua:
function Creature:onTargetCombat(target)
    if self:isPlayer() then
        if self:getStorageValue(STORAGEVALUE_WAR_GREENPLAYER_BOOL) == 1 then
            if target:getStorageValue(STORAGEVALUE_WAR_REDPLAYER_BOOL) == 1 then
                return RETURNVALUE_NOERROR
            elseif target:getStorageValue(STORAGEVALUE_WAR_REDPLAYER_BOOL) == 0 then
                self:sendCancelMessage("You cannot attack someone that is on your team.")
                return false
            end
        elseif self:getStorageValue(STORAGEVALUE_WAR_REDPLAYER_BOOL) == 1 then
            if target:getStorageValue(STORAGEVALUE_WAR_GREENPLAYER_BOOL) == 1 then
                return RETURNVALUE_NOERROR
            elseif target:getStorageValue(STORAGEVALUE_WAR_GREENPLAYER_BOOL) == 0 then
                self:sendCancelMessage("You cannot attack someone that is on your team.")
                return false
            end
        end
    end
    
    if target:getName() == "Training Dummy" then
        target:registerEvent("EventDPS")
Helps me. . . So when i hit the Dummy, it appears the DPS, and at the chanel the same.
 
Back
Top