Help me announce item :3

ahmadshidqi

New member
Messages
48
Points
0
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
default_sad.png
, please help me
 
Last edited by a moderator:
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:
Code:
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:
Code:
@nameid -> Item id@count  -> Item count
To 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:

Code:
/** * 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:
Code:
{	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:
Code:
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
default_smile.png
 
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:
Code:
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:
Code:
@nameid -> Item id@count  -> Item count
To 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:
Code:
{	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:
Code:
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
default_smile.png
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

 
Last edited by a moderator:
Back
Top