Jump to content
MakeWebGames

Trading System


Veramys

Recommended Posts

Ok so back before MWG closed I had looked around for a trade system and couldn't find one, so I built one to suit my needs. So here it is

SQL For Trades

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Sql for Logs

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Create a file called trade.php if you are using Cronus's mod for the armory uncomment the part about check_loaned. Also if your global_func doesn't have an inv_dropdown I created one

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Inv_dropdown for your global_func.php

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

And for your staff_logs.php file

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

You'll want to add the link to your smenu staff_logs.php?action=tradelogs and of course the trade.php link to explore.

Edit* This was tested on base mccodes and it worked for me, I also stripped all the game specific css coding so it is barebones.

Edited by Veramis
  • Like 5
Link to comment
Share on other sites

Not bad but I would like to add a few suggestions if at all possible. All my suggestions are basically my preference:

1. In your JS change “var” to “let” or “const”. For most of them at least you would be safer with “let”.

Preface:

Over time every bit counts and I only get this from my little time with Laravel. With Eloquent in Laravel there is a handy method called “withTrashed()” and couple with “$table->softDeletes()” in the migration it creates a “deleted_at” column in the table. On your model when you use “withTrashed()” it will query all rows where the “deleted_at” column exists and != null and by default will just skip over those.

Now #2

Taking what I mentioned above, you can trash your logs table and add some sort of Boolean column in your modules table and query everything except for what you don’t want. Then in the staff logs portion you can query everything or just the ones that you want to see.

I hope that makes sense and do with what I said as you will.

  • Like 1
Link to comment
Share on other sites

  • 7 months later...
  • 9 months later...

Looks good but it throws errors for me. Is that because of the PHP update? If it is, can someone tell me how to convert it to make it compatitble with latest version of PHP?

In trade.php?action=create when I create a trade, it does however still show up on the main page

Test Site - Critical Error

A critical error has occurred, and page execution has stopped. Below are the details:
1054: Unknown column 'trMONEY' in 'field list'

Action taken: Attempted to execute query: INSERT INTO `trades_logs`
(`trID`, `trFROM`, `trUSER`, `trMONEY`, `trITEM`, `trQTY`, `trTAK`, `trACC`, `trRMONEY`, `trRITEM`, `trRQTY`, `trRTAK`, `trRACC`)
VALUES (NULL,1,03,100,'2','1','::1',0,0,0,0,'',0)

and when I try to update a trade:

Fatal error: Uncaught Error: Call to undefined function trade_add() in C:\xampp\htdocs\trade.php:362 Stack trace: #0 C:\xampp\htdocs\trade.php(65): add() #1 {main} thrown in C:\xampp\htdocs\trade.php on line 362

and in staff logs:

Parse error: syntax error, unexpected 'view_trade_logs' (T_STRING) in C:\xampp\htdocs\staff_logs.php on line 36

staff_logs.php

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

 

Edited by PHPStudent
Link to comment
Share on other sites

Your 'tradelogs' case in staff_logs.php is missing a colon.
Simply add the missing colon.

The missing column (trMONEY) doesn't exist in trades_logs. The equivalent appears to be trGOLD.
Based on the implementation, I recommend you change the table structure to match.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

  • Like 1
Link to comment
Share on other sites

4 hours ago, Magictallguy said:

Your 'tradelogs' case in staff_logs.php is missing a colon.
Simply add the missing colon.

The missing column (trMONEY) doesn't exist in trades_logs. The equivalent appears to be trGOLD.
Based on the implementation, I recommend you change the table structure to match.

ALTER TABLE trades_logs CHANGE trGOLD trMONEY BIGINT NOT NULL DEFAULT 0;

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Thanks for the help. I ran the SQL and put in the missing colon. Few errors, still:

- Trades log doesnt update with recent trades

- When I put a through a trade with another player, while it still shows up on the main page, I get this:

"Test Site - Critical Error

A critical error has occurred, and this page cannot be displayed. Please try again later.
Query failed"

- Can't update a trade:

atal error: Uncaught Error: Call to undefined function trade_add() in C:\xampp\htdocs\trade.php:345 Stack trace: #0 C:\xampp\htdocs\trade.php(48): add() #1 {main} thrown in C:\xampp\htdocs\trade.php on line 345

Link to comment
Share on other sites

5 minutes ago, PHPStudent said:

 

Thanks for the help. I ran the SQL and put in the missing colon. Few errors, still:

- Trades log doesnt update with recent trades

- When I put a through a trade with another player, while it still shows up on the main page, I get this:

"Test Site - Critical Error

A critical error has occurred, and this page cannot be displayed. Please try again later.
Query failed"

- Can't update a trade:

atal error: Uncaught Error: Call to undefined function trade_add() in C:\xampp\htdocs\trade.php:345 Stack trace: #0 C:\xampp\htdocs\trade.php(48): add() #1 {main} thrown in C:\xampp\htdocs\trade.php on line 345

I'm on my phone so can't do much but head to that line and take out the trade_ part and have it just as function add()

 

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
Reply to this topic...

×   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...