The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 786 - File: showthread.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/showthread.php 786 errorHandler->error






Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TUTORIAL] - Spheres Webpage Generator
Author Message
Barnabus
Journeyman
*

Posts: 124
Likes Given: 0
Likes Received: 3 in 2 posts
Joined: Apr 2012
Reputation: 1



Post: #1
[TUTORIAL] - Spheres Webpage Generator
Spheres Simple WebPage Generation Can be a handy tool and its not hard to use.

For this example a stone will be created in game and then read from a webpage.


1. Make a stone

PHP Code:
[ITEMDEF i_webpageExample_stone]
DEFNAME=i_webpageExample_stone
NAME
=Web Stone
ID
=i_gravestone_2
TYPE
=t_script

ON
=@CREATE
    ATTR
=ATTR_NEWBIE|ATTR_MOVE_NEVER
    TIMER
=1

ON
=@TIMER
    
// Set some tags on it to read
    
IF <REGION.GUARDED>
        
TAG.RegionGuarded=UP
    
ELSE
        
TAG.RegionGuarded=DOWN
    
ENDIF
    
// And the timer it should be less than the webupdate time, that ill mention in a moment.
    
TIMER=10
    
RETURN 

2. in game .add i_webpageExample_stone in a town on your map.

3. in game write .xshow UID and target the stone, record the UID mines is (040005f1d)

4. above the stone script write this DEFNAME and put your stones UID in

PHP Code:
[DEFNAME WebExample]
WebStoneUid 040005f1d 

5. resync the server

6. open note pad and copy and paste the following

PHP Code:
<html>
    <
head>
        <
title>WebPageExample</title>
    </
head>
    <
body>
         
Webpage Example
    
</body>
</
html

7. save and close the text file and then rename it (Including its extension ".txt") to "webpage.html"

8. if you have a website put the page into it (http://www.mywebsite.com/webpage.html)
if you dont have a website put the file inside your sphere folder (/scripts/web/webpage.html)

9. Open Sphere.ini and scroll down until you find
Code:
///////////////////////////////////////////////////////////////
//////// Webpage Settings
///////////////////////////////////////////////////////////////

// Note, that you can catch error codes by creating sphere404.htm and so on
// for all HTTP error codes sphere support.

[WEBPAGE 1]
// Determines what html file is used as base for the status page
WebPageSrc=scripts/web/spherestatusbase.html
// Determines where the status page is saved
WebPageFile=scripts/web/status.html
// In seconds, how often the status file is updated
WebPageUpdate=60
// Required PLevel to view this page (0 = anyone, 6 = admins only)
PLevel=0

10. Create a new one as below [WEBPAGE 2]
Code:
[WEBPAGE 2]
WebPageSrc=scripts/web/webpage.html // Your new webpage
WebPageFile=scripts/web/webpage.php // You can even change the file extension (Remeber not to use same name if same extension)
WebPageUpdate=20    // 15 Seconds is too fast and has been set just for the purpose of the example.
//sphere reads WebPageSrc and then makes the WebPageFile every WebPageUpdate seconds

while sphere.ini is still open check these settings
Code:
// Use the built in http server
// 0 - disable http server and webpage generation
// 1 - disable http server and enable webpage generation
// 2 - enable http server and webpage generation (default)
UseHttp=2

11. Edit your webpage.html again and change it as shown below.
PHP Code:
<html>
    <
head>
        <
title>WebPageExample</title>
    </
head>
    <
body>
        <
p>Webpage Example</p>
        <
p>%uid.WebStoneUid.NAMEis in %uid.WebStoneUid.REGION.NAME%</p>
        <
p>and Guard Zone is %uid.WebStoneUid.TAG.RegionGuarded%</p>
    </
body>
</
html

12. Open up your stone script and add the following function
PHP Code:
[PLEVEL 1]
WebPage

[FUNCTION WebPage]
WEBLINK C:\sphere\scripts\web\webpage.php 

13. Save and close all open scripts and webpages

14. resync the server and wait for <WebPageUpdate> seconds for the page to be generated.

15. if you own a website goto http://www.mywebsite.com/webpage.php.
if you dont own a website in game use the command .webpage
(This post was last modified: 11-03-2012 10:28 PM by Barnabus.)
11-03-2012 09:36 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Barnabus's post
Post Reply 


Messages In This Thread
[TUTORIAL] - Spheres Webpage Generator - Barnabus - 11-03-2012 09:36 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)