I'm trying to develop an addon card game. And i have to gather informations about cards have been played.
I search a usefull way to gather informations like :
When a card is played, the player send a chat message in an "invisible chat" or perhaps via the SendAddonMessage but i failed.
I don't understand the utility of SendAddonMessage() , and how it's work.
If anyone have a suggestion about an usefull way to share information Through a channel ...
(sorry for my english i'm french ;))|||For SendAddonMessage(), sending is simple:
SendAddonMessage("MyAddon", "message", "WHISPER", "Player")
If you want, it's also possible to use "GUILD", "BATTLEGROUND, "RAID", or "PARTY" instead of "WHISPER" (in which case you wouldn't give the "Player" part). Note that you *can't* use "CHANNEL" as the type -- if you want your addon to have its own channel, you'll have to use the regular SendChatMessage() and hide the messages from the player.
The receiving is the fun part. Your addon will need to register for the event CHAT_MSG_ADDON. When it gets the even, it will get four arguments, which are the same as the four you sent, except that the last is the name of the sender.
So, something like:
function MyAddon_OnEvent()
if event == "CHAT_MSG_ADDON" then
if arg1 ~= "MyAddon" then return end
-- do things depending on the other arguments here
end
end
You'll also have to create a frame (either programmatically or through an XML file) and have it register for the CHAT_MSG_ADDON event, with MyAddon_OnEvent as the handler.|||Ok ! Thanks i'll test it and i'll tell you if it's work !|||Hello ! I have some troubles but this time it's with the SlashCmdList function,
It's does'nt work : my code :
Code:
function CreerPartie()
JoinPermanentChannel("Contree", nil, 1, nil);
ListChannels();
end
function Contree_OnLoad()
SLASH_CONTREE = "/contree";
SlashCmdList["CONTREE"] = function()
CreerPartie();
end
And my XML :
Code:
<Script File="HelloWorld.lua"/>
<Frame name="HelloWorldFrame">
<Scripts>
<OnLoad>
Contree_OnLoad();
</OnLoad>
</Scripts>
</Frame>
And when i type /contree in WoW it's does'nt work (message with /help invite etc ...)
I've searched a solution in the forum and google but i still don't find a solution, so if anyone have an idea :)
Thanks|||Your SLASH_CONTREE needs to be SLASH_CONTREE1. WoW allows you to hook multiple slash commands up to one function, and requires the number there even if you're only doing one.|||Ok thanks ! it's works !
No comments:
Post a Comment