colcrt Publicado 9 de Noviembre del 2015 Reportar Compartir Publicado 9 de Noviembre del 2015 hola a tod@s veran estoy un poco liado con un funcion que necesito algun alma caritativa que me quiera ayudar :D nose como hacer basicamente necesito una funcion create_item que lo que haga es procesar esto if create_item(Item[1].vnum, Item[1].count, attrs, sockets, cell) == true then tomando los valores, que recoge de otras funciones if (cell >= 0) then local sockets = {Item[1].socket0, Item[1].socket1, Item[1].socket2} local attrs = {{Item[1].attrtype0, Item[1].attrvalue0}, {Item[1].attrtype1, Item[1].attrvalue1}, {Item[1].attrtype2, Item[1].attrvalue2}, {Item[1].attrtype3, Item[1].attrvalue3}, {Item[1].attrtype4, Item[1].attrvalue4}, {Item[1].attrtype5, Item[1].attrvalue5}, {Item[1].attrtype6, Item[1].attrvalue6}} if create_item(Item[1].vnum, Item[1].count, attrs, sockets, cell) == true then game.query("DELETE FROM player.shop_items WHERE shop_id = '"..tonumber(shop_id).."' AND owner_id = '"..pc.get_player_id().."' AND pos = '"..tonumber(pos).."';") end inetryconydot reacciono a esto 1 Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
Shang Publicado 9 de Noviembre del 2015 Reportar Compartir Publicado 9 de Noviembre del 2015 Qué es lo que debe chequear esa función para que retorne true? Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
colcrt Publicado 9 de Noviembre del 2015 Author Reportar Compartir Publicado 9 de Noviembre del 2015 Qué es lo que debe chequear esa función para que retorne true? mira esta es la funcion completa en la quest function getItem(shop_id, pos) Item = game.query("SELECT * FROM player.shop_items WHERE shop_id = '"..tonumber(shop_id).."' AND owner_id = '"..pc.get_player_id().."' AND pos = '"..tonumber(pos).."';") if Item == nil or table.getn(Item) == 0 then return else if (tonumber(Item[1].status) == 1) then syschat("eso seria maravilloso...") return else local cell = pc.enough_inventory2(Item[1].vnum) if (cell >= 0) then local sockets = {Item[1].socket0, Item[1].socket1, Item[1].socket2} local attrs = {{Item[1].attrtype0, Item[1].attrvalue0}, {Item[1].attrtype1, Item[1].attrvalue1}, {Item[1].attrtype2, Item[1].attrvalue2}, {Item[1].attrtype3, Item[1].attrvalue3}, {Item[1].attrtype4, Item[1].attrvalue4}, {Item[1].attrtype5, Item[1].attrvalue5}, {Item[1].attrtype6, Item[1].attrvalue6}} if create_item(Item[1].vnum, Item[1].count, attrs, sockets, cell) == true then game.query("DELETE FROM player.shop_items WHERE shop_id = '"..tonumber(shop_id).."' AND owner_id = '"..pc.get_player_id().."' AND pos = '"..tonumber(pos).."';") end end end end end Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
Shang Publicado 9 de Noviembre del 2015 Reportar Compartir Publicado 9 de Noviembre del 2015 mira esta es la funcion completa en la quest function getItem(shop_id, pos) Item = game.query("SELECT * FROM player.shop_items WHERE shop_id = '"..tonumber(shop_id).."' AND owner_id = '"..pc.get_player_id().."' AND pos = '"..tonumber(pos).."';") if Item == nil or table.getn(Item) == 0 then return else if (tonumber(Item[1].status) == 1) then syschat("eso seria maravilloso...") return else local cell = pc.enough_inventory2(Item[1].vnum) if (cell >= 0) then local sockets = {Item[1].socket0, Item[1].socket1, Item[1].socket2} local attrs = {{Item[1].attrtype0, Item[1].attrvalue0}, {Item[1].attrtype1, Item[1].attrvalue1}, {Item[1].attrtype2, Item[1].attrvalue2}, {Item[1].attrtype3, Item[1].attrvalue3}, {Item[1].attrtype4, Item[1].attrvalue4}, {Item[1].attrtype5, Item[1].attrvalue5}, {Item[1].attrtype6, Item[1].attrvalue6}} if create_item(Item[1].vnum, Item[1].count, attrs, sockets, cell) == true then game.query("DELETE FROM player.shop_items WHERE shop_id = '"..tonumber(shop_id).."' AND owner_id = '"..pc.get_player_id().."' AND pos = '"..tonumber(pos).."';") end end end end end No me has respondido. Te he preguntado qué es lo que quieres que haga la función create_item, ya que con ese nombre no debería de retornar nada... y tu quieres que retorne true. Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
colcrt Publicado 9 de Noviembre del 2015 Author Reportar Compartir Publicado 9 de Noviembre del 2015 No me has respondido. Te he preguntado qué es lo que quieres que haga la función create_item, ya que con ese nombre no debería de retornar nada... y tu quieres que retorne true. xD crear el item con los datos que recoge de la db, hay es donde nose por que mira es una shop offline si alguien compra el item que es para este caso lo que aria esa funcio es crear el item entregarlo y retornar true para eliminarlo de la db osea que se vendio y se entrego nose si me explico... creo que ya estoy en mi limite de programacion jejeje pdt ------> olvide mencionar aqui es donde llamo esa funcion if (private_shops.checkVariables(data, 2) == true and data[1] == "GET_ITEM") then if (private_shops.isMyShop(tonumber(data[2])) == true) then private_shops.getItem(tonumber(data[2]), tonumber(data[3])) private_shops.RefreshItems(tonumber(data[2])) end end Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
Shang Publicado 9 de Noviembre del 2015 Reportar Compartir Publicado 9 de Noviembre del 2015 No hace falta crear una nueva función para eso. Puedes usar pc.give_item2_select(vnum, count) y luego item.set_value(index, applytype, applyvalue) e item.set_socket(index, socket). Btw, no hace falta chequear el hueco libre que puedes usar en el inventario, la función para dar el item ya lo hace. Saludos! Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
PACI Publicado 11 de Noviembre del 2015 Reportar Compartir Publicado 11 de Noviembre del 2015 hola, hice esta func rapidamente en lua con las funciones q dice shang, puedes probarla --[[ Author: PACI Description: Creates an item with selected item attributes and sockets. Returns two args: boolean, int Syntax: Example 1 - Without item count (default 1): local item_created, errorType = create_item(19) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end >> Gives the player an item with the vnum 19. Example 2 - Without attributes nor sockets: local item_created, errorType = create_item(19, 1) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end >> Gives the player 1x the item 19 Example 3 - Only Attributes: local itemAttributes = { {1, 2000}, -- 2.000 MÁX HP {17, 15}, -- 15 Half-Humans -- {attrType, attrValue}, } local item_created, errorType = create_item(19, 1, itemAttributes) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end Example 4 - Attributes and Sockets: local itemAttributes = { {1, 2000}, -- 2.000 MÁX HP {17, 15}, -- 15 Half-Humans -- {attrType, attrValue}, } local itemSockets = {28301, 28317, 28302} local item_created, errorType = create_item(19, 1, itemAttributes, itemSockets) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end Example 5 - Only Sockets: local itemSockets = {28301, 28317, 28302} local item_created, errorType = create_item(19, 1, {}, itemSockets) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end ]] function create_item(itemVnum, itemCount, itemAttributes, itemSockets) local function _error(str, ret) if pc.is_gm() then syschat("lua.create_item.error: "..str..": returned "..ret) return false, ret end end if not itemVnum or itemVnum == 0 then return _error("not enough arg (itemVnum == 0)", -3) elseif type(itemCount) ~= "number" then return _error("itemCount must be a number", -2) elseif not itemCount or itemCount == 0 then itemCount = 1 end itemAttributes = itemAttributes or {} itemSockets = itemSockets or {} pc.give_item2_select(itemVnum, itemCount) if table.getn(itemAttributes) > 0 then for i = 1, table.getn(itemAttributes) do if table.getn(itemAttributes[i]) < 2 then return _error("itemAttributes["..i.."] is not fully defined, need 2 arguments: {attrType, attrValue}", -1) end item.set_value(i-1, itemAttributes[i][1], itemAttributes[i][2]) end end if table.getn(itemSockets) > 0 then for i = 1, table.getn(itemSockets) do if not itemSockets[i] then return _error("itemSockets are not fully defined", 0) end item.set_socket(i-1, itemSockets[i]) end end return true, 1 end Ryuk reacciono a esto 1 Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
colcrt Publicado 11 de Noviembre del 2015 Author Reportar Compartir Publicado 11 de Noviembre del 2015 hola, hice esta func rapidamente en lua con las funciones q dice shang, puedes probarla [spoiler]--[[ Author: PACI Description: Creates an item with selected item attributes and sockets. Returns two args: boolean, int Syntax: Example 1 - Without item count (default 1): local item_created, errorType = create_item(19) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end >> Gives the player an item with the vnum 19. Example 2 - Without attributes nor sockets: local item_created, errorType = create_item(19, 1) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end >> Gives the player 1x the item 19 Example 3 - Only Attributes: local itemAttributes = { {1, 2000}, -- 2.000 MÁX HP {17, 15}, -- 15 Half-Humans -- {attrType, attrValue}, } local item_created, errorType = create_item(19, 1, itemAttributes) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end Example 4 - Attributes and Sockets: local itemAttributes = { {1, 2000}, -- 2.000 MÁX HP {17, 15}, -- 15 Half-Humans -- {attrType, attrValue}, } local itemSockets = {28301, 28317, 28302} local item_created, errorType = create_item(19, 1, itemAttributes, itemSockets) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end Example 5 - Only Sockets: local itemSockets = {28301, 28317, 28302} local item_created, errorType = create_item(19, 1, {}, itemSockets) if item_created then syschat("Item given to the player succesfully") else syschat("Something wrong happend, errorType is: "..errorType) end ]] function create_item(itemVnum, itemCount, itemAttributes, itemSockets) local function _error(str, ret) if pc.is_gm() then syschat("lua.create_item.error: "..str..": returned "..ret) return false, ret end end if not itemVnum or itemVnum == 0 then return _error("not enough arg (itemVnum == 0)", -3) elseif type(itemCount) ~= "number" then return _error("itemCount must be a number", -2) elseif not itemCount or itemCount == 0 then itemCount = 1 end itemAttributes = itemAttributes or {} itemSockets = itemSockets or {} pc.give_item2_select(itemVnum, itemCount) if table.getn(itemAttributes) > 0 then for i = 1, table.getn(itemAttributes) do if table.getn(itemAttributes[i]) < 2 then return _error("itemAttributes["..i.."] is not fully defined, need 2 arguments: {attrType, attrValue}", -1) end item.set_value(i-1, itemAttributes[i][1], itemAttributes[i][2]) end end if table.getn(itemSockets) > 0 then for i = 1, table.getn(itemSockets) do if not itemSockets[i] then return _error("itemSockets are not fully defined", 0) end item.set_socket(i-1, itemSockets[i]) end end return true, 1 end[/spoiler] la voy a probar, pero esta genial gracias PACI Enlace para comentar Compartir en otros sitios Mas opciones de compartir...
Mensajes recomendados