[Help]How can I know what item I got.

02/27/2013 14:11 monoedge#1
I made a custom item which is like random box.
Then, I want to know what item I got from the box when I open the box. Do you know what I mean?

For example, when you open a creature random box, you may see the message ("You use creature random box." and "You gain 1 xxx.") in the chat.

However, when I open my box, no message shows. Just like "You use xxx." So how can I write script for adding a message like "You gain 1 xxx."? Please anyone help me if you know about this.
02/27/2013 15:02 MrStubborn#2
[Only registered and activated users can see links. Click Here To Register...]

use Lua Script like :


Code:
function randomboxp()
insert_item(id,1)
end
I guess that's what you want


Regards
02/27/2013 15:14 ismokedrow#3
Code:
function randombox()
local rand = math.random(1,100)

    if rand > 1 and rand < 15 then
    insert_item(id,1)
    cprint("You have received: item_name, item_amount")
    elseif rand > 10 and rand < 25 then
    insert_item(id,1)
    cprint("You have received: item_name, item_amount")
    end
end
02/27/2013 16:13 monoedge#4
Thank you very much it works!!!!!!!!!!
02/27/2013 16:34 ismokedrow#5
No problem, if you want more and more random chances, just keep adding elseif clauses (REMEMBER DO NOT PUT AN END ON AN ELSEIF unless it is the VERY LAST elseif.
02/27/2013 16:57 monoedge#6
Ya, I'm just adding elseif clauses now:)
Thank you!!
02/28/2013 05:44 SilentBill#7
Hardcore people mess with dropgroups. Just sayin'
02/28/2013 08:36 c1ph3r#8
Quote:
Originally Posted by monoedge View Post
I made a custom item which is like random box.
Then, I want to know what item I got from the box when I open the box. Do you know what I mean?

For example, when you open a creature random box, you may see the message ("You use creature random box." and "You gain 1 xxx.") in the chat.

However, when I open my box, no message shows. Just like "You use xxx." So how can I write script for adding a message like "You gain 1 xxx."? Please anyone help me if you know about this.
Funny ideas in this thread^^

[Only registered and activated users can see links. Click Here To Register...]

What about checking existing items like the creature random box^^

Official Way:
1. create 1 dropgroup with all items that should be in the box
2. create the item
3. add the dropgroup to the item via opt_var

Everything is done.

If you want to use .lua scripting...there is one command get_itemname_by_id

Code:
function randombox()
  
  --Array that contains the items
  local giftarray =
  {item_id1,item_id2,item_id3,item_id4,item_id5,item_id6,item_id7,item_id8,
  item_id9,item_id10,item_id11,item_id12,item_id13,item_id14,item_id15,item_id16}

  --Randompointer for the Item (16 because it's the count of the array)
  local randompointer = math.random(1,16)

  --Randomitemcount (min and max count you want to use)
  local itemcount = math.random(1,5) 

  --insert the item
  insert_item(giftarray[randompointer],itemcount,0,0,2)

  --Show a Message with Itemname and count
  whisper(gv("name"),"You gained "..itemcount.."x "
  ..get_item_name_by_code(normalgiftarray[normalpointer]).."")

end
This is doing nearly the same as a Dropgroup via .lua.
02/28/2013 13:44 monoedge#9
Quote:
Originally Posted by c1ph3r View Post
Funny ideas in this thread^^

[Only registered and activated users can see links. Click Here To Register...]

What about checking existing items like the creature random box^^

Official Way:
1. create 1 dropgroup with all items that should be in the box
2. create the item
3. add the dropgroup to the item via opt_var

Everything is done.

If you want to use .lua scripting...there is one command get_itemname_by_id

Code:
function randombox()
  
  --Array that contains the items
  local giftarray =
  {item_id1,item_id2,item_id3,item_id4,item_id5,item_id6,item_id7,item_id8,
  item_id9,item_id10,item_id11,item_id12,item_id13,item_id14,item_id15,item_id16}

  --Randompointer for the Item (16 because it's the count of the array)
  local randompointer = math.random(1,16)

  --Randomitemcount (min and max count you want to use)
  local itemcount = math.random(1,5) 

  --insert the item
  insert_item(giftarray[randompointer],itemcount,0,0,2)

  --Show a Message with Itemname and count
  whisper(gv("name"),"You gained "..itemcount.."x "
  ..get_item_name_by_code(normalgiftarray[normalpointer]).."")

end
This is doing nearly the same as a Dropgroup via .lua.
Ya this is also very helpful for me:)
In order to use script_text, I deleted value in opt_type and var. So I'm creating lua scrip. Also sealed creatures are including in the box so I thought it's better to create a script.

Anyway, thank you very much!!!!