Thread Tools Display Modes
05-31-11, 06:05 PM   #1
Clarkey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 8
How to determine if im in group or not

Hi, I've recently created an addon but I only want it to work if the user is in a party because it sends message to /p.

I need something to the effect of..

Code:
if(playerisinparty) then
 - do stuff
end
because at the moment, if you aren't in a party then i get spammed 'You aren't in a party'.
  Reply With Quote
05-31-11, 06:07 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Code:
if GetNumPartyMembers() > 0 then
    -- do stuff
end
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
05-31-11, 06:15 PM   #3
Clarkey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 8
Thanks, I tried that but doesn't work.

This is what I tried.

Code:
local noParty = GetNumPartyMembers()
if noParty > 0 then
-- do stuff
end
If im solo, it still tries to do it, returning the 'You aren't in a party.'
  Reply With Quote
05-31-11, 06:18 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
When are you calling the above segment of code?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-31-11, 06:22 PM   #5
Clarkey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 8
Code:
local enabled = "YES";
local channel = "PARTY";
local CControl = CreateFrame("Frame")

if GetNumPartyMembers() > 0 then

    if(enabled == "YES") then
        CControl:SetScript("OnEvent",function(...)
	    local args = {...}

-- do stuff

        end)
    end
end
CControl:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
DEFAULT_CHAT_FRAME:AddMessage("## CControl is ready.",1,1,1)
EDIT: fixed with...

Code:
local enabled = "YES";
local channel = "PARTY";
local CControl = CreateFrame("Frame")

    if(enabled == "YES") then
        CControl:SetScript("OnEvent",function(...)
	    local args = {...}
if GetNumPartyMembers() > 0 then

-- do stuff

        end
        end)
end
CControl:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
DEFAULT_CHAT_FRAME:AddMessage("## CControl is ready.",1,1,1)

Last edited by Clarkey : 05-31-11 at 06:38 PM.
  Reply With Quote
05-31-11, 06:41 PM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
The code is ran only once, hence at login (unless you are in a group at that point) will not set the script thus it will never run later on. Instead you should do this: ...

*Edit*

I noticed you noticed, hehe.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to determine if im in group or not


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off