Jump to content

zxb329622888

Members
  • Posts

    2
  • Joined

  • Last visited

2 Followers

Profile Information

  • Gender
    Female

Recent Profile Visitors

2326 profile views

zxb329622888's Achievements

Poring

Poring (1/15)

0

Reputation

  1. BUILDIN_FUNC(getcanrefine) { int itemid; struct item_data* i_data; TBL_PC *sd; sd = script_rid2sd(st); if( sd == NULL ) return 0; itemid = script_getnum(st,2); i_data = itemdb_exists(itemid); if( i_data <= 0) { return 0; } script_pushint(st,i_data->flag.no_refine); return 0; }
  2. I'msorry, I'm fromChina, English is not very good,sorry itemid,type,Variable name 19994,3,Vitality type = 1 zeny type = 2 cash type = 3 Custom variable nam type = 4 item Code Find: pc.h int vend_loot; Join: int vend_type; char *vend_variable; Find: item.h struct s_item_vend{ Join: int type; char variable[20]; Find: item.c static bool itemdb_read_vending(char* fields[], int columns, int current) Replace: static bool itemdb_read_vending(char* fields[], int columns, int current) { struct item_data* id; int nameid,type; nameid = atoi(fields[0]); type = atoi(fields[1]); if( ( id = itemdb_exists(nameid) ) == NULL ) { ShowWarning("itemdb_read_vending: Invalid item id %d.n", nameid); return false; } if( id->type == IT_ARMOR || id->type == IT_WEAPON ) { ShowWarning("itemdb_read_vending: item id %d cannot be equipment or weapon.n", nameid); return false; } if ( type < 0 || type > 4 ) { ShowWarning("itemdb_read_vending: 无效的type属性 %d n",type); return false; } safestrncpy(item_vend[current].variable,fields[2],sizeof(item_vend[current].variable)); item_vend[current].itemid = nameid; item_vend[current].type = type; return true; } Find: sv_readdb(db_path, "item_vending.txt", ',', 1, 1, MAX_INVENTORY, &itemdb_read_vending); Replace: sv_readdb(db_path, "item_vending.txt", ',', 3, 3, MAX_INVENTORY, &itemdb_read_vending); Find: skill.c int skill_vending( struct map_session_data *sd, int nameid) { Replace: int skill_vending( struct map_session_data *sd, int nameid) { struct item_data *item = itemdb_exists(nameid); char output[1024]; int i; nullpo_ret(sd); if( nameid <= 0) { clif_skill_fail(sd,MC_VENDING,0,0,0); return 0; } if( nameid > MAX_ITEMDB ) return 0; for (i=0;i<MAX_INVENTORY;i++) { if (item_vend[i].itemid == nameid) { sd->vend_loot = item_vend[i].itemid; sd->vend_type = item_vend[i].type; sd->vend_variable = item_vend[i].variable; } } sprintf(output,"您已选择: %s",itemdb_jname(sd->vend_loot)); clif_displaymessage(sd->fd,output); if ( !pc_can_give_items(pc_isGM(sd))) clif_skill_fail(sd,MC_VENDING,0,0,0); else { clif_openvendingreq(sd,2+sd->vend_lvl); } return 1; } Find: vending.c void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count) { Replace: void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count) { int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING]; double z; int currid,vcurrid; struct item item_buffer; int paysd,getvsd,p_z,p_g; struct s_vending vending[MAX_VENDING]; // against duplicate packets struct map_session_data* vsd = map_id2sd(aid); nullpo_retv(sd); if( sd->state.npc_vending && sd->state.npc_vending == uid ) {// a script vend has been requests struct npc_data* nd = map_id2nd(uid); if( nd == NULL ) return; vending_purchasereq_script(sd, nd, uid, data, count); return; } if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id ) return; // invalid shop if( vsd->vender_id != uid ) {// shop has changed clif_buyvending(sd, 0, 0, 6); // store information was incorrect return; } if( !searchstore_queryremote(sd, aid) && ( sd->bl.m != vsd->bl.m || !check_distance_bl(&sd->bl, &vsd->bl, AREA_SIZE) ) ) return; // shop too far away searchstore_clearremote(sd); if( count < 1 || count > MAX_VENDING || count > vsd->vend_num ) return; // invalid amount of purchased items blank = pc_inventoryblank(sd); //number of free cells in the buyer's inventory // duplicate item in vending to check hacker with multiple packets memcpy(&vending, &vsd->vending, sizeof(vsd->vending)); // copy vending list // some checks z = 0.; // zeny counter w = 0; // weight counter for( i = 0; i < count; i++ ) { short amount = *(uint16*)(data + 4*i + 0); short idx = *(uint16*)(data + 4*i + 2); idx -= 2; if( amount <= 0 ) return; // check of item index in the cart if( idx < 0 || idx >= MAX_CART ) return; ARR_FIND( 0, vsd->vend_num, j, vsd->vending[j].index == idx ); if( j == vsd->vend_num ) return; //picked non-existing item else vend_list[i] = j; if (battle_config.extended_vending) { z += ((double)vsd->vending[j].value * (double)amount); switch (vsd->vend_type) { case 1: if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) { clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny return; } if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } break; case 2: if(z > sd->cashPoints || z < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(800)); return; } if (z + (double)vsd->cashPoints > (double)MAX_ZENY) { clif_displaymessage(sd->fd, msg_txt(812)); return; } break; case 3: if(z > pc_readregistry(sd,trim(vsd->vend_variable),3) || z < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(810)); return; } if (z + (double)pc_readregistry(sd,trim(vsd->vend_variable),3) > (double)MAX_ZENY) { clif_displaymessage(sd->fd, msg_txt(811)); return; } break; case 4: currid = pc_search_inventory (sd, vsd->vend_loot); if( z > (double)sd->status.inventory[currid].amount || currid < 0. || z > (double)MAX_ZENY ) { clif_displaymessage(sd->fd, msg_txt(801)); // you don't have enough zeny return; } vcurrid = pc_search_inventory (vsd, vsd->vend_loot); if( z + (double) vsd->status.inventory[vcurrid].amount > MAX_AMOUNT && !battle_config.vending_over_max_item ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } break; } } else { if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) { clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny return; } if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) { clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow return; } } w += itemdb_weight(vsd->status.cart[idx].nameid) * amount; if( w + sd->weight > sd->max_weight ) { clif_buyvending(sd, idx, amount, 2); // you can not buy, because overweight return; } //Check to see if cart/vend info is in sync. if( vending[j].amount > vsd->status.cart[idx].amount ) vending[j].amount = vsd->status.cart[idx].amount; // if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples). // here, we check cumulative amounts if( vending[j].amount < amount ) { // send more quantity is not a hack (an other player can have buy items just before) clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity return; } vending[j].amount -= amount; switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) { case ADDITEM_EXIST: break; //We'd add this item to the existing one (in buyers inventory) case ADDITEM_NEW: new_++; if (new_ > blank) return; //Buyer has no space in his inventory break; case ADDITEM_OVERAMOUNT: return; //too many items } } //Logs (V)ending Zeny [Lupus] if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); if(battle_config.extended_vending){ switch (vsd->vend_type) { case 1: //Logs (V)ending Zeny [Lupus] if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); pc_payzeny(sd, (int)z); if( battle_config.vending_tax ) z -= z * (battle_config.vending_tax/10000.); pc_getzeny(vsd, (int)z); break; case 2: pc_paycash(sd,(int)z,0); pc_getcash(vsd,(int)z,0); break; case 3: paysd = pc_readregistry(sd,trim(vsd->vend_variable),3); getvsd = pc_readregistry(vsd,trim(vsd->vend_variable),3); p_z = paysd - (int)z; p_g = getvsd + (int)z; pc_setregistry(sd,trim(vsd->vend_variable), p_z, 3); pc_setregistry(vsd,trim(vsd->vend_variable), p_g, 3); break; case 4: if(z > sd->status.inventory[currid].amount) return; pc_delitem(sd, currid, (int)z, 0, 0); memset(&item_buffer,0,sizeof(item_buffer)); item_buffer.nameid = vsd->vend_loot; item_buffer.identify = 1; pc_additem(vsd,&item_buffer,(int)z); break; } } else { if( log_config.zeny > 0 ) log_zeny(vsd, "V", sd, (int)z); pc_payzeny(sd, (int)z); if( battle_config.vending_tax ) z -= z * (battle_config.vending_tax/10000.); pc_getzeny(vsd, (int)z); } for( i = 0; i < count; i++ ) { short amount = *(uint16*)(data + 4*i + 0); short idx = *(uint16*)(data + 4*i + 2); idx -= 2; //Logs sold (V)ending items [Lupus] if(log_config.enable_logs&0x4) { log_pick_pc(vsd, "V", vsd->status.cart[idx].nameid, -amount, &vsd->status.cart[idx]); log_pick_pc( sd, "V", vsd->status.cart[idx].nameid, amount, &vsd->status.cart[idx]); } // vending item pc_additem(sd, &vsd->status.cart[idx], amount); vsd->vending[vend_list[i]].amount -= amount; pc_cart_delitem(vsd, idx, amount, 0); clif_vendingreport(vsd, idx, amount); //print buyer's name if( battle_config.buyer_name ) { char temp[256]; sprintf(temp, msg_txt(265), sd->status.name); clif_disp_onlyself(vsd,temp,strlen(temp)); } } // compact the vending list for( i = 0, cursor = 0; i < vsd->vend_num; i++ ) { if( vsd->vending[i].amount == 0 ) continue; if( cursor != i ) // speedup { vsd->vending[cursor].index = vsd->vending[i].index; vsd->vending[cursor].amount = vsd->vending[i].amount; vsd->vending[cursor].value = vsd->vending[i].value; } cursor++; } vsd->vend_num = cursor; //Always save BOTH: buyer and customer if( save_settings&2 ) { chrif_save(sd,0); chrif_save(vsd,0); } //check for @AUTOTRADE users [durf] if( vsd->state.autotrade ) { //see if there is anything left in the shop ARR_FIND( 0, vsd->vend_num, i, vsd->vending[i].amount > 0 ); if( i == vsd->vend_num ) { //Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [skotlex] vending_closevending(vsd); map_quit(vsd); //They have no reason to stay around anymore, do they? } } } Thiscode is notusedinthelatest version of theRA,correctionanddeletion of
×
×
  • Create New...