• 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!

Doesn't work for me, i can't see the players on the web.

stream.json:
Code:
{"Rasmus":[998,999,7,302,3,94,94,94,94,0,0,0,0]

What is the problem? I installed the Outfitter thing too.

same problem?
 
EDIT: Now it seems to be working fine but i have the same problem.

{"Alfheim":[32362,32244,7,512,0,0,114,86,0,0,0,0,0],}
But doesn't appear on web!
 
Last edited:
Yeah I got the same problem. My stream.json file is being created correctly, but the website doesn't show anything :(

How to solve this?
 
I've made it to work, at least for me.

site (.php or .html)
Code:
<!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:999;position:absolute;top:'+((k[1])*32-15)+'px;left:'+((k[0])*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>

In globalevents:
Code:
function onThink(cid, interval)
local centerPos = {x=5041,y=5052,z=7}
	local cyko = {   
		streampos = getSpectators(centerPos, 12, 10, false), --Middle pos of the temple and radius.
		ghost = false, --You want allow players which using ghost? true of false. 
	}      
	local stream = "{"
	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)..'":['.. getCreaturePosition(cid).x - (centerPos.x-10) ..','.. getCreaturePosition(cid).y - (centerPos.y-9) ..','.. getCreaturePosition(cid).z ..','.. getCreatureOutfit(cid).lookType ..','.. getCreatureOutfit(cid).lookAddons ..','.. getCreatureOutfit(cid).lookHead ..','.. getCreatureOutfit(cid).lookBody ..','.. getCreatureOutfit(cid).lookLegs ..','.. getCreatureOutfit(cid).lookFeet ..',0,'.. (getCreatureLookDirection(cid)) ..',' .. getCreatureOutfit(cid).lookTypeEx .. ','.. getCreatureSkullType(cid) ..'],';
			end
		end
	end
	stream = stream .. '}'
	local text = stream
	local file = io.open("/home/ots/www/cache/stream.json", "w")
	file:write("".. text .. "")
	file:close() 
	return true 
end
Configure var centerPos to your own position and it should work.
You can do screenshot in-game (or in map editor) and place it as background at the site.


@EDIT:

And i forgot that u need to change:
Code:
local file = io.open("/home/ots/www/cache/stream.json", "w")
 
Last edited:
@up
it works in console, but the stream.json doesnt update and nothing in website
 
I've made it to work, at least for me.

I cant see what code changes you made? The GlobalEvents is what I created, and php is still the same .. Can you help me? what you changed ..?

- - - Updated - - -

@up
it works in console, but the stream.json doesnt update and nothing in website

If you use my globalevents, you need change this way..

local file = io.open("/home/ots/www/cache/stream.json", "w")
 
There was a problem with position of character. Globalevents code sent a position of character(for example x=3000, y=3000, z=7) and the js code was printing character in the position of top and left: ~15000 so it was far far away from our screens.
Second problem was with z-index - if somebody used background - it hid behind characters.
Change for both problems was in line:
Code:
s += '<div style="z-index:999;position:absolute;top:'+((k[1])*32-15)+'px;left:'+((k[0])*32-7)+'px;width:64px;height:64px;background:transparent url(';
Another change was in globalevent code to center characters to their right positions.
 
mine is set to
local file = io.open("C:\xampp\htdocs\cache\stream.json", "w")
and the file isnt updating yet ;/
 
aa, never thought about that. Works now xD!
Thanks budd.
 
You're welcome, I'm glad I helped you :p

Btw, I recommend not to use the cache folder (in Gesior) because it can cause problems with the folder permissions.
 
I've made it to work, at least for me.

site (.php or .html)
Code:
<!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*- <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:999;position:absolute;top:'+((k[1])*32-15)+'px;left:'+((k[0])*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(/(*)/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);">*<\/div>';
                       
                        s += '<\/div><\/div>';
                 }
                document.getElementById('put').innerHTML = s;
                setTimeout("update", 250);
 
        } else {
                /*setTimeout(update, 3000, 2);
                document.getElementById('onlinecount').innerHTML = 'Viewers: '+data+'*- <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>

In globalevents:
Code:
function onThink(cid, interval)
local centerPos = {x=5041,y=5052,z=7}
	local cyko = {   
		streampos = getSpectators(centerPos, 12, 10, false), --Middle pos of the temple and radius.
		ghost = false, --You want allow players which using ghost? true of false. 
	}      
	local stream = "{"
	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)..'":['.. getCreaturePosition(cid).x - (centerPos.x-10) ..','.. getCreaturePosition(cid).y - (centerPos.y-9) ..','.. getCreaturePosition(cid).z ..','.. getCreatureOutfit(cid).lookType ..','.. getCreatureOutfit(cid).lookAddons ..','.. getCreatureOutfit(cid).lookHead ..','.. getCreatureOutfit(cid).lookBody ..','.. getCreatureOutfit(cid).lookLegs ..','.. getCreatureOutfit(cid).lookFeet ..',0,'.. (getCreatureLookDirection(cid)) ..',' .. getCreatureOutfit(cid).lookTypeEx .. ','.. getCreatureSkullType(cid) ..'],';
			end
		end
	end
	stream = stream .. '}'
	local text = stream
	local file = io.open("/home/ots/www/cache/stream.json", "w")
	file:write("".. text .. "")
	file:close() 
	return true 
end
Configure var centerPos to your own position and it should work.
You can do screenshot in-game (or in map editor) and place it as background at the site.


@EDIT:

And i forgot that u need to change:
Code:
local file = io.open("/home/ots/www/cache/stream.json", "w")

any clue how to set the outfit line for this one?
cant get it to work :S

http://otland.net/f118/9-86-outfit-shower-190380/
 
outfit shows but wrong direction all time xd

That is because your Lua is throwing directions values on a different way than the outfitter needs.

You can do this in your web:
PHP:
s += 'outfitter.php?a='+k[3]+'&b='+k[4]+'&c='+k[5]+'&d='+k[6]+'&e='+k[7]+'&f='+k[8]+1+'&g='+k[9]+'&h='+(k[10]+1)+'&i=1';

Or this in your Lua:
Lua:
(getCreatureLookDirection(cid)+1)

Your server is probably addressing directions as:
0 = north
1 = east
2 = south
3 = west

But the outfitter does it this way:
1 = north
2 = east
3 = south
4 = west

So thats why the +1 I added to the code.

Now it should work :)
 
Thanks a lot dude, Im using the lua method. The HTML method didnt work, it disabled the whole outfit thing :p

Thanks again =))

You must spread some Reputation around before giving it to angelobodj again.
 
if anyone could help me i've tried to do this from all diffrent ways on what people have tried but i've had no luck on getting my players to pop up, my stream is like this at the moment Cytera - Stream if anyone could help it would be awesome!


-- Edited --


website acc: Using Gesior

Windows/Linus: Using Windows

My Path: C:/xammp/htdocs/cache/stream.json", "w")

i also get this code on my stream.json

Code:
{"Grabbo":[7,9,7,302,0,44,44,44,44,0,1,0,0],}
 
Last edited:
if anyone could help me i've tried to do this from all diffrent ways on what people have tried but i've had no luck on getting my players to pop up, my stream is like this at the moment Cytera - Stream if anyone could help it would be awesome!

website acc: Using Gesior

Windows/Linus: Using Windows

My Path: C:/xammp/htdocs/cache/stream.json", "w")

i also get this code on my stream.json

Code:
{"Grabbo":[7,9,7,302,0,44,44,44,44,0,1,0,0],}

same here, anyone know the solution?
 
Back
Top