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 12-15-2009, 06:37 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Currency Converter

Hello, this may be my first Code Gallery contribution.
I got inspired by Jerret's (fowlplay4) Translate script that used Google as it's engine.
So, I've made a Google Currency Converter out of Jerret's Script!

Class "class_currency":*
PHP Code:
function onCreated() {
  
// For Server's running on the 64-bit NPC-Server
  
addDNSEntry("www.google.com""72.14.213.95"); 
}
function 
Convert(amountfromto) {
  
// Make from and To UpperCase
  
temp.from.upper();
  
temp.to.upper();
  
  
// Determine URL
  
temp.site "http://www.google.com/finance/converter";
  
temp.url  temp.site "?a=" amount "&from=" temp."&to=" temp.t;

  
// Request URL
  
temp.req requesturl(temp.url);
  
this.catchevent(temp.req"onReceiveData""onConvert");
}
function 
onConvert(obj) {
  
// Perseing Time!
  
temp.parse =  obj.fulldata.substring(obj.fulldata.pos("<!DOCTYPE") + obj.fulldata.pos("<div id=currency_converter_result>") );
  
temp.parse2 temp.parse.substring(0temp.parse.pos("</span>"));
  
temp.parse3 temp.parse2.substring("<div id=currency_converter_result>".length());
  
temp.parse4 temp.parse3.substring(0temp.parse3.pos("<span class=bld>")) @ 
                
temp.parse3.substring(temp.parse3.pos("<span class=bld>") + "<span class=bld>".length());
  
// Echo Parsed Data
  
echo(temp.parse4);

*=The class can be named anything you want,
but I named it for the Example usage.


Example Usage:
PHP Code:
function onCreated() {
  
this.join("class_currency");
  
Convert(1"Eur""UsD");
  
// Would echo "1 EUR = 1.4632 USD"

Currency list at Attachment.

Cheers
Attached Files
File Type: txt Currencys.txt (1.5 KB, 220 views)
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #2  
Old 12-15-2009, 06:40 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
Nice work.
__________________
Quote:
Reply With Quote
  #3  
Old 12-15-2009, 08:09 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Neat !
Reply With Quote
  #4  
Old 12-18-2009, 11:04 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by fowlplay4 View Post
Nice work.
Quote:
Originally Posted by alexandralove View Post
Neat !

thanks (:
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #5  
Old 12-18-2009, 07:11 PM
benpoke103 benpoke103 is offline
Zvarri!
benpoke103's Avatar
Join Date: Jun 2002
Posts: 332
benpoke103 will become famous soon enough
Very cool.

Would be interesting to see it run on a timer however, that will convert from a single unit of currency to another in order to get the differentials to store them locally, and have the script run serverside and not depend on google for approx. 6 hours
__________________
Need support? Here's how to reach me.

Forum PM (Preferred)
#graaldt @ Freenode
Reply With Quote
  #6  
Old 12-18-2009, 09:33 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by benpoke103 View Post
Very cool.
Thank you.

Quote:
Originally Posted by benpoke103 View Post
Would be interesting to see it run on a timer however, that will convert from a single unit of currency to another in order to get the differentials to store them locally, and have the script run serverside and not depend on google for approx. 6 hours
Interesting, Why? Don't really see a reason why you should store it locally.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #7  
Old 12-18-2009, 11:28 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 benpoke103 View Post
Very cool.

Would be interesting to see it run on a timer however, that will convert from a single unit of currency to another in order to get the differentials to store them locally, and have the script run serverside and not depend on google for approx. 6 hours
Well, this script is probably never going to be actually used (not very useful for Graal), but if it ever was, I agree that it'd be good to cache.
__________________
Reply With Quote
  #8  
Old 12-19-2009, 01:57 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by cbk1994 View Post
this script is probably never going to be actually used
well thanks alot for that
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #9  
Old 12-19-2009, 02:03 AM
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 Deas_Voice View Post
well thanks alot for that
What do you think it could be used for on a Graal server?
__________________
Reply With Quote
  #10  
Old 12-19-2009, 02:07 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by cbk1994 View Post
What do you think it could be used for on a Graal server?
well no, i agree that it's not useful to a server, but it's gonna be used.....
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #11  
Old 12-19-2009, 02:09 AM
Rufus Rufus is offline
Registered User
Join Date: Jun 2004
Location: United Kingdom
Posts: 4,698
Rufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud of
It could be used on Era and Zodiac. It would allow the players to determine how much USD they can sell their items for if they're not in the United States.
__________________
Quote:
Originally Posted by Loriel View Post
Seriously, you have ****-all for content and you're not exactly pulling in new developer talent, angling for prestigious titles should be your last concern.
Reply With Quote
  #12  
Old 12-19-2009, 02:13 AM
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 Rufus View Post
It could be used on Era and Zodiac. It would allow the players to determine how much USD they can sell their items for if they're not in the United States.
__________________
Reply With Quote
  #13  
Old 12-19-2009, 02:15 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Rufus View Post
It could be used on Era and Zodiac. It would allow the players to determine how much USD they can sell their items for if they're not in the United States.
haha good one, don't forget GK!
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #14  
Old 12-19-2009, 02:16 AM
Rufus Rufus is offline
Registered User
Join Date: Jun 2004
Location: United Kingdom
Posts: 4,698
Rufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud of
Quote:
Originally Posted by cbk1994 View Post
Lighten up.
__________________
Quote:
Originally Posted by Loriel View Post
Seriously, you have ****-all for content and you're not exactly pulling in new developer talent, angling for prestigious titles should be your last concern.
Reply With Quote
  #15  
Old 12-19-2009, 02:18 AM
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 Rufus View Post
Lighten up.
It was more of an admittance of defeat than anything .
__________________
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 03:23 AM.


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