Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Share Posted March 4, 2013 (edited) I'm using: if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `xxxx`(`xxx`,`xxxx`,`xxx`,`xxx`,`xxxx`) VALUES ('%d','%d','%d','%d','%d')",sd->status.char_id, sd->status.cart[index].nameid, sd->vending.amount, sd->vending.value, time)){Sql_ShowDebug(mmysql_handle);continue;} insert works fine, but I close the sale, and the database continues with the recorded data. how to remove recorded data when I close the store? in "vending_closevending" Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->vender_id); dont work Thanks. Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 sd->vender_id is wrong to use. You're looking for the char_id which vender_id is just an index value. You'll need to use sd->status.char_id and that should work just fine in vending_closevending(). 1 Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) sd->vender_id is wrong to use. You're looking for the char_id which vender_id is just an index value. You'll need to use sd->status.char_id and that should work just fine in vending_closevending(). Thx, works fine... but in @at? Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 Autotrade uses the normal vending source. So when a player logs in on the account it will call the closevending() function. Even if the server shuts down that function is used. Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) i'll test... thank you Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 You don't need that line. Look right above and the call for vending_closevending() is made. That will remove them from the table there, so trying to delete them again would return 0 results every time thus making it a useless query. 1 Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) I use @at, but, when relog (show msg server still recognizes your last login) . and dont remove lines... [info]: Character 'Hawk' logged off (using @autotrade). Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 As long as you have your delete query in the if (sd->vending) check it will remove the items just fine. It's possible you have a typo or something. Use like what you have in your first post and include the SQL debug line to see if there is an issue. Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) As long as you have your delete query in the if (sd->vending) check it will remove the items just fine. It's possible you have a typo or something. Use like what you have in your first post and include the SQL debug line to see if there is an issue. Only in auto trade dont delete lines.... --------------------------------------------------------------------- void vending_closevending(struct map_session_data* sd) { nullpo_retv(sd); if( sd->state.vending ) { sd->state.vending = false; clif_closevendingboard(&sd->bl, 0); Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->status.char_id); } } ---------------------------------------------------------------- How to get coordinates and map name? Ex. payon (172, 219) Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 Ah, ok sorry I didn't have any stuff on my laptop and was going from memory. So players who are in autotrade are disassociated from a connection in clif_parse() which is why the vending stuff is still being shown (because vending_closevending() is never called here). You'll need to add a query there to delete the player's stuff from your table. You can just call vending_closevending(sd) and you should be safe to run that in the autotrade check. Again, I highly suggest you make it a if-statement rather than just a straight query. For example: if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->status.char_id)) Sql_ShowDebug(mmysql_handle); Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) Ah, ok sorry I didn't have any stuff on my laptop and was going from memory. So players who are in autotrade are disassociated from a connection in clif_parse() which is why the vending stuff is still being shown (because vending_closevending() is never called here). You'll need to add a query there to delete the player's stuff from your table. You can just call vending_closevending(sd) and you should be safe to run that in the autotrade check. Again, I highly suggest you make it a if-statement rather than just a straight query. For example: if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->status.char_id)) Sql_ShowDebug(mmysql_handle); works fine (clif.c) but when I type @at, the rows are deleted. how to delete only when I relog. --------------------------------------------------------------------------------------------------------------- if (sd->state.autotrade) { //Disassociate character from the socket connection. session[fd]->session_data = NULL; sd->fd = 0; ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", sd->status.name); if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->status.char_id)) Sql_ShowDebug(mmysql_handle); } else if (sd->state.active) { // Player logout display [Valaris] ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off.\n", sd->status.name); clif_quitsave(fd, sd); } else { //Unusual logout (during log on/off/map-changer procedure) ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id); map_quit(sd); } } else { ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL)); } do_close(fd); return 0; } Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Aleos Posted March 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted March 4, 2013 Eh, sorry. That's for the closing of the connection when the command is used. Autotrading players are removed in unit_remove_map which vending_closevending() is called in. So you shouldn't have to make any changes to remove the items. Quote Link to comment Share on other sites More sharing options...
Cyrix Posted March 4, 2013 Group: Members Topic Count: 44 Topics Per Day: 0.01 Content Count: 150 Reputation: 13 Joined: 02/16/12 Last Seen: April 10, 2023 Author Share Posted March 4, 2013 (edited) How to get coordinates and map name? Ex. payon (172, 219) And this line dont work... can u help again. if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `xxxxx`(`xxxx`,`xxxx`,`xxxx`,`xxxx`, `card0`, `card1`, `card2`, `card3`, `refine`, ) VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d')",sd->status.char_id, sd->status.cart[index].nameid, sd->vending.amount, sd->vending.value, sd->vending.card[0], sd->vending.card[1], sd->vending.card[2],, sd->vending.card[3], sd->vending.refine)) Edited March 4, 2013 by Cyrix Quote Link to comment Share on other sites More sharing options...
Question
Cyrix
I'm using:
if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `xxxx`(`xxx`,`xxxx`,`xxx`,`xxx`,`xxxx`) VALUES ('%d','%d','%d','%d','%d')",sd->status.char_id, sd->status.cart[index].nameid, sd->vending.amount, sd->vending.value, time))
{
Sql_ShowDebug(mmysql_handle);
continue;
}
insert works fine, but I close the sale, and the database continues with the recorded data.
how to remove recorded data when I close the store?
in "vending_closevending"
Sql_Query(mmysql_handle, "DELETE FROM `xxxx` WHERE `char_id`='%d'", sd->vender_id);
dont work
Thanks.
Edited by CyrixLink to comment
Share on other sites
12 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.