Thread Tools Display Modes
08-04-08, 04:50 AM   #1
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
HELP!! i cant get addon to whisper a player

yes, I know this is a newbie question but i have been working on this for some time.. I cannot get my addon to whisper a player when chat comes through on another channel. for example player#1 = /5 hey player#2 recieved whisper: (player#1: hey)

here is what i have so far plz help

btw i can get it to whisper if they both have the addon and it goes through the addon interface but i cant get the whisper to go through ingame
-----This part works and its all registered

SendAddonMessage("RT1", m1, "WHISPER", "*****");
SendAddonMessage("RT2", m2, "WHISPER", "****");
SendAddonMessage("RT3", RT_Version.." "..arg2.." "..id, "WHISPER", "****");


-----this part i cant get to work

SendchatMessage("RT1", m1, "WHISPER", "***");
SendchatMessage("RT2", m2, "WHISPER", "***");
SendchatMessage("RT3", RT_Version.." "..arg2.." "..id, "WHISPER", "***");

do i have to do this in another form or what am i doing wrong
it says that "failed to load sendchatmessage a nil value" o something along those lines
  Reply With Quote
08-04-08, 05:26 AM   #2
Vilkku
An Aku'mai Servant
 
Vilkku's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 35
I don't entirely understand all the different arguments you are using here.

SendchatMessage("RT1", m1, "WHISPER", "***");

Anyway, currently the arguments are
message: RT1
chattype: m1
language: WHISPER
receiver: ***
which don't seem like the proper ones

Here's an example of whispering to another player:
SendChatMessage("Hello World!", "WHISPER", "COMMON", "thet3rminat0r");

You can't leave the language out, so maybe do a faction check and then make a variable either common or orcish.

Last edited by Vilkku : 08-04-08 at 07:34 AM. Reason: Check Akryn's post, thanks for pointing that out :)
  Reply With Quote
08-04-08, 06:44 AM   #3
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
if you pass nil as the language, it will use your default
  Reply With Quote
08-04-08, 07:35 AM   #4
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
problem is its acting like it cant even find sendchatmessage as a command because its not saying bad parameters
  Reply With Quote
08-04-08, 07:41 AM   #5
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
and the script is a little more complicated then a static answer so the RT1 and m1 are places in a script for it to go back up and copy what was said in a certain channel and say it through another channel.. as of right now i can get this to work lets say if someone says something in /5 i can get it to come out through the addon interface. SO any one that is in the SAME GUILD can see it even if they are not in the same channel.

more specifically i want to be able to place on of my accounts in lets say shattrath city where there is trade chat. i am able to read trade chat even if i am not in a city at the time by using the addon RemoteTrade but now what i am doing is creating a conjoining addon that allowes for people to join a certain channel that when they type something in that channel it comes out in trade on the guy that i have placed in shatt.

As of right now i can get it to come out in the addonmessage but i cant get the chatmessage one to work. If i can get that to work I am done
  Reply With Quote
08-04-08, 07:44 AM   #6
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
Originally Posted by thet3rminat0r View Post
problem is its acting like it cant even find sendchatmessage as a command because its not saying bad parameters
That's because it's SendChatMessage() and not SendchatMessage()...you didn't capitalize the "C" in Chat.
  Reply With Quote
08-04-08, 07:52 AM   #7
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
SendChatMessage("msg" [,"chatType" [,"language" [,"channel"]]]);(http://www.wowwiki.com/API_SendChatMessage)
  Reply With Quote
08-04-08, 08:23 AM   #8
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
ok so all the errors are gone here is what the new code looks like

SendAddonMessage("RT1", m1, "WHISPER", "*****");
SendAddonMessage("RT2", m2, "WHISPER", "****");
SendAddonMessage("RT3", RT_Version.." "..arg2.." "..id, "WHISPER", "****");

SendChatMessage("RT1", "CHANNEL", nil, "2")
SendChatMessage("RT2", "CHANNEL", nil, "2")
SendChatMessage("RT3", "CHANNEL", nil, "2")


the only problem now is that instead of taking what is said in the other channel it says RT1 RT2 and RT3


thx for the help and im getting closer

Last edited by thet3rminat0r : 08-04-08 at 08:44 AM.
  Reply With Quote
08-04-08, 09:19 AM   #9
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
Originally Posted by thet3rminat0r View Post
ok so all the errors are gone here is what the new code looks like

SendAddonMessage("RT1", m1, "WHISPER", "*****");
SendAddonMessage("RT2", m2, "WHISPER", "****");
SendAddonMessage("RT3", RT_Version.." "..arg2.." "..id, "WHISPER", "****");

SendChatMessage("RT1", "CHANNEL", nil, "2")
SendChatMessage("RT2", "CHANNEL", nil, "2")
SendChatMessage("RT3", "CHANNEL", nil, "2")


the only problem now is that instead of taking what is said in the other channel it says RT1 RT2 and RT3


thx for the help and im getting closer
If RT1, RT2, etc are locals, putting them in quotes defines them as text instead of the local.

Edit: Same with any of the other locals you're calling (ie. CHANNEL)
  Reply With Quote
08-04-08, 09:35 AM   #10
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
ok well i figured out why i was having soo much trouble i cant exactly do what i have been doing so i have to change tactics. U cannot use an addonchatmessage to broadcast into trade channel but is it possible to be able to "copy" a message in a channel and say it in another channel?


for instance /8 WTB such and such {OUT COMES} /2 WTB such and such

could there be something in this that i could use?

TheMessage = string.find( arg2, "(%w+)[%s%p]*(.*)");


SendChatMessage(TheMessage, "TRADE", GetDefaultLanguage("player"), 2);

Last edited by thet3rminat0r : 08-04-08 at 09:47 AM.
  Reply With Quote
08-04-08, 09:48 AM   #11
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Please post your complete code.
  Reply With Quote
08-04-08, 09:58 AM   #12
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
ok well i had to start anew but here is an example that i think would work for what i want.. the addon is called multiboxer and it will forward whispers to a certain person basically u are only looking for the sendchatmessage part as well as how that works as sendaddonmessage wont work for what im doing.


Code:
local AssistingBarID = 1
local MainBarID = 2
local AutomaticallyFollow = true
local AutomaticallyAcceptQuests = true
local AutomaticallyChangeLootingToFFA = true



function MultiBoxer_OnEvents()
    if (event=="ADDON_LOADED") then         -- load saved variables
        -- load saved variables
    elseif (event=="PLAYER_REGEN_ENABLED") then 
         if (AutomaticallyFollow==true) then
             if (not UnitIsPartyLeader("player")) then
                 FollowLeader();
             end
         end
    elseif (event=="PARTY_INVITE_REQUEST") then -- make sure the person inviting is on your "trusted" list.
--        for i = 1,getn(TrustedPlayers) do
--            if (string.lower(arg1)==string.lower(TrustedPlayers[i])) then
                AcceptGroup();
                StaticPopup1:Hide();
--            end
--        end
    elseif (event=="PARTY_LEADER_CHANGED") then
        if (UnitIsPartyLeader("player")) then -- if party leader changed, and your the leader, then lead (others will follow YOU now).
            Lead();
        end 
    elseif (event=="QUEST_DETAIL") then
        AcceptQuest();
    elseif (event=="QUEST_ACCEPT_CONFIRM") then -- ESCORT QUESTS
        AcceptQuest();
    elseif (event=="PLAYER_XP_UPDATE") then
        	")..":- "..UnitXP("player")..":- "..UnitXPMax("player"), "PARTY");
    elseif (event=="RESURRECT_REQUEST") then
        AcceptResurrect();
    elseif (event=="UNIT_COMBAT") then
        SendAddonMessage("MultiBoxer", "TakingDamage:-", "PARTY");    
    elseif (event=="CHAT_MSG_ADDON") then 
        if (arg1=="MultiBoxer") then 
           local startPos, endPos, TheCommand, TheMessage = string.find( arg2, "(%w+)[%s%p]*(.*)");
           if (TheCommand=="Followme") then
                if (arg4~=UnitName("player")) then
                    FollowLeader();
                end
           elseif (TheCommand=="InfoMessage") then
               if (arg4~=UnitName("player")) then
                   WhisperYourself(TheMessage); -- NEED A BETTER WAY TO MESSAGE OTHER THEN WHISPERING
               end
           elseif (TheCommand=="PromoteToLeader") then
               if (UnitIsPartyLeader("player")) then -- if your leader, then pass leadership
                   PromoteToLeader(TheMessage);
               end
           elseif (TheCommand=="TakingDamage") then
               if (not UnitIsPartyLeader("player")) then
                  --  AlertLeader(arg4.." IS TAKING DAMAGE!")
               end
           elseif (TheCommand=="FollowLeader") then
               if (not UnitIsPartyLeader("player")) then
                   FollowUnit("party1");  
                   ChangeActionBarPage(AssistingBarID); 
               end
           end
        end

    end
end

function AlertLeader(TheMessage)
    SendChatMessage(TheMessage, "WHISPER", GetDefaultLanguage("player"), UnitName("party1"));
end

function WhisperYourself(TheMessage)
    SendChatMessage(TheMessage, "WHISPER", GetDefaultLanguage("player"), UnitName("player"));
end

function AddTrustedPlayer(TrustedPlayer)
               tinsert(TrustedPlayers, TheMessage)
end

function RemoveTrustedPlayer(TrustedPlayer)
               for i = 1,getn(TrustedPlayers) do
                   if (strlower(TrustedPlayers[i])==strlower(TheMessage)) then
                       SendChatMessage(tremove(TrustedPlayers, i).." was sucessfully removed from your TrustedPlayers list.");    
                   end
               end

end

function ListTrustedPlayers()
    for i = 1,getn(TrustedPlayers) do
       WhisperYourself(TrustedPlayers[i])
    end
end

function Lead()
    SendAddonMessage("MultiBoxer", "Followme:-", "PARTY");
    ChangeActionBarPage(MainBarID);
end

function FollowLeader()
    SendAddonMessage("MultiBoxer", "FollowLeader:-", "PARTY");
end

function NewLeader(PartyMember)
    SendAddonMessage("MultiBoxer", "PromoteToLeader:-".." "..PartyMember, "PARTY");
end

local frame = CreateFrame("Frame");
  frame:SetScript("OnEvent", MultiBoxer_OnEvents);
  frame:RegisterEvent("PLAYER_REGEN_ENABLED");
  frame:RegisterEvent("CHAT_MSG_ADDON");
  frame:RegisterEvent("PARTY_INVITE_REQUEST");
  frame:RegisterEvent("PARTY_LEADER_CHANGED");
  frame:RegisterEvent("QUEST_DETAIL");
  frame:RegisterEvent("QUEST_ACCEPT_CONFIRM");
  frame:RegisterEvent("PLAYER_XP_UPDATE");
  frame:RegisterEvent("RESURRECT_REQUEST");
  frame:RegisterEvent("UNIT_COMBAT"); -- FIRES WHEN AN NPC OR PLAYER IS IN COMBAT AND TAKES DAMAGE
  Reply With Quote
08-04-08, 10:17 AM   #13
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
*sigh*

Ok then ... let's see:

- register "CHAT_MSG_CHANNEL"

- join your "internal certain" channel

- create an OnEvent handler
see if arg9 is your "internal certain" channel name
if this is true then fire up SendChatMessage(arg1, "CHANNEL", nil, GetChannelName("Trade - CityName"))
(replace CityName with something usefull)


http://www.wowwiki.com/API_SendChatMessage
http://www.wowwiki.com/API_GetChannelName
http://www.wowwiki.com/Events/Communication
  Reply With Quote
08-04-08, 11:53 AM   #14
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
sry for the frustration Duugu im just new to this.

ok so here is what i have so far sry it took so long to post i had to nap for a bit

Code:
function frame_OnLoad()
this:RegisterEvent("CHAT_MSG_CHANNEL");
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE");
this:RegisterEvent("CHAT_MSG_ADDON");

end

function Frame_OnEvent()
if (event=="CHAT_MSG_CHANNEL") 
	and (arg9=="tradechat") then 
           local startPos, endPos, TheCommand, TheMessage = string.find( arg9, "(%w+)[%s%p]*(.*)") and
				 SendChatMessage(arg1, "2", nil, GetChannelName("Trade - Shattrath"));


as of right now it doesnt give me any errors but it also doesnt post in trade.
I probably have one of the if and then's wrong so PLZ help and sry for the frustration
  Reply With Quote
08-04-08, 12:07 PM   #15
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
According to http://www.wowwiki.com/API_SendChatMessage the arguments for SendChatMessage are
message, chatType, language, channelName

Valid chat types are http://www.wowwiki.com/ChatTypeId

Now let's see your code:
SendChatMessage(arg1, "2", nil, GetChannelName("Trade - Shattrath"));

- arg1 is the message. great.
- "2" ... wtf? This isn't a valid chattype. For the trade channel the chat type is "CHANNEL".
  Reply With Quote
08-04-08, 12:13 PM   #16
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
fsafsageacvxz god i need some sleep
  Reply With Quote
08-04-08, 01:16 PM   #17
thet3rminat0r
A Deviate Faerie Dragon
Join Date: Aug 2008
Posts: 10
ok pretty much i cant get this to work, i changed what u said i get no error's ive changed it so it would whisper some on the text changed channels changes ands to then's and vice versa. If some one wants to look into it plz do but i think duguu is about to blow his top at me so any suggestions would be great
  Reply With Quote
08-04-08, 01:19 PM   #18
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Code:
local MultiBoxer = CreateFrame("Frame")

MultiBoxer:RegisterEvent("CHAT_MSG_CHANNEL")

function MultiBoxer_OnEvent()
     if (event=="CHAT_MSG_CHANNEL") and (arg9=="tradechat") then 
          SendChatMessage("msg" [,"chatType" [,"language" [,"channel"]]]); --Edit this
     end
end
__________________
Never be satisfied with satisfactory.

Last edited by Cralor : 08-04-08 at 01:22 PM.
  Reply With Quote
08-04-08, 01:32 PM   #19
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
Make sure when you use SendChatMessage() that the variables you're entering is correct. If you're not throwing errors, than there's something wrong with what you're feeding into that API.

SendChatMessage("msg" [,"chatType" [,"language" [,"channel"]]])

msg: The message
chatTyle: The type of chat (ie. PARTY, WHISPER, CHANNEL, RAID, etc)
language: This is optional, but you have to call nil if bypassing
Channel: If it's a whisper, it's the receiver's name. If a channel, it has to be the numerical channel number (1 = General, 2 = Trade, etc).
  Reply With Quote
08-04-08, 01:35 PM   #20
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
Originally Posted by Slakah View Post
Firstly your missing :SetScript() secondly your using the global args, which are being removed, and finally use local functions stop polluting global.
Not the most helpful response...
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » HELP!! i cant get addon to whisper a player


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