ahmadshidqi 0 Posted July 2, 2014 (edited) How to announce item that get from item_groups? Like everytime open "High Weapon Box" Server will be Announce to all map/player :3 get item (getitemrand(12623) from "High Weapon Box" or something else :3. I've tried, but fail , please help me Edited July 2, 2014 by ahmadshidqi Quote Share this post Link to post Share on other sites
0 pan 87 Posted July 2, 2014 Without altering your source code it's not possible to know which item was got after using *getrandgroupitem, as you posted in source support I'll provide a snippet altering this command behaviour: Open your src/map/script.c and find: BUILDIN(getrandgroupitem) {[...] for (i = 0; i < count; i += get_count) { // if not pet egg if (!pet->create_egg(sd, nameid)) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } script_pushint(st, 0);[...]Alter it to:BUILDIN(getrandgroupitem) {[...] for (i = 0; i < count; i += get_count) { // if not pet egg if (!pet->create_egg(sd, nameid)) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } pc->setreg(sd, script->add_str("@nameid"), nameid); pc->setreg(sd, script->add_str("@count"), get_count); script_pushint(st, 0);[...]Save and build your map-server. Now every time that you use *getrandgroupitem and it's successful two temporary variables will be set:@nameid -> Item id@count -> Item countTo verify if the command was successful just check any variable. Now to use it in a item box. Put this function inside any script file: /** * Display an announce letting other players know which item strcharinfo(0) * got when using a box. * arg(0) - Id of the box * These args should be from *getrandgroupitem * arg(1) - @nameid * arg(2) - @count **/function script F_BOX_OPEN { @box_id = getarg(0); @nameid = getarg(1); @count = getarg(2); announce strcharinfo(0)+" opened "+getitemname(@box_id)+" and got "+@count+" "+getitemname(@nameid)+""+((@count > 1)?"s":"")+"!", bc_map; return;}Now go to your item_db.conf and find the entry for the item that you'd like to alter, for instance High Weapon Box:{ Id: 12623 AegisName: "High_Weapon_Box" Name: "High Weapon Box" Type: 2 Buy: 20 Weight: 10 Upper: 63 Script: <" getrandgroupitem 12623,1; ">},Now alter its script to something like:Script: <" getrandgroupitem 12623,1; if(@nameid) callfunc "F_BOX_OPEN",High_Weapon_Box, @nameid, @count;">If you'd like for this to be automatic you could add a broadcast function to BUILDIN(getrandgroupitem), but and any time this function is called it would automatically announce Quote Share this post Link to post Share on other sites
0 ahmadshidqi 0 Posted July 2, 2014 (edited) Without altering your source code it's not possible to know which item was got after using *getrandgroupitem, as you posted in source support I'll provide a snippet altering this command behaviour: Open your src/map/script.c and find: BUILDIN(getrandgroupitem) {[...] for (i = 0; i < count; i += get_count) { // if not pet egg if (!pet->create_egg(sd, nameid)) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } script_pushint(st, 0);[...]Alter it to:BUILDIN(getrandgroupitem) {[...] for (i = 0; i < count; i += get_count) { // if not pet egg if (!pet->create_egg(sd, nameid)) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } pc->setreg(sd, script->add_str("@nameid"), nameid); pc->setreg(sd, script->add_str("@count"), get_count); script_pushint(st, 0);[...]Save and build your map-server. Now every time that you use *getrandgroupitem and it's successful two temporary variables will be set:@nameid -> Item id@count -> Item countTo verify if the command was successful just check any variable. Now to use it in a item box. Put this function inside any script file: /** * Display an announce letting other players know which item strcharinfo(0) * got when using a box. * arg(0) - Id of the box * These args should be from *getrandgroupitem * arg(1) - @nameid * arg(2) - @count **/function script F_BOX_OPEN { @box_id = getarg(0); @nameid = getarg(1); @count = getarg(2); announce strcharinfo(0)+" opened "+getitemname(@box_id)+" and got "+@count+" "+getitemname(@nameid)+""+((@count > 1)?"s":"")+"!", bc_map; return;}Now go to your item_db.conf and find the entry for the item that you'd like to alter, for instance High Weapon Box:{ Id: 12623 AegisName: "High_Weapon_Box" Name: "High Weapon Box" Type: 2 Buy: 20 Weight: 10 Upper: 63 Script: <" getrandgroupitem 12623,1; ">},Now alter its script to something like:Script: <" getrandgroupitem 12623,1; if(@nameid) callfunc "F_BOX_OPEN",High_Weapon_Box, @nameid, @count;">If you'd like for this to be automatic you could add a broadcast function to BUILDIN(getrandgroupitem), but and any time this function is called it would automatically announce waw... thankyou pan... i'll report you again if isn't work >.<, please wait... sorry bad eng -- Edited Wow! Thankyou pan.... its very awesome.. thankyou very much Edited July 2, 2014 by ahmadshidqi Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted July 2, 2014 script_pushint(st, nameid); Quote Share this post Link to post Share on other sites
0 Neferpitou 2 Posted July 26, 2015 not working anymore can anyone make this work in latest revision of herc? Quote Share this post Link to post Share on other sites
Share this post
Link to post
Share on other sites