Jump to content
  • 0

pc.give_item2_select() function


Sober

Question

				local res = mysql_query("SELECT vnum,applytype0,applyvalue0,applytype1,applyvalue1,applytype2,applyvalue2,applytype3,applyvalue3,applytype4,applyvalue4,socket0,socket1,socket2 FROM player.test WHERE item_id='"..tostring(item_id).."'")
				pc.give_item2_select(tonumber(res[1][1]))
				item.set_socket(0,tonumber(res[1][12]))
				item.set_socket(1,tonumber(res[1][13]))
				item.set_socket(2,tonumber(res[1][14]))
				item.set_attr(tonumber(res[1][2]),tonumber(res[1][3]))
				item.set_attr(tonumber(res[1][4]),tonumber(res[1][5]))
				item.set_attr(tonumber(res[1][6]),tonumber(res[1][7]))
				item.set_attr(tonumber(res[1][8]),tonumber(res[1][9]))
				item.set_attr(tonumber(res[1][10]),tonumber(res[1][11]))

I have this piece of code and the quest stops at the line item.set_socket(0,tonumber(res[1][12])), i think that the item is not even selected.

Ingame i receive the item but bonuses and stones are not added...

I try to chat(item.get_id()) but quest stops there too...

Syserr:

RunState: LUA_ERROR: locale/germany/quest/object/state/auction:35: attempt to index global `item' (a string value) WITH ERRORCODE 1
RunState: LUA_STATE: index 0 ref 3

Any expert who can help??!

I am using Vanilla core

Link to comment

8 answers to this question

Recommended Posts

  • 0

You can try pc.give_item2 same function(without table). but if you won't this situation, you can try (try-exception system) for lua

 

Best Regards

Ellie

Do not be sorry, be better.

Link to comment
  • 0

pc.give_item2 returns the new item id, so you can do this way:

 

local id = pc.give_item2(12345)

local ret = item.select(id)

if not ret then syschat("something is wrong") else

...

end

 

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0

pc.give_item2 returns the new item id, so you can do this way:

 

local id = pc.give_item2(12345)

local ret = item.select(id)

if not ret then syschat("something is wrong") else

...

end

 

I have tried this way, but quest stops again at line local ret = item.select(id)  i even chat(id) and it returns me correctly the item id...

What the hell is wrong o.O

Link to comment
  • 0

Maybe you have an error in the quest. If you named a variable to "item" it will overwrite the "userdata object" and a function call on it may cause a "attempt to index global `item' (a string value)" like error.

  • Love 1

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0

Maybe you have an error in the quest. If you named a variable to "item" it will overwrite the "userdata object" and a function call on it may cause a "attempt to index global `item' (a string value)" like error.

 

That was the case :)

Now the whole quest is executed but i still have a problem, the item that i receive does not take any socket nor bonuses

Link to comment
  • 0

Try item.set_value(idx, type, value), but i've got no idea why set_socket doesn't work.

 

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0

I remember at the moment. item.set_socket and another functions using "GetCurrentItem" if you don't select current item, system does not work.

 

Like ATAG said. But this solution not work on your quest. Try with cell.

local a = mysql_query("select pos from player.item where vnum = '"..tostring(item_id).."',applytype,etc")
local b = item.select_cell(a[1])
item.set_socket(0,row[2])
item.select_cell(

Best Regards

Ellie

 

Do not be sorry, be better.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.