PDA

View Full Version : DPS example script


Torax
05-24-2010, 03:13 AM
Due to an oversight, the example script was not included in this patch. Here is the DPS sample script. Create a folder in your main directory called addons. (Crowns of Power/main/addons). Create a new file called dps.lua and paste this into it:


-- Register the chat command /dps
addChatCommand("dps");

-- Function to reset DPS stats
function resetStats()
damageTable = {};
totalDamage = 0;
end

-- Initilize variable when script first executes
resetStats()

-- Called when the player first spawns
function onLoaded()
status("DPS monitor loaded.");
isLoaded = true;
end

-- Report the damage to the appropriate channel. func is the function to use to report the damage, see chatcmd_dps
function reportDamage(func)

sorttbl = GetSortedTable(damageTable)
place = 1;
for idx,row in pairs(sorttbl) do

dmgPct = round(((row.value / totalDamage) * 100), 2);
func(place .. ". " .. row.key .. " - " .. commas(row.value) .. " (" .. dmgPct .. "%)")
place = place + 1;
if(place > 10) then break end

end

end

-- Called when /dps is entered in chat. Anything after /dps is in the text variable
function chatcmd_dps(text)
if text == "say" then
chatSay(" -= DPS Report =- ");
reportDamage(chatSay);
elseif text == "group" then
chatGroup("=DPS for group=");
reportDamage(chatGroup);
elseif text == "guild" then
chatGuild("=DPS for group=");
reportDamage(chatGuild);
elseif text == "reset" then
status("DPS Monitor reset");
resetStats();
else
status("DPS Monitor 1.0")
status("==== COMMANDS ====")
status("/dps group (Report DPS to group)")
status("/dps say (Report DPS to say)")
status("/dps guild (Report DPS to guild)")
status("/dps reset (Reset current DPS statistics)")
end
end

-- Event called every time a player does damage in your group
function onDamageDone(damageDone, attackerName, defenderName, hitType, damageType)

-- Convert your damage to your name
if (attackerName == "You" or attackerName == "Your") then attackerName = playerInfo("name") end

if damageTable[attackerName] == nil then
damageTable[attackerName] = 0;
end

damageTable[attackerName] = damageTable[attackerName] + damageDone;

totalDamage = totalDamage + damageDone;
end

-- Reset stats when you join a new group
function onGroupJoin()
if isLoaded == nil then return end
status("DPS Monitor stats reset");
resetStats();
end

-- Reset stats when you leave a group
function onGroupLeave()
if isLoaded == nil then return end
status("DPS Monitor stats reset");
resetStats();
end

andylord
05-24-2010, 08:37 AM
Could we have an example that shows damage taken please trying to get my head around it

yneos
05-24-2010, 09:31 AM
it says
-=DPS report=-
1.Zaraki 8093 (100%)

so name, how much damage and the percent of damage seen

but now it makes me wonder why does it say DPS, when DPS is damage per second? there is no calculation for that xD

Torax
05-24-2010, 01:37 PM
Feel free to edit the script and make changes. We will be happy to include to include any updates the community makes in upcoming patches,

You are correct that the name "DPS" is a bit of a misnomer as no damage per second is actually calculated. It would be easy to modify the script however and hook it up to the enter/exit combat events to figure it out.

spiker8420
05-24-2010, 01:48 PM
if I use notepad instead of lua, will it still work?

yneos
05-24-2010, 01:52 PM
yes you can use notepad, and yes i know you can change it :P im trying to make myself a healing one. but i keep getting an error. on the damagetable, and ive tried healingtable.


and another question. i was trying to help spikedra set his up. He created the "addons" folder in the main folder of COP. he copied the dps script into notepad, saved the file as dps.lua. at first it was dps.lua.txt i had him change that, it is now a lua file. when he logs into COP it does not work. i was useing screen share with him on skype so i know he isn't lying to me :P he doesn't have his in C: > program > cop > main > addons his is like C: > user > games > cop > main > addons i dont think it should have made a difference, but it seems it is.

Paladin016
05-24-2010, 02:46 PM
doesn't work for me...

spiker8420
05-24-2010, 09:29 PM
make sure that you save the file as dps.lua what will auto happen is ur comp should save it as a txt doc and u need to go into ur folder and change the settings so that its just the .lua and not .lua.txt