PDA

View Full Version : Help please, OnEvent handling <-(noob)


Duck
03-13-2005, 11:51 AM
Ok, I have some programming experience, and a little scripting experience, but nearly all of this stuff is new to me.

I'm trying to create a script that will recieve a message from a player and then cast the spell that player asks for onto the player. Basically a simpler verison of WhisperCast, but without all the extra GUI's and stuff.

As I said I'm pretty much a total newb to this so I have no idea what I'm doing, I'm more or less trying to copy/paste code from other addons and then modify it to work for me.

Anyway here's what I have so far:
(tellspell.toc)
## Interface: 4216
## Title: Tellspell
## Notes: Cast spells on people!
tellspell.xml
(tellspell.xml)
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="tellspell.lua"/>
<Frame name="tellspell">
<Scripts>
<OnLoad>
tellspell_OnLoad();
</OnLoad>
<OnEvent>
tellspell_OnEvent(event);
</OnEvent>
</Scripts>
</Frame>
</ui>
(tellspell.lua)
function tellspell_OnLoad()

end

function tellspell_OnEvent(event)
local info = ChatTypeInfo["SYSTEM"];
if (event == "CHAT_MSG_WHISPER") then
ChatFrame1:AddMessage("New Message Successfully Parsed!", info.r, info.g, info.b, info.id);
end
end

What this is supposed to do is pop up a message whenever I recieve a tell, just so I know that my code is realizing I actually recieved a tell. However, it is doing nothing. I don't get any errors, it says that it is loading in the log file, but nothing happens.

And while you're reading this 2 other questions:

1) Once someone sends me a message how do I pull out the persons name and what they sent me? (From whispercast it looks like these are arg1 and arg2, with playername=arg2 and message=arg1, am I correct there?)

2) How would I go about casting a spell in the LUA file? (guessing it's the same as the script command CastSpellByName("spellname"); but do I have to put <script></script> around it or anything like that?)

Thanks a ton in advance for any help :)

Duck
03-13-2005, 12:50 PM
(tellspell.lua)
function tellspell_OnLoad()

end

function tellspell_OnEvent(event)
local info = ChatTypeInfo["SYSTEM"];
if (event == "CHAT_MSG_WHISPER") then
ChatFrame1:AddMessage("New Message Successfully Parsed!", info.r, info.g, info.b, info.id);
end
end


Ok, found it, needed to add this in to the lua:
function tellspell_OnLoad()
this:RegisterEvent("CHAT_MSG_WHISPER");
end

function tellspell_OnEvent(event)
if (event == "CHAT_MSG_WHISPER") then
ChatFrame1:AddMessage("tellspell found!");
end
end
something so simple... (noob)

EDIT:

OK, I have everything working right I think, lots of output to the chatbox, so it looks like everything is working right, except it doesn't cast the spell on the person...

The script target the person who sent the tell, and selects the right spell and puts it into a string, but calling CastSpellByName(string); does nothing? Any advice?

NEXT EDIT:

Ok, if I steal WhisperCast's idea and make a /command to execute the cast instead of it being instant it still doesn't work, UNLESS I make a macro that executes the /command, then it works. But if I just type in the /command in game nothing happens, then press the macro, and it fires off.

Is this some kind of anti-botting failsafe or something? Or am I doing something wrong and the macro somehow gets past it?

dsdranor
03-14-2005, 04:25 PM
You were right with your 1st guess, its Anti-Botting code, and its built into the WoW API.

bwh
03-14-2005, 09:03 PM
you cannot cast spells without a hard key press, every spell/move needs one press.