Help with simple Addon
I need a little help with this first simple addon i am developing. Basically at the moment it will work outside of PvP but within pvp it does not work.
The basic premise of this addon is to get the current number of players in the group and output the number of spaces left in the group. This is just a simple base start for a more complicated addon i plan on developing in the future. So basically i have my initialize function that contains Code:
function TCC:Initialize() Code:
function OnGroupMemberLeft(eventCode, characterName, reason, wasLocalPlayer, amLeader) Code:
function OnGroupMemberJoined(eventCode, characterName) Code:
function groupMetrics() Thank you |
You need to be a bit more specific.
What do you mean with "in PvP" and what does not work? The code you showed seems fine to me. |
Thank you for replying, sorry for not being that specific.
In PvP i mean when in Cyrodiil, and when a player leaves or joins a group nothing is displayed in my textbuffer. However once i am outside of Cyrodiil say in deshaan or any other zone it works as expected. |
Ok, my first suspect would be your Log method. Try to use the provided api method d() instead and see if it makes a difference.
You should also put an output into your OnGroupMemberLeft and OnGroupMemberJoined handlers and at the beginning of groupMetrics to see if they get called. |
As sirinsidiator said I don't see anything that would prevent output either. Again as sirinsidiator said try using d("some message") in each function to see if they are called. My guess would be either there is a problem with your TCC.LogMsg function or TCC:Initialize() is not being called to initialize the event registers. Do you unregister those events anywhere? If so I would check that. Where are you calling TCC:Initialize() from, can we see that code?
If you still can't figure it out paste the code somewhere, like on http://pastebin.com/ and give us a link for it. Other things: You should make groupMetrics local: Lua Code:
IsPlayerInGroup(string name) takes a string name as its parameter, not the word "group", unless your characters name is group :) Looking at the code I think you can use any form of the characters name: rawName, unitName, displayName, but I've not used the function so I would recommend testing these to check and see which ones work properly. Lua Code:
|
Thank you for taking your time to reply to me.
I am going to look at putting in to d() messages now. With regards to Code:
self.inGroup = IsPlayerInGroup("group") I will update you all after i have done some more debugging. Thanks again. |
Right I have figured out what I had done wrong, I had accidently commented out my TCC.Initialize()
When I convert the groupMetrics() to a local function I get an error message referring to function expected , something along those lines. However my addon is working now if I keep it as it is. |
Quote:
This wont work because groupMetrics is defined BELOW someplace that it is used in the code: Lua Code:
It must be defined above any calls to it in the code file like this: Lua Code:
Although it is working you should still change groupMetrics to local. The reason is if someone else, in some other addon does the same thing, uses the term groupMetrics in their addon and they don't make theirs local either the two will interfere with each other and it will causes problems in both addons. |
Oh thank you very much i will make sure i do this .
Thanks again :) |
All times are GMT -6. The time now is 09:54 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI