Jump to content
  • 0
ahmadshidqi

Help me announce item :3

Question

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 by ahmadshidqi

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

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 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:
{	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 :)

Share this post


Link to post
Share on other sites
  • 0

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 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:
{	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 by ahmadshidqi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.