• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent Stream Live From Your Website!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,284
Location
Sweden?
Hello, here is a stream code, which will stream live from your website.

Credits goes also to TGYoshi for the code, i just made some edits to make it work for us.

PnO226.png


Thanks to Raggaer, for the php! credits to his help :)

At globalevents/globalevents.xml add this line:
XML:
<globalevent name="Stream" interval="1" event="script" value="stream.lua"/>

At globalevents/scripts and create new lua and name it "stream.lua":
Lua:
function onThink(cid, interval)
local cyko = {    
    	streampath = io.open('/var/www/cache/stream.json',"w"),
	streampos = getSpectators({x=1000,y=1000,z=7}, 18, 15, false), --Middle pos of the temple and radius.
	ghost = false, --You want allow players which using ghost? true of false.
}      
    local stream = "{"
    local generateplayerspos = getThingPos(cid)
    local generateoutfits = getCreatureOutfit(cid)
	if cyko.streampos then
		for i = 1, #cyko.streampos do
			local cid = cyko.streampos[i]
			if isPlayer(cid) and isPlayerGhost(cid) == cyko.ghost then
				stream = stream .. '"'..getCreatureName(cid)..'":['.. generateplayerspos.x ..','.. generateplayerspos.y ..','.. generateplayerspos.z ..','.. generateoutfits.lookType ..','.. generateoutfits.lookAddons ..','.. generateoutfits.lookHead ..','.. generateoutfits.lookBody ..','.. generateoutfits.lookLegs ..','.. generateoutfits.lookFeet ..',0,'.. (getCreatureLookDirection(cid)) ..',' .. generateoutfits.lookTypeEx .. ','.. getCreatureSkullType(cid) ..'],';
			end
		end
	end
	stream = stream .. '}'
        cyko.streampath:write(stream)
        cyko.streampath:close() 
        return true 
end

Now at your website you can use this:
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Pokemon Portal - Stream</title>
        <style type="text/css">
.alpha_wrapper {
        padding-top: 8px;
        float: left;
        position: relative;
        color: #fff;
        width: 96px;
        text-align: center;
}
.name {
        white-space: nowrap;
        color: rgb(0, 255, 0);
        font-size:10px;
        width: 50%;
        margin: 0px auto;
        padding-bottom: 2px;
        font-family: Verdana;
        text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
.skull {
        background: transparent url(images/redskull.gif) no-repeat;
        position: absolute;
        top: 31px;
        left: 57px;
        width: 11px;
        height: 11px;
        width: 50%;
        margin: 0px auto;
}
        </style>
</head>
<body style="background-image:url('');background-color:#525453;background-repeat:repeat-x;">
<div style="color:white;float:center;text-align:center;margin: 0 auto;text-shadow:0 0 5px #fff;font-family:Georgia,serif;font-weight:strong;font-size:35px;">Pokemon Portal Livestream</div>
<div id="onlinecount" style="color:white;clear:both;font-family:Arial, sans-serif;float:center;text-align:center;margin:0 auto">Viewers: 0&nbsp;- <a href="#" style="color: white;" onclick="window.close();">Close</a></div>
<div style="box-shadow:0 0 20px #000;clear:both;font-family:Arial, sans-serif;color:white;width:737px;height:605px;border:2px solid black;margin:5px auto;background-image:url('images/stream.png');text-align:center;overflow:hidden;position:relative;" id="put"></div>
 
<script type="text/javascript">
<!--
function disableSelection(target){
 
    if (typeof target.onselectstart!="undefined")
        target.onselectstart=function(){return false}
 
    else if (typeof target.style.MozUserSelect!="undefined")
        target.style.MozUserSelect="none"
    else
        target.onmousedown=function(){return false}
 
    target.style.cursor = "default"
}
 
disableSelection(document.body);
 
var uid = Math.floor(Math.random()*(10000000-1))+10000000;
function handler(data, hid) {
        if (hid == 1) {
                try { var obj = eval("(" + data + ")"); }
                catch(err) {}
       
                var s = '';
                for (x in obj) {
                        var k = obj[x];
       
                        s += '<div style="z-index:'+(k[1]-20)+';position:absolute;top:'+((k[1]-992)*32-15)+'px;left:'+((k[0]-992)*32-7)+'px;width:64px;height:64px;background:transparent url(';
                        if(k[3] == 0)
                                s += 'images/items/'+k[11]+'.gif';
                        else
                                s += 'outfitter.php?id='+k[3]+'&addons='+k[4]+'&head='+k[5]+'&body='+k[6]+'&legs='+k[7]+'&feet='+k[8]+'&mount='+k[9]+'&dir='+k[10];
       
                        s += ') no-repeat right bottom;">\
                        <div class="alpha_wrapper">\
                                <div class="name" style="margin: 5px 19px">'+x.replace(/(&nbsp)/g,' ')+'<\/div>\
                                <div style="margin-left: 34px; margin-top: -7px; width: 25px; height: 2px; background-color: rgb(0, 191, 0); border: 1px solid black;"><\/div>';
                        if(k[12] >= 3)
                                s += '<div class="skull" style="background-image:url(img/'+(k[12] == 3 ? 'white' : (k[12] == 4 ? 'red' : 'black')) + 'skull.gif);">&nbsp;<\/div>';
                       
                        s += '<\/div><\/div>';
                 }
                document.getElementById('put').innerHTML = s;
                setTimeout("update", 250);
 
        } else {
                /*setTimeout(update, 3000, 2);
                document.getElementById('onlinecount').innerHTML = 'Viewers: '+data+'&nbsp;- <a href="http://pportal.net/">Back to Pokemon Portal Website</a>';*/
        }
}
function update(hid) {
        var xhr;
        try {
                xhr=new XMLHttpRequest();
        }
        catch (e) {
                try {
                        xhr=new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e) {
                        try {
                                xhr=new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e) {
                                alert("Your browser does not support AJAX!");
                                return false;
                        }
                }
        }
        if (hid == 1) {
                xhr.open("GET","/cache/stream.json?"+Math.random(), true);
        } else {
                //xhr.open("GET","lv_update.php?id="+uid, true);
        }
        xhr.onreadystatechange=function() {
                if(xhr.readyState==4) {
                        handler(xhr.responseText, hid);
                        setTimeout(update,500,1);
                }
        }
 
        xhr.send(null);
}
//setTimeout(update,100,1);
handler({"2": ["",1003,1003,6,132,2,115,0,132,114,0,3,0,1],
}, 1);
update(1);
//setTimeout(update,100,2);
</script>
</body>
</html>

For the outfits you can use this:
http://otland.net/f118/outfitter-8-60-showing-outfits-website-167046/

Enjoy!
 
Last edited:
Uploaded pic :p, but i dont have the outfits bcz its custom server and those outfits id doesnt fit to my server.
 
I would like to see any demo website with that. Any one has it to show working?


I would like to confirm if it is as just amazing as it looks!

Great job!!
 
Error.
[14/12/2012 00:35:30] [Error - GlobalEvent Interface]
[14/12/2012 00:35:31] data/globalevents/scripts/stream.lua:eek:nThink
[14/12/2012 00:35:31] Description:
[14/12/2012 00:35:31] data/globalevents/scripts/stream.lua:11: attempt to index global 'pos' (a nil value)
[14/12/2012 00:35:31] stack traceback:
[14/12/2012 00:35:31] data/globalevents/scripts/stream.lua:11: in function <data/globalevents/scripts/stream.lua:8>
[14/12/2012 00:35:31] [Error - GlobalEvents::think] Couldn't execute event: Stream
 
[14/12/2012 01:24:51] [Error - GlobalEvent Interface]
[14/12/2012 01:24:52] data/globalevents/scripts/stream.lua:eek:nThink
[14/12/2012 01:24:52] Description:
[14/12/2012 01:24:52] data/globalevents/scripts/stream.lua:17: attempt to concatenate global 'stream' (a nil value)
[14/12/2012 01:24:52] stack traceback:
[14/12/2012 01:24:52] data/globalevents/scripts/stream.lua:17: in function <data/globalevents/scripts/stream.lua:8>
[14/12/2012 01:24:52] [Error - GlobalEvents::think] Couldn't execute event: Stream
 
Wow, really nice, but it creates the entire zone? I mean if yo u change the area, it will create the entire new area?

Maybe you could able people to search entire map choosing them which locations to see.
 
Fixed and made some changes.
 
Wow, really nice, but it creates the entire zone? I mean if yo u change the area, it will create the entire new area?

Maybe you could able people to search entire map choosing them which locations to see.

I think that you have to put the photo in background, with that you just can show which player is in X pos and show it, s you can't create a map or something else
 
1. Take a picture on Ex. temple. Then add it into the folder you can configure at the stream.php
width:737px;height:605px;border:2px solid black;margin:5px auto;background-image:url('images/stream.png')
then fix the stream path:
streampath = io.open('/var/www/cache/stream.json',"w"),
And add the middle pos of the temple:
streampos = getSpectators({x=1000,y=1000,z=7}, 18, 15, false), --Middle pos of the temple and radius.
 
What is this?

PHP:
streampath = io.open('/var/www/cache/stream.json',"w"),

Where I have this route?
 
Thanks to Zoom Iker:
Try this for windows:
Code:
streampath = io.open('www\stream.txt/',"w"),
 
@Raggaer

Could you give me the paths of windows, idk how to fix that. Thanks.
 
Bro... but I dont have this document stream.txt! :S
is a very complicated system.
 
Back
Top