Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Trade System (https://forums.graalonline.com/forums/showthread.php?t=134256857)

Switch 11-08-2009 05:53 PM

Trade System
 
5 Attachment(s)
A trading system using a GUI that I was working on last night.

Create a new weapon called "Trade System" and place what's in the text-document inside.
Both parties need the weapon to work correctly.

Chat "/trade [communityname]" to ask if [communityname] wants to trade (they have 20 seconds to respond).
Chat "/tradeaccept" to accept a requested trade.
Chat "/tradedecline" to decline a requested trade

There's not an "unaccept" function.
This works for all weapon NPCs besides player-hidden ones (starts with "-") and Trade System, Bow, Fireball, Nukeshot, Bomb, Joltbomb, and Superbomb. If you want to change that go to the addItem() function, find the GuiTextListCtrl, and add/remove others.
If you want to change this to another item system (MUDLib, SQLite, etc) or add to what can be traded, go to the addItem() function, find the GuiTextListCtrl, and load the items. Then also go to the server side of the script where cmd is donetrade and add/remove the items how you would normally. The same goes for currency, except the function is addGralat().

cbk1994 11-08-2009 05:59 PM

The script looks good, but your use of with() blocks for finding players is awful :cry:.

Anyway, can you post some screenshots?

fowlplay4 11-08-2009 06:18 PM

Show screens! :)

Should of used this.name, instead of a hard-coded weapon name so they aren't forced to use Trade System as a weapon name.

Have you attempted to glitch/dupe using your system? That's a really important factor that separates a good trade system from a bad one.

Switch 11-08-2009 06:40 PM

Quote:

Originally Posted by fowlplay4 (Post 1537329)
Should of used this.name, instead of a hard-coded weapon name so they aren't forced to use Trade System as a weapon name.

Have you attempted to glitch/dupe using your system? That's a really important factor that separates a good trade system from a bad one.

Except for not allowing the system to be traded, that's done, because for some reason it wouldn't work.

I haven't, no.

Sorry about the JPEG.

sssssssssss 11-08-2009 07:05 PM

Its a very good system bro. :)

cbk1994 11-08-2009 07:38 PM

I just took another look at the code, and noticed a few things...
  • Never trust the client, you're assuming the player has the weapon they say they have and not checking if they really have it serverside. Remember that (with the right utilities), any variable can be changed on clientside, and any function can be called, removed, or renamed.
  • You're doing stuff like for (i=0; i<p1.size(); i++), where you can just do for (temp.i : p1) {
  • Stuff like {"no", "no"} can be {false, false}, which is probably easier to read, but I guess that's just personal style

Tigairius 11-08-2009 07:42 PM

Quote:

Originally Posted by cbk1994 (Post 1537344)
  • Never trust the client, you're assuming the player has the weapon they say they have and not checking if they really have it serverside. Remember that (with the right utilities), any variable can be changed on clientside, and any function can be called, removed, or renamed.

Thank you, I was just about to post that.

This script is not safe and is not safe for server use.

Switch 11-08-2009 09:10 PM

Quote:

Originally Posted by cbk1994 (Post 1537344)
  • You're doing stuff like for (i=0; i<p1.size(); i++), where you can just do for (temp.i : p1) {
  • Stuff like {"no", "no"} can be {false, false}, which is probably easier to read, but I guess that's just personal style

For some reason, doing things like for (temp.pie : this.allpies) give me problems in some cases (I can't list one off the top of my head), so I tend not to do that if it's not for allplayers or players, since it's always worked for those.
I changed it to use booleans in my last edit. I had it using them before but I was having trouble getting the function checkBothAccept to work so I was trying a bunch of different things, and I forgot to change it back.

Quote:

Originally Posted by Tigairius (Post 1537345)
Thank you, I was just about to post that.

This script is not safe and is not safe for server use.

I think I've ironed out most of it in my last edit besides making sure everything on both sides of the trade are the same. The original wasn't meant to prevent memory editing.

Switch 11-11-2009 08:43 PM

1 Attachment(s)
I can't update the original post (or my last), so here's an updated version for the checks in donetrade. It will check before adding or removing anything.

Samposse 11-26-2009 11:23 AM

i like it :P hehe

cbk1994 11-26-2009 06:40 PM

Quote:

Originally Posted by Switch (Post 1537356)
For some reason, doing things like for (temp.pie : this.allpies) give me problems in some cases (I can't list one off the top of my head), so I tend not to do that if it's not for allplayers or players, since it's always worked for those.

Most likely you're trying to remove things

PHP Code:

for (temp.npc player.level.npcs) {
  
npc.destroy();


Things like that can cause trouble because they're removing from the array. Similar things happen when removing weapons from players.

Switch 11-26-2009 11:26 PM

Quote:

Originally Posted by cbk1994 (Post 1540610)
Most likely you're trying to remove things

PHP Code:

for (temp.npc player.level.npcs) {
  
npc.destroy();


Things like that can cause trouble because they're removing from the array. Similar things happen when removing weapons from players.

I'm not even sure what I was trying to do, but I may have been.


All times are GMT +2. The time now is 02:41 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.