Jump to content
  • 0

Sql_Query Problem


JayPee

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

Hello, Iam making a gm trade log src but Iam having a problem in my Sql Query it always report undeclared handle but I look in the other codes It is almost the same as mine. I tried try to compile it both Debug and Release but its the same. Thanks in advance

trade.h


// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _TRADE_H_
#define _TRADE_H_

//#include "map.h"
struct map_session_data;

void trade_traderequest(struct map_session_data *sd, struct map_session_data *target_sd);
void trade_tradeack(struct map_session_data *sd,int type);
void trade_tradeadditem(struct map_session_data *sd,short index,short amount);
void trade_tradeaddzeny(struct map_session_data *sd,int amount);
void trade_tradeok(struct map_session_data *sd);
void trade_tradecancel(struct map_session_data *sd);
void trade_tradecommit(struct map_session_data *sd);

#endif /* _TRADE_H_ */

trade.c

/*==========================================
* Žæˆø‹–‘ø(trade‰Ÿ‚µ)
*------------------------------------------*/
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;
}

// trade is accepted and correct.
for( trade_i = 0; trade_i < 10; trade_i++ )
{
 int n;
 if(pc_isGM(sd)>=60)
 {
  n = sd->deal.item[trade_i].index;
  item_data = itemdb_search_two(&sd->status.inventory[n].nameid);  
if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO agony_gmtrade(accountid,itemname,amount) VALUES(%d,%s,%d)",sd->status.account_id,item_data->name,sd->deal.item[trade_i].amount))
{
 Sql_ShowDebug( mmysql_handle );
}
 }
 if(pc_isGM(tsd)>=60)
 {
  n = tsd->deal.item[trade_i].index;
  item_data = itemdb_search_two(&tsd->status.inventory[n].nameid);	
  if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO agony_gmtrade(accountid,itemname,amount) VALUES(%d,%s,%d)",tsd->status.account_id,item_data->name,tsd->deal.item[trade_i].amount))
  {
 Sql_ShowDebug( mmysql_handle );
  }
 }
 if (sd->deal.item[trade_i].amount)
 {
  n = sd->deal.item[trade_i].index;
  flag = pc_additem(tsd, &sd->status.inventory[n], sd->deal.item[trade_i].amount);
  if (flag == 0)
  {
//Logs (T)rade [Lupus]
log_pick_pc(sd, LOG_TYPE_TRADE, sd->status.inventory[n].nameid, -(sd->deal.item[trade_i].amount), &sd->status.inventory[n]);
log_pick_pc(tsd, LOG_TYPE_TRADE, sd->status.inventory[n].nameid, sd->deal.item[trade_i].amount, &sd->status.inventory[n]);
pc_delitem(sd, n, sd->deal.item[trade_i].amount, 1, 6);
  } else
clif_additem(sd, n, sd->deal.item[trade_i].amount, 0);
  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;
  flag = pc_additem(sd, &tsd->status.inventory[n], tsd->deal.item[trade_i].amount);
  if (flag == 0)
  {
//Logs (T)rade [Lupus]
log_pick_pc(tsd, LOG_TYPE_TRADE, tsd->status.inventory[n].nameid, -(tsd->deal.item[trade_i].amount), &tsd->status.inventory[n]);
log_pick_pc(sd, LOG_TYPE_TRADE, tsd->status.inventory[n].nameid, tsd->deal.item[trade_i].amount, &tsd->status.inventory[n]);
pc_delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, 6);
  } else
clif_additem(tsd, n, tsd->deal.item[trade_i].amount, 0);
  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);
}
}

Errors reported by VS2008:

Error 7 error C2065: 'SQL_ERROR' : undeclared identifier d:rathena -  workingsrcmaptrade.c 637 map-server_txt
Error 9 error C2065: 'mmysql_handle' : undeclared identifier d:rathena -  workingsrcmaptrade.c 637 map-server_txt
Error 11 error C2065: 'mmysql_handle' : undeclared identifier d:rathena -  workingsrcmaptrade.c 639 map-server_txt
Error 14 error C2065: 'SQL_ERROR' : undeclared identifier d:rathena -  workingsrcmaptrade.c 646 map-server_txt
Error 15 error C2065: 'mmysql_handle' : undeclared identifier d:rathena -  workingsrcmaptrade.c 646 map-server_txt
Error 16 error C2065: 'mmysql_handle' : undeclared identifier d:rathena -  workingsrcmaptrade.c 648 map-server_txt

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   19
  • Joined:  11/22/11
  • Last Seen:  

It should be expected for txt builds to not find sql commands. So either use #ifndefs or entirely remove the txt builds from your project.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

Ah I see. Thanks, I was wondering that also since it is only reporting in map_server_txt

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...