Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-02-2010, 07:56 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
Exporting Variable

Ok, I dont know if this is the right section technically. I was wondering if it is possible to pull the value and name of a gs2 variable and display the name and value on a website? Website is in php, but if I have to use a different language I can.
__________________
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...



Last edited by sssssssssss; 05-02-2010 at 08:15 PM..
Reply With Quote
  #2  
Old 05-02-2010, 10:28 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Getting the variable name, without having it saved as a string will not work. (Unless GS2 saves it as a string somewhere already, of course)
Reply With Quote
  #3  
Old 05-02-2010, 10:44 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
You can use requesturl and send that value to your php server using get requests.

I.e:

PHP Code:
function onCreated() {
  
temp.url "http://www.example.com/update.php?var=whatever&value=somevalue";
  
requesturl(temp.url);

Then in your PHP page access the GET values and use some functionality and save it to a text file or in a database.
__________________
Quote:
Reply With Quote
  #4  
Old 05-02-2010, 11:45 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
If you have a lot of data to send, you can also use this to send it as POST data.
__________________
Reply With Quote
  #5  
Old 05-03-2010, 12:06 AM
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
So i just make that ="somevalue" the value of the var correct?

And I would probably grab maybe 3-4 things seperately, so this should work I think.
__________________
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 05-03-2010, 12:42 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 sssssssssss View Post
So i just make that ="somevalue" the value of the var correct?

And I would probably grab maybe 3-4 things seperately, so this should work I think.
(sorry if I misunderstood your request and I come off as condescending)

If, for example, you wanted a live feed of the number of players on your server, you could create a DB NPC like this:

PHP Code:
function onCreated() {
  
this.onTimeOut();
}

function 
onInitialized() {
  
this.onTimeOut(); // restart the timeout in case NPC-server restarts
}

function 
onTimeOut() {
  
requestURL("http://example.com/update_players.php?players=" allplayers.size() @ "&pass=as!4dKSxm231");
  
this.setTimer(30); // update every 30 seconds

...then in the PHP script...

PHP Code:
// update_players.php

$password 'as!4dKSxm231'// password used to make sure the request came from the server
$ip '127.0.0.1'// IP of the server (find this on http://statistics.graal.us), for extra security

// is it from the server?
if ($ip != $_SERVER['REMOTE_ADDR'] || $password != $_GET['pass']) {
  die(
"request from unauthorized server"); // either the IP or password was wrong
}

$playerCount $_GET['players'];
// now you can store this in a file, MySQL, whatever 
__________________
Reply With Quote
  #7  
Old 05-03-2010, 12:48 AM
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
your comments ran off the snippet (sry if spelt wrong, not in the right mind if that makes sense to u over 21 people).
__________________
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
  #8  
Old 05-03-2010, 12:53 AM
Stephen Stephen is offline
Boom!
Stephen's Avatar
Join Date: May 2004
Location: San Francisco
Posts: 10,410
Stephen has much to be proud ofStephen has much to be proud ofStephen has much to be proud ofStephen has much to be proud ofStephen has much to be proud ofStephen has much to be proud of
Quote:
Originally Posted by sssssssssss View Post
your comments ran off the snippet (sry if spelt wrong, not in the right mind if that makes sense to u over 21 people).
You may be a little confused - it should be possible to scroll the script "snippet" box from side to side.
__________________
Reply With Quote
  #9  
Old 05-03-2010, 02:14 AM
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 that 23 year old "alcohol" problem, my bad, seriously. I would delete my post but then urs wouldnt make 0 sense.
__________________
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
  #10  
Old 05-05-2010, 06:28 AM
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
I actually just realized tonight that I dont need to send the variable to a webpage when someone goes to the webpage technically.

Is there a way I can get the webpage to retrieve a variable on a graal server when the webpage opens, no matter how it actually opens. Like, if i search my page in google, then go to it, i would like the information on the webpage to be up to date with the variable on the server still.
__________________
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
  #11  
Old 05-05-2010, 06:37 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by sssssssssss View Post
I actually just realized tonight that I dont need to send the variable to a webpage when someone goes to the webpage technically.

Is there a way I can get the webpage to retrieve a variable on a graal server when the webpage opens, no matter how it actually opens. Like, if i search my page in google, then go to it, i would like the information on the webpage to be up to date with the variable on the server still.
You can still do what Chris suggested to keep things current:
  • Have the graal server periodically pass a variable to your webserver
  • Store the variable
  • Display the stored variable on a separate webpage
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #12  
Old 05-05-2010, 06:44 AM
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
I have no idea how to get graal to just periodically pass something to my website that way without hitting "open url" in graal first, that way it can send the variable to the site unless requesturl works without doing that, then i just didnt know exactly how requesturl works.
__________________
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
  #13  
Old 05-06-2010, 06:31 AM
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
Since it's kind of on topic, is there a way to send a variable from a site to a server?
__________________
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
  #14  
Old 05-06-2010, 01:24 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
We don't allow binding of sockets for TSocket except in very special cases. So it's technically possible (we run some graal webservers) but is not enabled because of security reasons. It's however possible to open a permanent TSocket to your webserver or whatever, you will have to request to get it enabled for your server (including destination address and port number).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:49 PM.


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