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

LUA code for TFS 1.0 [added missing functions]:
PHP:
local centerPos = {x=5041,y=5052,z=7}
local showGhost = false --You want show players which using ghost? true of false.

-- TFS 1.0 compat, get direction of creature
function getCreatureLookDirection(cid) local c = Creature(cid) return c ~= nil and c:getDirection() or false end
-- TFS 1.0 compat, only player may have skull in TFS 1.0, so for NPC/monsters function returns SKULL_NONE
function getCreatureSkullType(cid) local p = Player(cid) return p ~= nil and p:getSkull() or SKULL_NONE end

function onThink(cid, interval)
    local streampos = getSpectators(centerPos, 12, 10, false)
    local stream = "{"
    if streampos then
        for i = 1, #streampos do
            local cid = streampos[i]
            if isPlayer(cid) and isPlayerGhost(cid) == showGhost 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 file = io.open("/home/ots/www/cache/stream.json", "w")
    file:write("".. stream .. "")
    file:close()
    return true
end
 
Hmm, I can't get this to work
, no errors in console,but there is only 1 picture,that dosnt move,like the picture i took and putted in the Images,however,im not too sure if my path is correct
Code:
('C:\xampp\htdocs\cache\stream.json',"w"),
ive created the Stream.json my self,in the cache folder
Code:
C:\xampp\htdocs\cache
Gesior 2012
Help would be really really appriacated :D
Imfreezing
 
If anyone needs it for TFS 1.0 add me on skype: phoowned ([email protected])
I made new version of that JS and LUA script for TFS 1.0, but I need someone to test it before I release it in new thread.
 
local cyko = { <-----------------------is assumed that this is not the name of the player?
streampath = io.open('/var/www/cache/stream.json',"w"), <------- I have not this file


Since the link would be placed at the pictures of the outfits and where?

fondo.jpg


anyone can help me?
thanks and regards
 
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![/I]
 
look found but an error appear:

found here
http://premia-global.net/


in function '__index'
data/globalevents/scripts/stream.lua:47: in function <data/globalevents/scripts/stream.lua:25>
[Error - GlobalEvents::think] Failed to execute event: stream

AND

data/globalevents/scripts/stream.lua:47: attempt to index local 'streampath' (a nil value)
 
Back
Top