Jump to content
  • 0

[solved] Vending Sold Price History


jamesandrew

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.07
  • Content Count:  58
  • Reputation:   3
  • Joined:  06/21/23
  • Last Seen:  

I'm facing a problem where players are abusing vending to rmt their zeny. I know pickup_log only has vending log but without the prices for what they sold.

Can someone please help me making a script that could record price of sold vending items to sql?

Thanks
 

Edited by jamesandrew
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  2
  • Reputation:   0
  • Joined:  07/26/21
  • Last Seen:  

Can try using the following script:

- Open your rAthena server's database management tool.

- Create a new table in your database with the following columns:

`id`, `name`, `price`, `vend_time`, `vend_map`, `vend_x`, `vend_y`

 

- In your server's `conf/import/tables.sql` file, add the following line:

`pickup_log: id int(11) NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL DEFAULT '', price int(11) NOT NULL DEFAULT '0', vend_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00', vend_map varchar(50) NOT NULL DEFAULT '', vend_x int(11) NOT NULL DEFAULT '0', vend_y int(11) NOT NULL DEFAULT '0', PRIMARY KEY (id)`

- In your server's `src/map/vending.c` file, find the `vending_buyitem` function.
- Inside the `vending_buyitem` function, add the following lines of code:

```
char vend_name[NAME_LENGTH];
int vend_price;
struct map_session_data *sd = map_id2sd(vendor_id);
if (sd != NULL) {
    safestrncpy(vend_name, itemdb_name(item_data[item_id]), NAME_LENGTH);
    vend_price = (int)price;
    SQL->EscapeString(sql_handle, sql_query, vend_name, sizeof(vend_name));
    SQL->Query(sql_handle, "INSERT INTO pickup_log (name, price, vend_time, vend_map, vend_x, vend_y) VALUES ('%s', '%d', NOW(), '%s', '%d', '%d')", vend_name, vend_price, mapindex_id2name(sd->bl.m), sd->bl.x, sd->bl.y);
}


```

This will create a new entry in the `pickup_log` table every time a player buys an item from a vending shop, recording the name of the item, its price, the time of the transaction, and the location of the vending shop.

Edited by MasterJohn
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  232
  • Reputation:   86
  • Joined:  06/30/18
  • Last Seen:  

If you want to log vending for every npc shop, not for a specific one, this is a case for the source modification section.

On 10/20/2023 at 10:19 AM, jamesandrew said:

Not the npc. I mean vending skill from merchant class

I see, well that is also a case for the source mod section.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.07
  • Content Count:  58
  • Reputation:   3
  • Joined:  06/21/23
  • Last Seen:  

6 hours ago, Winterfox said:

If you want to log vending for every npc shop, not for a specific one, this is a case for the source modification section.

Not the npc. I mean vending skill from merchant class

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...