M4karov Posted February 14, 2017 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 149 Reputation: 36 Joined: 04/01/13 Last Seen: March 27 Share Posted February 14, 2017 Hello everyone, I would like help adding this command to my emulator, I am using the current version of the emulator. Index: src/map/clif.c =================================================================== --- src/map/clif.c (revision 1122) +++ src/map/clif.c (working copy) @@ -10488,10 +10488,12 @@ *------------------------------------------*/ void clif_parse_SolveCharName(int fd, struct map_session_data *sd) { - int charid; + int charid = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - charid = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - map_reqnickdb(sd, charid); + if(charid >= 150000) map_reqnickdb(sd, charid); + else if(charid == STUFF_BTG_FLAG) clif_solved_charname(fd,charid,"[BTG]"); // Sistema de Consumiveis [CarlosHenrq] + else if(charid == STUFF_GVG_FLAG) clif_solved_charname(fd,charid,"[GVG]"); // Sistema de Consumiveis [CarlosHenrq] + else if(charid == STUFF_PVP_FLAG) clif_solved_charname(fd,charid,"[PVP]"); // Sistema de Consumiveis [CarlosHenrq] } /*========================================== Index: src/map/itemdb.c =================================================================== --- src/map/itemdb.c (revision 1122) +++ src/map/itemdb.c (working copy) @@ -1088,3 +1088,15 @@ return 0; } +/*========================================== + * Sistemas de Consumiveis [CarlosHenrq] + *------------------------------------------*/ +int itemdb_is_stuff(struct item * item) { + int flag = 0; + if(item->card[0] != CARD0_CREATE || item->card[2] < STUFF_BTG_FLAG){ + return -1; + } + flag = 32767-item->card[2]; + + return (flag+1); +} Index: src/map/itemdb.h =================================================================== --- src/map/itemdb.h (revision 1122) +++ src/map/itemdb.h (working copy) @@ -39,6 +39,11 @@ //Use apple for unknown items. #define UNKNOWN_ITEM_ID 512 +// Sistema de Consumiveis [CarlosHenrq] +#define STUFF_PVP_FLAG 32767 +#define STUFF_GVG_FLAG 32766 +#define STUFF_BTG_FLAG 32765 + struct item_data { int nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; @@ -144,4 +149,7 @@ void do_final_itemdb(void); int do_init_itemdb(void); +// Sistema de Consumiveis [CarlosHenrq] +int itemdb_is_stuff(struct item * item); + #endif /* _ITEMDB_H_ */ Index: src/map/pc.c =================================================================== --- src/map/pc.c (revision 1122) +++ src/map/pc.c (working copy) @@ -3350,7 +3350,7 @@ int i; nullpo_retr(-1, sd); - ARR_FIND( 0, MAX_INVENTORY, i, sd->inventory.u.items_inventory[i].nameid == item_id && (sd->inventory.u.items_inventory[i].amount > 0 || item_id == 0) ); + ARR_FIND(0,MAX_INVENTORY,i,sd->inventory.u.items_inventory[i].nameid == item_id && (sd->inventory.u.items_inventory[i].amount > 0 || item_id == 0) && ((itemdb_is_stuff(&sd->inventory.u.items_inventory[i]) == 1) == map[sd->bl.m].flag.pvp || (itemdb_is_stuff(&sd->inventory.u.items_inventory[i]) == 2) == map[sd->bl.m].flag.gvg || (itemdb_is_stuff(&sd->inventory.u.items_inventory[i]) == 3) == map[sd->bl.m].flag.battleground)); return ( i < MAX_INVENTORY ) ? i : -1; } @@ -3572,6 +3572,9 @@ if( !item->script ) //if it has no script, you can't really consume it! return 0; + if(!map[sd->bl.m].flag.pvp && itemdb_is_stuff(&sd->inventory.u.items_inventory[n]) == 1 || !map[sd->bl.m].flag.gvg && itemdb_is_stuff(&sd->inventory.u.items_inventory[n]) == 2 || !map[sd->bl.m].flag.battleground && itemdb_is_stuff(&sd->inventory.u.items_inventory[n]) == 3) + return 0; + switch( nameid ) { case 605: // Anodyne Index: src/map/script.c =================================================================== --- src/map/script.c (revision 1122) +++ src/map/script.c (working copy) @@ -14947,9 +14947,45 @@ clif_showdigit(sd, (unsigned char)type, value); return 0; +} + +/*========================================== + * Sistemas de Consumiveis [CarlosHenrq] + * getstuffitem(<item_id>,<amount>,<flag>{,"<Char Name>"}); + *------------------------------------------*/ +BUILDIN_FUNC(getstuffitem) { + struct map_session_data * sd = (( script_hasdata(st,5) ) ? map_nick2sd(script_getstr(st,5)):script_rid2sd(st)); + int amount = script_getnum(st,3), flag = STUFF_BTG_FLAG + script_getnum(st,4), f; + struct script_data * data = NULL; + struct item_data * item_data = NULL; + struct item item; + + data = script_getdata(st,2); + get_val(st,data); + + if(data_isstring(data) && (item_data = itemdb_searchname(conv_str(st,data))) == NULL || (item_data = itemdb_exists(conv_num(st,data))) == NULL){ + ShowError("O Item enviado não existe.\n"); + return 0; + }else if(amount <= 0){ + ShowError("O valor enviado para números de itens enviado é inválido.\n"); + return 0; + }else if(!itemdb_isstackable2(item_data)){ + ShowError("Só é possivel enviar itens consumiveis.\n"); + return 0; + } + + memset(&item,0,sizeof(item)); + item.nameid = item_data->nameid; + item.identify = 1; + item.card[0] = CARD0_CREATE; + item.card[2] = flag; + + if((f = pc_additem(sd,&item,amount))) + clif_additem(sd,0,0,f); + + return 0; } - // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT BUILDIN_FUNC(defpattern); @@ -15357,5 +15393,9 @@ //brAthena Modificações BUILDIN_DEF(sc_check,"i"), + + // Sistema de Consumiveis [CarlosHenrq] + BUILDIN_DEF(getstuffitem,"vii*"), + {NULL,NULL,NULL}, }; error: http://prntscr.com/e8ubbb Quote Link to comment Share on other sites More sharing options...
Question
M4karov
Hello everyone, I would like help adding this command to my emulator, I am using the current version of the emulator.
error: http://prntscr.com/e8ubbb
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.