Thread Tools Display Modes
04-18-09, 12:20 AM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Slash command -> function calls

Trying to work Kicker into the default /gkick, /kick slash commands so that users won't have to type out those long-ass commands. Unfortunately, I haven't found the core functions for these so that I can hook them.

Anyone happen to know what/where they are?
  Reply With Quote
04-18-09, 12:24 AM   #2
Aezay
A Theradrim Guardian
 
Aezay's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 66
The slash command is /gremove and the function it links to is SlashCmdList["GUILD_UNINVITE"].
  Reply With Quote
04-18-09, 12:54 AM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Ick. Functions stored in tables. Haven't figured/played with those things yet.
  Reply With Quote
04-18-09, 01:03 AM   #4
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by ChaosInc View Post
Ick. Functions stored in tables. Haven't figured/played with those things yet.
Then use UninviteUnit(name) for party/raid and GuildUninvite(name) for guild.

IsPartyLeader() to see if you can kick from party/raid and CanGuildRemove() to see if you can kick from guild.
  Reply With Quote
04-18-09, 01:07 AM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Azul View Post
Then use UninviteUnit(name) for party/raid and GuildUninvite(name) for guild.
That's already in place.

Code:
function Kicker_SlashCommandHandler(msg)
	local source, leftover = Kicker_GetCmd(msg);
	local name, reason = Kicker_GetCmd(leftover);
	
	if (source == "guild") or (source == "g") then
		GuildUninvite(name)
		SendChatMessage(KICKMSG.. "guild. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " has been /gkicked! (".. reason.. ")", "GUILD", nil, nil);
	elseif (source == "party") or (source == "p") then
		UninviteUnit(name)
		SendChatMessage(KICKMSG.. "party. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " kicked from party. (".. reason.. ")", "PARTY", nil, nil);
	elseif (source == "raid") or (source == "r") then
		UninviteUnit(name)
		SendChatMessage(KICKMSG.. "raid. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " kicked from raid. (".. reason.. ")", "RAID", nil, nil);
	else
		SendChatMessage("Kicker: You failed to kick anyone.  You suck.")
	end
end
I'm just looking to hook this into the game's already present commands.

/kicker guild <name> cause you suck -> /gremove <name> cause you suck
  Reply With Quote
04-18-09, 01:12 AM   #6
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by ChaosInc View Post
That's already in place.

Code:
function Kicker_SlashCommandHandler(msg)
	local source, leftover = Kicker_GetCmd(msg);
	local name, reason = Kicker_GetCmd(leftover);
	
	if (source == "guild") or (source == "g") then
		GuildUninvite(name)
		SendChatMessage(KICKMSG.. "guild. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " has been /gkicked! (".. reason.. ")", "GUILD", nil, nil);
	elseif (source == "party") or (source == "p") then
		UninviteUnit(name)
		SendChatMessage(KICKMSG.. "party. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " kicked from party. (".. reason.. ")", "PARTY", nil, nil);
	elseif (source == "raid") or (source == "r") then
		UninviteUnit(name)
		SendChatMessage(KICKMSG.. "raid. (".. reason..")", "WHISPER", nil, name);
		SendChatMessage(name.. " kicked from raid. (".. reason.. ")", "RAID", nil, nil);
	else
		SendChatMessage("Kicker: You failed to kick anyone.  You suck.")
	end
end
I'm just looking to hook this into the game's already present commands.

/kicker guild <name> cause you suck -> /gremove <name> cause you suck
Well if you want to hook it then you kind of need the SlashCmdList[] array, since that is where the slash commands are stored.

If you know ahead of time exactly how many aliases of the /gremove command there are (let's say 3), you could try just doing SLASH_GUILD_UNINVITE4="/kicker guild" and not have to deal with arrays then.
If the number changes between patches your addon will break, though.
  Reply With Quote
04-18-09, 07:19 PM   #7
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Would it be SlashCmdList["PARTY_UNINVITE"] or just plain "UNINVITE"? Tried:

Code:
origPartyUninvite = SlashCmdList["PARTY_UNINVITE"] -- preserve original just in case
SlashCmdList["PARTY_UNINVITE"] = function(msg)
	Kicker_SlashCommandHandler(msg);
	end
with no result.

EDIT: Got it. It's just plain "UNINVITE" for future reference.

Last edited by Sythalin : 04-18-09 at 07:33 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Slash command -> function calls


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