WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Somethings wrong with this? (https://www.wowinterface.com/forums/showthread.php?t=49826)

morpheusxeno 09-02-14 07:53 AM

Somethings wrong with this?
 
Code:

elseif (event == "GUILD_ROSTER_UPDATE" and IsInGuild() ~= nil) then
                local bootNum = 0
                for i = 0, GetNumGuildMembers() do
                        local name, rank, rankIndex, level, classLocale, zone, note, officernote, online, status, class = GetGuildRosterInfo(i)
                       
                        -- check for blacklist
                        local index = BlackList:GetIndexByName(name)
                        if (index > 0) then
                                local player = BlackList:GetPlayerByIndex(index)

                                local alreadywarned = false
                                for warnedname, timepassed in pairs(Already_Warned_For["GUILD_ROSTER"]) do
                                        if ((name == warnedname) and (GetTime() < timepassed+10)) then
                                                alreadywarned = true
                                        end
                                end
                                if (not alreadywarned) then
                                        Already_Warned_For["GUILD_ROSTER"][name]=GetTime()+300
                                        BlackList:AddSound()
                                        BlackList:UpdateDetails(index, nil, nil, level, class, nil)
                                        BlackList:AddErrorMessage(name .. " is on your Black List and is in your GUILD.", "red", 5)
                    if(player["reason"] ~= "") then
                                                BlackList:AddMessage(name .. " is on your Black List and is in your GUILD, reason:" .. player["reason"], "red")         
                                    else
                                                BlackList:AddMessage(name .. " is on your Black List and in your GUILD", "red")         
                                        end


Not getting a lua error, but the info isnt being transmitted to other guild members

Choonstertwo 09-02-14 09:08 AM

I can't see any obvious mistakes. Try adding some print statements to various places to help you see what's going on.

If you post all of your code, we may be able to help more.

Phanx 09-02-14 06:02 PM

Also, this isn't related to whatever problem you're having, but:

Code:

if (... and IsInGuild() ~= nil) then
You should omit the explicit check against nil. In WoD all 1/nil returns are being changed to proper true/false booleans, and nil evaluates to a boolean false anyway, so a simpler implicit boolean check will not only be more readable and more efficient, but also work in both API environments:

Code:

if ... and IsInGuild() then
I'd also suggest moving the IsInGuild check inside the event check, so that if the event fires when you're not in a guild, your code won't waste time checking all the other events. Better yet, don't register the event at all if the player isn't in a guild. ;)

morpheusxeno 09-03-14 04:16 PM

Thank you Phanx you too Choonstertwo.


All times are GMT -6. The time now is 12:52 AM.

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