Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-08-2009, 05:53 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Trade System

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().
Attached Thumbnails
Click image for larger version

Name:	pic1.JPG
Views:	367
Size:	34.5 KB
ID:	49803   Click image for larger version

Name:	pic3.JPG
Views:	290
Size:	42.9 KB
ID:	49807   Click image for larger version

Name:	pic2.JPG
Views:	291
Size:	38.1 KB
ID:	49808   Click image for larger version

Name:	pic4.JPG
Views:	274
Size:	6.0 KB
ID:	49809  
Attached Files
File Type: txt tradesystem.txt (26.6 KB, 352 views)
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 11-08-2009 at 09:04 PM.. Reason: info for changing, pics, and update
Reply With Quote
  #2  
Old 11-08-2009, 05:59 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
The script looks good, but your use of with() blocks for finding players is awful .

Anyway, can you post some screenshots?
__________________
Reply With Quote
  #3  
Old 11-08-2009, 06:18 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #4  
Old 11-08-2009, 06:40 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by fowlplay4 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #5  
Old 11-08-2009, 07:05 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Its a very good system bro.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #6  
Old 11-08-2009, 07:38 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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
__________________
Reply With Quote
  #7  
Old 11-08-2009, 07:42 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
  • 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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #8  
Old 11-08-2009, 09:10 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
  • 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 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #9  
Old 11-11-2009, 08:43 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
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.
Attached Files
File Type: txt tradesystem.txt (25.4 KB, 226 views)
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 11-11-2009 at 08:57 PM..
Reply With Quote
  #10  
Old 11-26-2009, 11:23 AM
Samposse Samposse is offline
Chopa Shopa !
Samposse's Avatar
Join Date: Nov 2008
Location: Norway
Posts: 87
Samposse is an unknown quantity at this point
Send a message via AIM to Samposse Send a message via MSN to Samposse
i like it :P hehe
__________________
Delitto :3

A
SERVER
UNDER
CONSTRUCTION !

feel free to ask me about delitto
Reply With Quote
  #11  
Old 11-26-2009, 06:40 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
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.
__________________
Reply With Quote
  #12  
Old 11-26-2009, 11:26 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:47 PM.


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