ArcEmu: Lua Enchant Npc - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Lua Enchant Npc

#1 User is offline   Runemaster 

  • Newbie
  • Group: Members
  • Posts: 4
  • Joined: 06-May 12
  • Gender:Male
  • Server OS:Windows

Posted 10 May 2012 - 07:07 PM

Hey arcemu peeps. Im not exactly NEW to Lua but I make some pretty novice mistakes. Can anyone point out what's wrong and what to do about it?

Essentially this is the famous enchanter npc that was in C++ but I rewrote it in Lua for simplicity's sake. That said, here's what's wrong.

When I enchant any chest enchant it checks my bracers, if I have them it enchants them with a weird random ass enchant that isnt the enchant ID I put into it.

the second is it keeps saying I dont have a shield or 2h when I do have it equipped

http://pastebin.com/5puJFZ9E

Thanks in advance, obviously will credit anyone who helps + arcemu.
0

#2 User is offline   Satanail 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 11-March 12
  • Gender:Male
  • Location:Absurdistan
  • Server OS:Windows

Posted 11 May 2012 - 02:26 AM

Well, actualy i found out a messed up intid. Take a look at this:
			if (intid == 5) then
			pUnit:GossipCreateMenu(304, player, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Powerful Stats|R", 25, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Super Health|R", 26, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Greater Mana Restoration|R", 27, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Exceptional Resilience|R", 28, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Greater Defense|R", 29, 0)
			pUnit:GossipMenuAddItem(5, "Nevermind.", 100, 0)
			pUnit:GossipSendMenu(player)
			end	
			
						
			if (intid == 20) then         
				local pItem = player:GetEquippedItemBySlot(4)
					if pItem ~= nil then
					pItem:AddEnchantment(3832, 0, 0)
					pUnit:GossipComplete(player)
					else
					player:SendAreaTriggerMessage("|cFF00FFFF[WoWGalore]: |cFFFFA500You have no chest equipped!")
					pUnit:GossipComplete(player)
					end
			end
			
			if (intid == 21) then         
				local pItem = player:GetEquippedItemBySlot(4)
					if pItem ~= nil then
					pItem:AddEnchantment(3297, 0, 0)
					pUnit:GossipComplete(player)
					else
					player:SendAreaTriggerMessage("|cFF00FFFF[WoWGalore]: |cFFFFA500You have no chest equipped!")
					pUnit:GossipComplete(player)
					end
			end
					
			if (intid == 22) then         
				local pItem = player:GetEquippedItemBySlot(4)
					if pItem ~= nil then
					pItem:AddEnchantment(2381, 0, 0)
					pUnit:GossipComplete(player)
					else
					player:SendAreaTriggerMessage("|cFF00FFFF[WoWGalore]: |cFFFFA500You have no chest equipped!")
					pUnit:GossipComplete(player)
					end	
			end
					
			if (intid == 23) then         
				local pItem = player:GetEquippedItemBySlot(4)
					if pItem ~= nil then
					pItem:AddEnchantment(3245, 0, 0)
					pUnit:GossipComplete(player)
					else
					player:SendAreaTriggerMessage("|cFF00FFFF[WoWGalore]: |cFFFFA500You have no chest equipped!")
					pUnit:GossipComplete(player)
					end	
			end
					
			if (intid == 24) then         
				local pItem = player:GetEquippedItemBySlot(4)
					if pItem ~= nil then
					pItem:AddEnchantment(1953, 0, 0)
					pUnit:GossipComplete(player)
					else
					player:SendAreaTriggerMessage("|cFF00FFFF[WoWGalore]: |cFFFFA500You have no chest equipped!")
					pUnit:GossipComplete(player)
					end
			end	

It is the gossip menu for your chest enchants. The menu adds items with intid 25 to 29, but if you look at the if statements for chest enchants, they are activated by intid's - 20 to 24. My point is that you've messed up some intid. 20 to 24 handle the chest enchants and 25 to 31 - wrist enchants.
Here is how you fix it:
			if (intid == 5) then
			pUnit:GossipCreateMenu(304, player, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Powerful Stats|R", 20, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Super Health|R", 21, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Greater Mana Restoration|R", 22, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Exceptional Resilience|R", 23, 0)
			pUnit:GossipMenuAddItem(3, "|cFF008000Enchant Chest - Greater Defense|R", 24, 0)
			pUnit:GossipMenuAddItem(5, "Nevermind.", 100, 0)
			pUnit:GossipSendMenu(player)
			end	

EDIT: Also found another bug\error. This does not complete the gossip.
pUnit:GossipComplete(player)

But this does:
player:GossipComplete()

0

#3 User is offline   Runemaster 

  • Newbie
  • Group: Members
  • Posts: 4
  • Joined: 06-May 12
  • Gender:Male
  • Server OS:Windows

Posted 11 May 2012 - 04:42 AM

awesome, that solves the brainfart part as I was up for the last two days writing it xD

Thanks man, I appreciate you taking the time to post that, Can't believe I didn't spot that.

Now my major problem remains, it wont get the fact I have a shield or two-hander equipped, the check has to be wrong some how.


Also note to self, stop saying the **** up all night writing, causes too many brainfarts.
0

#4 User is offline   Satanail 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 11-March 12
  • Gender:Male
  • Location:Absurdistan
  • Server OS:Windows

Posted 11 May 2012 - 06:48 AM

Quote

Now my major problem remains, it wont get the fact I have a shield or two-hander equipped, the check has to be wrong some how.


Also note to self, stop saying the **** up all night writing, causes too many brainfarts.

Well if you take a closer look at the query you run with the script, you will see that the local sql is returning string. Or said in lua language:
local sql = WorldDBQuery("SELECT subclass FROM items WHERE entry = '"..pItem:GetEntryId().."';"):GetColumn(0):GetString()

Notice that :GetString() at the end? In order to make the code line "if (sql == 6) then" recognize what the local sql returned and compare it, the values in the if statements must be expressed as strings, or it must be something like this: (for shields)
if (sql == "6") then


And for the 2H weapon part it should look something like this:
if (sql == "1" or sql == "5" or sql == "6" or sql == "8" or sql == "10") then
The values must be in "", because the core tries to compare strings but the values in your if statement are expressed as numeric and you can't compare string with numeric.
0

#5 User is offline   Runemaster 

  • Newbie
  • Group: Members
  • Posts: 4
  • Joined: 06-May 12
  • Gender:Male
  • Server OS:Windows

Posted 11 May 2012 - 08:36 AM

you're ******* kidding me. All these headaches because I just didnt use some "s..........

thanks man. Well, Ima go slam my head into the wall a few times. Thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users