-
Posted by deltoide on Fri, 30 Dec 2011 09:06:07
Is there anything wrong with these commands? He should check (at the time I get into the game) who is more than 30 days off and remove from the guild
local kick = 0 local function onUpdate(self) if kick == 0 then if not CanGuildRemove() then return end for i=1,GetNumGuildMembers() do local y,m,d=GetGuildRosterLastOnline(i) if y then if y>0 or m>0 or d>30 then GuildUninvite(GetGuildRosterInfo(i)) end end end kick = 1 end end local f = CreateFrame("frame") f:SetScript("OnUpdate", onUpdate)
-
Posted by jnwhiteh on Fri, 30 Dec 2011 10:28:10
The first thing is this runs every single time the screen refreshes. This is absolutely insane. Run it ONCE. Don't use an OnUpdate. But no, other than that I don't see anything logically wrong with it.
-
Posted by deltoide on Sun, 01 Jan 2012 15:47:11
There are some players with more than 30 days without getting in my guild, I run this addon and it is not working properly, have no idea of what can be?
-
Posted by jnwhiteh on Sun, 01 Jan 2012 16:33:29
No. Debug it. Find out what's happening.
-
Posted by deltoide on Mon, 02 Jan 2012 09:18:00
I performed a check of the code and it really is working, but he kicked out the players with more than 30 days and is trying to remove self-guild also, what might be happening?
-
Posted by jnwhiteh on Mon, 02 Jan 2012 11:05:47
I don't know. You need to debug it. Add some print statements. Find out what is happening. This isn't something I can test for you.
-
Posted by deltoide on Thu, 05 Jan 2012 10:47:09
What exactly is happening is the following.
I activate the addon and so my game finishes loading the screen, it automatically kicks who has more than 30 days away.
What is happening is that it is trying to kick my self constantly until my game closes by flood.
What can be?
-
Posted by jnwhiteh on Thu, 05 Jan 2012 11:08:03
You are missing the point entirely. Let me attempt to be clearer.
- I don't have this addon.
- I don't have a guild in which I can test this.
- I've already given you one problem with the code you've posted.
- Therefore YOU have to debug this. You have to figure out what is going wrong.
Do this:
function KickOldFromGuild(actuallyKick) if not CanGuildRemove() and actuallyKick then return end for i=1,GetNumGuildMembers() do local y,m,d=GetGuildRosterLastOnline(i) if y then if y>0 or m>0 or d>30 then if actuallyKick then GuildUninvite(GetGuildRosterInfo(i)) else print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d)) end end end end end local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", function(self, event, ...) -- This line will run it in debug mode, so no one is kicked KickOldFromGuild(false) -- This line would run it and actually try to kick -- KickOldFromGuild(true) end)
Now it runs ONCE, not every single screen refresh. It also waits for the appropriate initialisation event to run. It also has a boolean flag that lets you run it in debug mode, where it prints instead of kicks. It also has a global name so you can call it whenever you want rather than having to reload your UI.
-
Posted by deltoide on Thu, 05 Jan 2012 12:45:30
These are codes that you spent working very well and I really appreciate your attention, but he's an obstacle that all my other codes were.
As soon as I enter the game nothing happens, it only executes the command when I give /reload
-
Posted by jnwhiteh on Thu, 05 Jan 2012 12:47:54
Then call KickOldFromGuild(true) or KickOldFromGuild(false). /run KickOldFromGuild(false).
-
Posted by deltoide on Thu, 05 Jan 2012 14:00:57
I edited the command line to call ... local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", function(self, event, ...)
-- This line will run it in debug mode, so no one is kicked -- KickOldFromGuild(false) -- This line would run it and actually try to kick KickOldFromGuild(true)
end)
but still it does not run when entering the game
-
Posted by jnwhiteh on Thu, 05 Jan 2012 14:04:35
Does it not run? How do you know it doesn't run? Do you have an error? Did you add a print statement to ensure that its not getting run?
I cannot debug this for you. You want it done another way, then fine:
local frame = CreateFrame("Frame") frame:SetScript("OnUpdate", function(self, elapsed) KickOldFromGuild(true) self:Hide() end)
It'll run once the game starts and run only once. I can't tell you why the other isn't working because you refuse to help me debug or provide any information.
-
Posted by deltoide on Thu, 05 Jan 2012 14:17:35
I know that is not working because when I went into the game, he did not send nor print or remove players with 30+ guild.
And so I gave the /reload he did the removal.
I changed the code as you showed, but still does not run unless I command to /reload
Sorry even if I have not given enough information, but I'm an extreme beginner in this subject and I do not know how to do a more detailed calculation
-
Posted by jnwhiteh on Thu, 05 Jan 2012 15:31:17
Open Interface Options -> Go to Help -> Display Lua Errors (select this). Does the code give you an error when you login?
-
Posted by deltoide on Thu, 05 Jan 2012 16:37:37
Ok, I activated the option that you mentioned.
I login but nothing happened, only after I /reload
-
Posted by jnwhiteh on Thu, 05 Jan 2012 16:49:21
Post every single file of your addon here. Everything, the .toc file, the .lua file. Everything.
-
Posted by deltoide on Thu, 05 Jan 2012 23:12:51
Sorry for the delay friend, but had to give attention to my family. The code of each file are ...
OldPlayer.toc ## Interface: 40000 ## Title: |cFF086BCDEOldPlayer|r ## Version: 0.1 ## Notes: Kick old players ## Author: Deltoide OldPlayer.lua *************************************** OldPlayer.lua function KickOldFromGuild(actuallyKick) if not CanGuildRemove() and actuallyKick then return end for i=1,GetNumGuildMembers() do local y,m,d=GetGuildRosterLastOnline(i) if y then if y>0 or m>0 or d>29 then if actuallyKick then --GuildUninvite(GetGuildRosterInfo(i)) else print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d)) end end end end end local frame = CreateFrame("Frame") frame:SetScript("OnUpdate", function(self, elapsed) KickOldFromGuild(true) self:Hide() end)
-
Posted by jnwhiteh on Thu, 05 Jan 2012 23:40:14
function KickOldFromGuild(actuallyKick) if not CanGuildRemove() and actuallyKick then return end for i=1,GetNumGuildMembers() do local y,m,d=GetGuildRosterLastOnline(i) if y then if y>0 or m>0 or d>29 then if actuallyKick then GuildUninvite(GetGuildRosterInfo(i)) else print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d)) end end end end end -- Wait until the guild information is available the first time after login local frame = CreateFrame("Frame") frame:RegisterEvent("GUILD_ROSTER_UPDATE") frame:SetScript("OnEvent", function(self, event, ...) print("Guild information is available, running OldPlayer checker") KickOldFromGuild(false) end)
That should do it, it will run anytime the guild roster is updated. The function was absolutely running before, if you had debugged it at all you would have seen that. The problem was the guild roster is not immediately available when logging in, so it saw you had 0 guild members, and didn't have to do any other work. The information is available on reload, since its already been loaded, so that's why it worked then.
-
Posted by jnwhiteh on Thu, 05 Jan 2012 23:41:24
At this point I'm going to have to ask you to either purchase my book, or look elsewhere for your help with World of Warcraft addons. I am incredibly time limited, and quite generous, but I can't continue to help someone who has no affiliation with this website in the least.
-
Posted by deltoide on Fri, 06 Jan 2012 00:20:15
I understand my friend, anyway thank you for all the help they gave me throughout this time.
May God bless you.