Jump to content

Recommended Posts

Posted

Hola a todos, tengo un fallo, y no consigo arreglarlo en una quest he preguntado a varios , he probado muchas formas, pero no lo he conseguido aun.

 

Estoy aqui para ver si alguien es capaz de ayudarme en esto.

			items = {			--ID_categoria, ID_item, vnum, cantidad, precio, itemCostType, attr1, val1, attr2, val2, attr3, val3, attr4, val4, attr5, val5, attr6, val6, attr7, val7, sock1, sock2, sock3, Descripcion			{1, 1, 149, 1, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada Batalla +9"},			{1, 2, 19, 1, 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada +9"}			}						local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la quest			local id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la quest						chat("categoria: "..categoria.." id: "..id)						if categoria == items[1] and id == items[2] then				chat("categoria:"..items[1].." y id "..items[2])				mysql_query("UPDATE account.account SET coins = coins-"..items[5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")				pc.give_item2(items[3], items[4])			end

Espero que alguien pueda solucionarme este problemita.

 

Gracias y un saludo.

Posted

Has probado así?

			items = {			--ID_categoria, ID_item, vnum, cantidad, precio, itemCostType, attr1, val1, attr2, val2, attr3, val3, attr4, val4, attr5, val5, attr6, val6, attr7, val7, sock1, sock2, sock3, Descripcion			{1, 1, 149, 1, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada Batalla +9"},			{1, 2, 19, 1, 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada +9"}			}						local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la quest			local id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la quest						chat("categoria: "..categoria.." id: "..id.."")						if categoria == items[1] and id == items[2] then				chat("categoria:"..items[1].." y id "..items[2].."")				mysql_query("UPDATE account.account SET coins = coins-"..items[5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")				pc.give_item2(items[3], items[4])			end
Posted

Segun lo que has puesto y lo que entiendo este sería tu resultado, pero ni siquiera explicas que es categoria, y que debería de hacer exactamente el programa. 

items = {--ID_categoria, ID_item, vnum, cantidad, precio, itemCostType, attr1, val1, attr2, val2, attr3, val3, attr4, val4, attr5, val5, attr6, val6, attr7, val7, sock1, sock2, sock3, Descripcion{1, 1, 149, 1, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada Batalla +9"},{1, 2, 19, 1, 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada +9"}}local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la questlocal id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la questchat("categoria: "..categoria.." id: "..id)if categoria == items[1][1] and id == items[2][1] then	chat("categoria:"..items[1].." y id "..items[2])	mysql_query("UPDATE account.account SET coins = coins-"..items[5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")	pc.give_item2(items[3], items[4])end
Posted

Pues dejo explicado aqui:

 

Yo le doy a 1 boton en py, de 1 itemshop, para comprar 1 item, y desde python envio 2 datos a quest,

local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la questlocal id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la quest

esos 2 datos los envio, son 2 numeros, 1 es el numero de la categoria de la itemshop y otro es el numero del id del item ( no el vnum ).

 

Necesito que compare esos values recibidos con el array, y haga un pc.give_item2 con esa misma linea del array con su vnum y su cantidad.

Posted

items = {

-ID_categoria, ID_item, vnum, cantidad, precio, itemCostType, attr1, val1, attr2, val2, attr3, val3, attr4, val4, attr5, val5, attr6, val6, attr7, val7, sock1, sock2, sock3, Descripcion

{1, 1, 149, 1, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada Batalla +9"},

{1, 2, 19, 1, 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada +9"}

}

 

 

local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la quest

local id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la quest

 

chat("categoria: "..categoria.." id: "..id)

for a=1,table.getn(items),1 do

if categoria == items[a][1] and id == items[a][2] then

chat("categoria:"..items[a][1].." y id "..items[a][2])

mysql_query("UPDATE account.account SET coins = coins-"..items[a][5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")

pc.give_item2(items[a][3], items[a][4])

end -- if

end --for

 

 

necesitas un bucle for para buscar las comparaciones, y como dige antes eso es un array bidimensional

Posted
items = {	--ID_categoria, ID_item, vnum, cantidad, precio, itemCostType, attr1, val1, attr2, val2, attr3, val3, attr4, val4, attr5, val5, attr6, val6, attr7, val7, sock1, sock2, sock3, Descripcion			{1, 1, 149, 1, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada Batalla +9"},			{1, 2, 19, 1, 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Espada +9"}			}						local categoria = input(cmdchat("GetISBuyID")) --- esto devuelve 1 valor a la quest			local id = input(cmdchat("GetISBuyID2")) --- esto devuelve 1 valor a la quest						chat("categoria: "..categoria.." id: "..id)			local i = 1 			while (i <= table.getn(items)) do				i = i + 1				if categoria == items[i][1] and id == items[i][2] then					chat("categoria:"..items[1].." y id "..items[2])					mysql_query("UPDATE account.account SET coins = coins-"..items[5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")					pc.give_item2(items[3], items[4])					break				end			end
Posted

*Yori:

 

Imagen enviada

Despues del for, se queda parado y no pasa al if

 

 

* Pepinatorrrr xD

			local i = 1 			while (i <= table.getn(items)) do				i = i + 1				if categoria == items[i][1] and id == items[i][2] then					chat("categoria:"..items[1].." y id "..items[2])					mysql_query("UPDATE account.account SET coins = coins-"..items[5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")					pc.give_item2(items[3], items[4])					break				end			end

No llega al chat

chat("categoria:"..items[1].." y id "..items[2])
Posted

Como va a llegar al chat melón...

chat("categoria:"..items[1].." y id "..items[2])

será

chat("categoria:"..items[i][1].." y id "..items[i][2])

Tienes que poner en todos los items[1], items[2]...--> items[1]...
Yo la e probado así y me funciona:

quest tatata beginstate start beginwhen 70010.use beginitems = {	{1, 1, 149,1, "Espada Batalla +9"},	{1, 2, 19,1, "Espada +9"}}						local categoria = 1			local id = 2			local i = 0			while (i != table.getn(items)) do				i = i + 1				if categoria == items[i][1] and id == items[i][2]  then					chat("categoria:"..items[i][1].." y id "..items[i][2])				end			end			endendend
Posted

 

Como va a llegar al chat melón...

chat("categoria:"..items[1].." y id "..items[2])

será

chat("categoria:"..items[i][1].." y id "..items[i][2])

Tienes que poner en todos los items[1], items[2]...--> items[1]...

Yo la e probado así y me funciona:

quest tatata beginstate start beginwhen 70010.use beginitems = {	{1, 1, 149,1, "Espada Batalla +9"},	{1, 2, 19,1, "Espada +9"}}						local categoria = 1			local id = 2			local i = 0			while (i != table.getn(items)) do				i = i + 1				if categoria == items[i][1] and id == items[i][2]  then					chat("categoria:"..items[i][1].." y id "..items[i][2])				end			end			endendend
local i = 1 while (i <= table.getn(items)) doi = i + 1if categoria == items[i][1] and id == items[i][2] thenchat("categoria:"..items[i][1].." y id "..items[i][2])mysql_query("UPDATE account.account SET coins = coins-"..items[i][5].." WHERE id = "..pc.get_account_id().." LIMIT 1;")pc.give_item2(items[i][3], items[i][4])breakendend

tampoco me va así xd

Posted

mete un chat("dentro del if"), para ver si se cumple la condicion en algun momento

 

edito: por lo que veo, no hay conincidencias, ya que sale el mensaje del bucle repetido las 5 veces, asique lo que parece es que no recoje los valores del cliente, compruebalo con chat("Categoria: "..categoria.." id: "..id)

Posted

El problema es que los valores del cmdchat no funcionan, pero al probarlo con un chat, si que se salen.

Imagen enviada

 

Solo hacer la comparación con un elemento del array usando las variables de los cmdchat es lo que no funciona.

  • Dilong locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies to enhance your browsing experience and provide relevant content. By continuing to browse, you agree to our 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. and Terms of Use. For more information on how we protect your data, please check our Privacy Policy.