Thread Tools Display Modes
04-07-11, 11:43 AM   #1
Lanodar
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 6
Help with CHAT_MSG_WHISPER

Hey,
i've got a problem with the CHAT_MSG_WHISPER event.

This is my code: (just to test it )

Code:
CRTFrame:RegisterEvent("CHAT_MSG_WHISPER");
local function eventHandler(self, event, ...)

   local OtherPlayer = arg2;
   local message = arg1
   print(arg1)
   print(OtherPlayer)
   print(arg2)
end
CRTFrame:SetScript("OnEvent", eventHandler);
My problem is, that OtherPlayer and arg2, both return "nil" and I don't know why. arg1 returns the Whisper message
  Reply With Quote
04-07-11, 11:54 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
That's easy: Since ... 4.0 (?) arg1-x are not longer global variables. So you can't use them without initializing them. You have to use the function parameters instead.

You could do
Code:
local arg1, arg2 = ...
[E]
You might ask "and why has arg1 a value?". I would say that's just luck. Someone somewhere is initializing a global variable named arg1 and puts some data in it. But it's nothing you could depend on.

Last edited by Duugu : 04-07-11 at 11:58 AM.
  Reply With Quote
04-07-11, 12:00 PM   #3
Lanodar
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 6
It works thanks
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with CHAT_MSG_WHISPER


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