WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Played Killed Target Event? (https://www.wowinterface.com/forums/showthread.php?t=35163)

RightLegRed 09-26-10 02:13 AM

Played Killed Target Event?
 
I've looked through the wiki and other sites, I can't seem to find an event that fires when the player kills its target.

Is there one? If not, what would be an alternative?

Xubera 09-26-10 02:24 AM

http://www.wowwiki.com/API_COMBAT_LO...ecial_Events_2

I cant remember if it includes you even if not in a party, but it definately wont work on other players in a raid, only party members

RightLegRed 09-26-10 02:26 AM

Quote:

Originally Posted by Xubera (Post 207339)
http://www.wowwiki.com/API_COMBAT_LO...ecial_Events_2

I cant remember if it includes you even if not in a party, but it definately wont work on other players in a raid, only party members

I'll try that, thanks. Also, I appear to have placed this in the wrong section, could someone please move it for me?

RightLegRed 09-28-10 12:15 PM

I'm sorry for the double post and the late reply - only just got to testing this. This doesn't appear to work. I'm new with events and don't fully understand how they're used in WoWLUA.

Here's my code -
Foo.lua
Code:

if event == "PARTY_KILL" then
 hunted=hunted+1
end

slash_command.lua
Code:

SLASH_HUNT1 = "/hunt"
SlashCmdList["HUNT"] = function(msg, editBox)
        if hunted == nil then
        SendChatMessage("You haven't killed any monsters");
        else
        SendChatMessage(hunted, "SAY");
        end
end

Foo.xml
Code:

<Frame name="Foo_Frame">
  <Scripts>
    <OnLoad>
        Foo_OnLoad();
    </OnLoad>
    <OnEvent>
        Foo_OnEvent(self, event, ...); -- The ... parameter passes all arguments that would otherwise be implicitly sent prior to 3.0.
                                      -- As of 3.0, you will need to explicitly send these arguments (as done here). 
    </OnEvent>
  </Scripts>
</Frame>

AutoLoot1.toc
Code:

## Interface:
## Title: Hunt Tracker
## Author: Surgeon
## Version: 1.00.0
## URL: N/A
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariablesPerCharacter: hunted
Foo.lua
Foo.xml
slash_command.lua

Could someone tell me why it isn't working? Thanks (:

Xubera 09-28-10 01:59 PM

Foo.lua
Code:

function Foo_OnLoad(self)
    self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    SLASH_HUNT1 = "/hunt"
    SlashCmdList["HUNT"] = function(msg)
        if hunted == nil then
            SendChatMessage("You haven't killed any monsters", "SAY");
        else
            SendChatMessage("Number of killing blows: "..hunted, "SAY");
        end
    end
end

function Foo_OnEvent(self,event,...)
    local timestamp, type = ...
    if type == "PARTY_KILL" then
        hunted = ( hunted or 0 ) + 1 --in case hunted isnt declared yet
    end
end

Foo.xml
Code:

<Frame name="Foo_Frame">
  <Scripts>
    <OnLoad>
        Foo_OnLoad(self);
    </OnLoad>
    <OnEvent>
        Foo_OnEvent(self, event, ...);
    </OnEvent>
  </Scripts>
</Frame>

AutoLoot1.toc
Code:

## Interface:
## Title: Hunt Tracker
## Author: Surgeon
## Version: 1.00.0
## URL: N/A
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariablesPerCharacter: hunted
Foo.lua
Foo.xml


v6o 09-28-10 05:26 PM

Don't forget to actually check that you're the one killing (source guid/name)

Torhal 09-28-10 09:43 PM

Is this contained in a function, or is it really in the file body?

Code:

if event == "PARTY_KILL" then
 hunted=hunted+1
end

If the latter, that's your problem - there is no "event" at that point, and the code is only called once.

v6o 09-29-10 01:22 AM

If you're gonna use XML you should start and end the file with

Code:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">


>> your frame's here <<

</Ui>

Also you can change
SendChatMessage() which will actually send a message to the server for everyone to see to print() or DEFAULT_CHAT_FRAME:AddMessage() or ChatFrame1:AddMessage() which only you will be able to see.


mikma 09-29-10 07:55 AM

http://wowprogramming.com/snippets/W..._party_kills_4


All times are GMT -6. The time now is 02:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI