Thread Tools Display Modes
03-10-10, 06:44 PM   #1
Zinc
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
Ignoring certain players.

.lua
Code:
  local cf = CreateFrame("FRAME", "MParent");
  local frame = CreateFrame("FRAME", "MParent");

  cf:RegisterEvent("CHAT_MSG_WHISPER");
  frame:RegisterEvent("CHAT_MSG_CHANNEL_JOIN");

  local function autoResponse(first,second,third,player,fifth,sixth,seventh,eight,nine,ten,eleven)
     if player == "Carth" then
        print(player .. "Is a fag")
     elseif eleven == "OOC" then
       print("|CFF00FF00" .. player .. " has entered the channel.|R");
       SendChatMessage("Welcome to Ravenguard WoW OOC, " ..  player ..  ".  It is Tuesday, March 10, 2010. The guild of the day is Omega.  Have a good day!  Also, check out the forums for a new Custom Class contest." ,"WHISPER" , nil,player);
     end
  end

  local function commandHandler(empty,fag,message)
       print("Event Fired.");
         if message == "$unsubscribe" then
           print("The user would like to unsubscribe.");
         end
  end

     cf:SetScript("OnEvent",commandHandler);
  frame:SetScript("OnEvent",autoResponse);
This is my currect code so far. Now, as you can see, it will automatically whisper a player when joining a channel: In this example, the channel is named OOC. Now, I want to make an '$unsubscribe' command, so when people whisper me it, it will not whisper that character on joining. So far, I don`t know how to do this. I also need to make the list live when I logout, how do I do this?
  Reply With Quote
03-10-10, 06:53 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
The only way I can see of making the list live is if you publish the list across other users of the same addon so that an ever growing list is active as long as one person with that addon accepting updates of the data is online. Outside of that I don't think it would be possible as the data is stored in your wtf files and read while in game.
__________________
  Reply With Quote
03-10-10, 07:00 PM   #3
Zinc
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
Alright, Xrystal. Unfortunately, it is a personal AddOn, but thanks anyway.

Is there a way I can create a text file or publish in a text file the name of a player who whispers the command, and then update it manually?
  Reply With Quote
03-10-10, 07:39 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
If you want to generate a list of names for your own use that will exist when you next log in then that should be possible using the WTF files I mentioned to store data in. It will automatically be loaded the next time you run wow with that addon enabled.

When you mentioned live I thought you meant that you wanted the addon to stay running. Unfortunately that isn't possible.

Have a look at wowwiki for SavedVariables and you should find a nice tutorial on how they work. It was where I started out from.
__________________
  Reply With Quote
03-10-10, 09:29 PM   #5
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Register a saved variable in your table of contents file with the SavedVariables metadata tag.

Code:
## SavedVariables: MyAddonIgnoredUsers

Then register the ADDON_LOADED event to populate your saved variable.

Code:
local addonName = ...
local loadHandler = function(self, event, addon)
     -- only proceed if our addon is the one being loaded
     if addon == addonName then
          -- create a new table if it doesnt exist, otherwise use the old one
          MyAddonIgnoredUsers = MyAddonIgnoredUsers or {}
     end
end
Then in command handler, add the user to the ignored table.

Code:
MyAddonIgnoredUsers[<insert player name here>] = true
Then in your CHAT_MSG_CHANNEL_JOIN event, check to see if their name is in the table. If it is, don't send them a message.
  Reply With Quote
03-11-10, 01:58 AM   #6
zero-kill
A Firelord
 
zero-kill's Avatar
Join Date: Aug 2009
Posts: 497
And let us pray that Blizzard does not give in to free name changes.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Ignoring certain players.

Thread Tools
Display Modes

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