JhayUrsolino Admin
Posts : 15 Join date : 12/09/2012
| Subject: GM Trade / Drop logs + announce Mon Jan 07, 2013 5:21 pm | |
| - Code:
-
//================================================================================= // create SQL table tradelog //=================================================================================
CREATE TABLE `tradelog` ( `traderaccountid` int(11) DEFAULT NULL, `tradername` varchar(23) DEFAULT NULL, `tradeditemname` varchar(23) DEFAULT NULL, `tradeditemid` int(11) DEFAULT NULL, `tradeditemamount` int(11) DEFAULT NULL, `recievername` varchar(23) DEFAULT NULL, `recieveraccountid` int(11) DEFAULT NULL, `map` varchar(23) DEFAULT NULL, `x` smallint(6) DEFAULT NULL, `y` smallint(6) DEFAULT NULL, `time` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
//=================================================================================
//================================================================================= // In pc.c // Find: // int pc_dropitem(struct map_session_data *sd,int n,int amount) //================================================================================= // Replace Full structure(from start { to end }) with:
int pc_dropitem(struct map_session_data *sd,int n,int amount) { struct item_data *item_data; nullpo_retr(1, sd);
if(n < 0 || n >= MAX_INVENTORY) return 0;
if(amount <= 0) return 0;
if(sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0 || sd->status.inventory[n].amount < amount || sd->state.trading || sd->state.vending || !sd->inventory_data[n] //pc_delitem would fail on this case. ) return 0;
if( map[sd->bl.m].flag.nodrop ) { clif_displaymessage (sd->fd, msg_txt(271)); return 0; //Can't drop items in nodrop mapflag maps. } if( !pc_candrop(sd,&sd->status.inventory[n]) ) { clif_displaymessage (sd->fd, msg_txt(263)); return 0; } if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) return 0; item_data = itemdb_search(sd->status.inventory[n].nameid); pc_delitem(sd, n, amount, 0, 7, LOG_TYPE_PICKDROP_PLAYER); //========================================== // GM Drop log by Smoke //========================================== if(pc_isGM(sd)>=10 && pc_isGM(sd)<=98) { sprintf(atcmd_output, "[%s] dropped item [%s x %d] at [%s %d %d] - If suspected of corruption, please report this on the forums.",sd->status.name,item_data->jname,amount,mapindex_id2name(map_id2index(sd->bl.m)),sd->bl.x,sd->bl.y); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO tradelog(traderaccountid,tradername,tradeditemname,tradeditemid,tradeditemamount,recievername,map,x,y,time) VALUES(%d,'%s','%s',%d,%d,'ITEMDROP','%s',%d,%d,NOW())",sd->status.account_id,sd->status.name,item_data->jname,item_data->nameid,amount,mapindex_id2name(map_id2index(sd->bl.m)),sd->bl.x,sd->bl.y)) Sql_ShowDebug( mmysql_handle ); } //========================================== return 1; }
//================================================================================= // In trade.c // Find : // void trade_tradecommit(struct map_session_data *sd) //================================================================================= // Replace Full structure(from start { to end }) with:
void trade_tradecommit(struct map_session_data *sd) { struct map_session_data *tsd; int trade_i; int flag; struct item_data *item_data; if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade. return;
if ((tsd = map_id2sd(sd->trade_partner)) == NULL) { trade_tradecancel(sd); return; } sd->state.deal_locked = 2; if (tsd->state.deal_locked < 2) return; //Not yet time for trading.
//Now is a good time (to save on resources) to check that the trade can indeed be made and it's not exploitable. // check exploit (trade more items that you have) if (impossible_trade_check(sd)) { trade_tradecancel(sd); return; } // check exploit (trade more items that you have) if (impossible_trade_check(tsd)) { trade_tradecancel(tsd); return; } // check for full inventory (can not add traded items) if (!trade_check(sd,tsd)) { // check the both players trade_tradecancel(sd); return; }
memset(atcmd_output, '\0', sizeof(atcmd_output)); // trade is accepted and correct. for( trade_i = 0; trade_i < 10; trade_i++ ) { int n; if (sd->deal.item[trade_i].amount) { n = sd->deal.item[trade_i].index; item_data = itemdb_search(sd->status.inventory[n].nameid); flag = pc_additem(tsd, &sd->status.inventory[n], sd->deal.item[trade_i].amount,LOG_TYPE_TRADE); if (flag == 0) pc_delitem(sd, n, sd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE); else clif_additem(sd, n, sd->deal.item[trade_i].amount, 0);
//========================================== // GM Trade log by Smoke //========================================== if(pc_isGM(sd)>=20 && pc_isGM(sd)<=98) { sprintf(atcmd_output, "[%s] has traded item [%s x %d] with [%s]", sd->status.name,item_data->jname,sd->deal.item[trade_i].amount,tsd->status.name); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO tradelog(traderaccountid,tradername,tradeditemname,tradeditemid,tradeditemamount,recievername,recieveraccountid,map,x,y,time) VALUES(%d,'%s','%s',%d,%d,'%s',%d,'%s',%d,%d,NOW())",sd->status.account_id,sd->status.name,item_data->jname,item_data->nameid,sd->deal.item[trade_i].amount,tsd->status.name,tsd->status.account_id,mapindex_id2name(map_id2index(sd->bl.m)),sd->bl.x,sd->bl.y)) Sql_ShowDebug( mmysql_handle ); } //========================================== sd->deal.item[trade_i].index = 0; sd->deal.item[trade_i].amount = 0; } if (tsd->deal.item[trade_i].amount) { n = tsd->deal.item[trade_i].index; item_data = itemdb_search(tsd->status.inventory[n].nameid); flag = pc_additem(sd, &tsd->status.inventory[n], tsd->deal.item[trade_i].amount,LOG_TYPE_TRADE); if (flag == 0) pc_delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE); else clif_additem(tsd, n, tsd->deal.item[trade_i].amount, 0); //========================================== // GM Trade log by Smoke //========================================== if(pc_isGM(tsd)>=20 && pc_isGM(tsd)<=98) { sprintf(atcmd_output, "[%s] has traded item [%s x %d] with [%s]", tsd->status.name,item_data->jname,tsd->deal.item[trade_i].amount,sd->status.name); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO tradelog(traderaccountid,tradername,tradeditemname,tradeditemid,tradeditemamount,recievername,recieveraccountid,map,x,y,time) VALUES(%d,'%s','%s',%d,%d,'%s',%d,'%s',%d,%d,NOW())",tsd->status.account_id,tsd->status.name,item_data->jname,item_data->nameid,tsd->deal.item[trade_i].amount,sd->status.name,sd->status.account_id,mapindex_id2name(map_id2index(sd->bl.m)),sd->bl.x,sd->bl.y)) Sql_ShowDebug( mmysql_handle ); }
//========================================== tsd->deal.item[trade_i].index = 0; tsd->deal.item[trade_i].amount = 0; }
} if( sd->deal.zeny || tsd->deal.zeny ) { sd->status.zeny += tsd->deal.zeny - sd->deal.zeny; tsd->status.zeny += sd->deal.zeny - tsd->deal.zeny;
//Logs Zeny (T)rade [Lupus] if( sd->deal.zeny ) log_zeny(tsd, LOG_TYPE_TRADE, sd, sd->deal.zeny); if( tsd->deal.zeny ) log_zeny(sd, LOG_TYPE_TRADE, tsd, tsd->deal.zeny);
sd->deal.zeny = 0; tsd->deal.zeny = 0;
clif_updatestatus(sd, SP_ZENY); clif_updatestatus(tsd, SP_ZENY); } sd->state.deal_locked = 0; sd->trade_partner = 0; sd->state.trading = 0; tsd->state.deal_locked = 0; tsd->trade_partner = 0; tsd->state.trading = 0; clif_tradecompleted(sd, 0); clif_tradecompleted(tsd, 0);
// save both player to avoid crash: they always have no advantage/disadvantage between the 2 players if (save_settings&1) { chrif_save(sd,0); chrif_save(tsd,0); } } | |
|