• 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 The bear remote

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
Hello!

My last release. This is a better remote control than original. If you use some old open tibia distros maby you use it. This is better than original remote control but still beta.

To use it you need a host and the remote. i will pots both here.

First the host.

Host:

Tested on: TFS 0.3.x 0.2.x open tibia.
Requeriments: Lua socket, lua ex. (get it here)

Well our remote its like the first but more useful.
Lets install.
Add this XML on data/xml (remote.xml)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<remote>
	<conf ip="*" port="7178" password="0xff" maxbuffersize="2024" debugmode="0"/>
	<security onlylocalhost="1" allowfilemannager="1" showfilesondir="1" maxconnections="2"	allowloadstring="1"/>
	<ignoredfile>
		<file name="remote.xml"/>
		<file name="remote.lua"/>
		<file name="%@.log"/>  <!-- use %@ to all name-->
		<file name="%@.luac"/>  <!-- use %@ to dont open all luac files-->
	</ignoredfile>
	<press>
	{
	['lua'] = function(b,config,var)
		if config['security']['allowloadstring'] and config['security']['allowloadstring'] == "0" then
			b[1]:send('MSG=Loadstring disabled (Error 16)\n')
			return
		end
		local ret,err = loadstring(tostring(var))
		if ret then
			local ret,err = pcall(ret,b,config,var)
			if not ret then
				err = err:gsub('\n','€')
				b[1]:send('MSG=LUA ERROR '..tostring(err)..'. (Error 9)\n')
			else
				b[1]:send('MSG=Executed is '..tostring(ret)..' and return is: '..tostring(err)..'\n')
			end
		else
			err = err:gsub('\n','€')
			b[1]:send('MSG=LUA ERROR '..tostring(err)..'. (Error 10)\n')
		end
	end,
	['save'] = function(b)
		doSaveServer()
		b[1]:send('MSG=Save done.\n')
	end,
	['broadcast'] = function(b,config,var)
		doBroadcastMessage(var)
		b[1]:send('MSG=Broadcast "'..tostring(var)..'" has been sent.\n')
	end,
	['stateserver'] = function(b,config,var)
		if doSetGameState((tonumber(var) or 3)) then
			b[1]:send('MSG=Game state now is '..(tonumber(var) or 3)..'.\n')
		else
			b[1]:send('MSG=Game state with id '..(tonumber(var) or 3)..' not found.\n')
		end
	end,
	['reload'] =  function(b,config,var)
		if doReloadInfo((tonumber(var) or 99)) then
			b[1]:send('MSG=Reloaded '..(tonumber(var) or 99)..'.\n')
		else
			b[1]:send('MSG=Reload type '..(tonumber(var) or 99)..' not found.\n')
		end
	end,
	['mode'] =  function(b,config,var)
		if setWorldType((tonumber(var) or 4)) then
			b[1]:send('MSG=Wrold type now is '..(tonumber(var) or 4)..'.\n')
		else
			b[1]:send('MSG=Bad wrold type '..(tonumber(var) or 4)..'.\n')
		end
	end,
	['kick'] = function(b,config,var)
		local cid = getPlayerByName(var)
		if cid and isPlayer(cid) then
			doRemoveCreature(cid)
			b[1]:send('MSG=A player with name '..var..' has been kicked.\n')
		else
			b[1]:send('MSG=A player with name '..var..' not found.\n')
		end
	end,
	}
	</press>
</remote>

Now add This tag on data/globalevents/globalevents.xml
Code:
<globalevent name="remote" interval="1" event="script" value="remote.lua"/>
Create remote.lua on data/globalevents/scripts and add it:
Lua:
--[[
Open Tibia Advanced Remote Control (OTARC) - Remote control server
Version beta
Security fails not found. if you found some bug PLEASE report it faster!
V 0.1.56
By Mock the bear (MTB)
]]
--Requesting libs
assert(pcall(require,'socket'),'Please install lua socket!')
require('ex')
---local Vars
local user = {}
local nid = 0
local error_
local ready
local tosend = {}
local buf = ''
--[[
Function list. Start on line 11 ends on line 211
]]
function readXML() --- By Mock
	-- This function read remote.xml config
	local config = {}
	-- open XML
	local XML = io.open('data/XML/remote.xml','r')
	assert(XML,'remote.xml not found.')
	-- get XML data
	local XML_data = XML:read('*a')
	XML:close()
	-- get config info
	local conf = XML_data:match('<conf(.-)/>')
	assert(conf,'BAD XML format (1)')
	for i,b in conf:gmatch('%s*(.-)%s*=%s*"(.-)"') do
		config[i] = b
	end
	local security = XML_data:match('<security(.-)/>')
	assert(security,'BAD XML format (4)')
	config['security'] = {}
	for i,b in security:gmatch('%s*(.-)%s*=%s*"(.-)"') do
		config['security'][i] = b
	end
	-- get ignored files
	local ignore = {}
	local get = XML_data:match('<ignoredfile>(.+)</ignoredfile>')
	assert(get,'BAD XML format (2)')
	for i in get:gmatch('%s*<file%s*name%s*=%s*"(.-)"%s*/>%s*') do
		table.insert(ignore,1,i)
	end
	-- get buttons config
	local buts = XML_data:match('<press>(.+)</press>')
	assert(buts,'BAD XML format (3)')
	local s = assert(loadstring('return '..buts))
	config.buttons = s()
	config.ignore = ignore
	return config
end
-- Function to get dir
function retDir2(n,m)
	local ta = {branchname=m or n}
	for i in os.dir(n) do
		if i.type ~= 'file' then
			i.name = i.name:gsub("'"," - ")
			table.insert(ta,1,retDir2(n..'/'..i.name,i.name))
		else
			i.name = i.name:gsub("'"," - ")
			table.insert(ta,1,n..'/'..i.name)
		end
	end
	return ta
end
function retDir(n)
	local t = {branchname=n}
	for i in os.dir() do
		if i.type ~= 'file' then
			i.name = i.name:gsub("'"," - ")
			table.insert(t,1,retDir2(i.name))
		else
			i.name = i.name:gsub("'","- ")
			table.insert(t,1,i.name)
		end
	end

	return t
end
--Change trable to string value
function tableToString(tb) -- by Mock
	if type(tb) ~= "table" then
		return nil, error("bad argument #1 to 'saveTable' (table expected, got "..type(tb)..")", 2)
	end
	local str = "{"
	for k,d in pairs(tb) do
		if type(k) == 'string' then
			if type(d) == 'string' then
				str = str..""..k.."='"..d.."',"
			elseif type(d) == 'number' or type(d) == 'boolean' then
				str = str..""..k.."="..tostring(d)..","
			elseif type(d) == 'table' then
				str = str..'{'
				for e,f in pairs(d) do
					if type(e) == 'string' then
						if type(f) == 'string' then
							str = str..""..e.."='"..f.."',"
						elseif type(f) == 'number' or type(e) == 'boolean' then
							str = str..""..e.."="..tostring(f)..","
						elseif type(f) == 'table' then
							str = str..""..e.."="..tableToString(f)..","
						end
					elseif type(e) == 'number' then
						if type(f) == 'string' then
							str = str.."["..e.."]='"..f.."',"
						elseif type(f) == 'number' or type(f) == 'boolean' then
							str = str.."["..e.."]="..tostring(f)..","
						elseif type(f) == 'table' then
							str = str.."["..e.."]="..tableToString(f)..","
						end
					end
				end
				str = str..'},'
			end
		elseif type(k) == 'number' then
			if type(d) == 'string' then
				str = str.."["..k.."]='"..d.."',"
			elseif type(d) == 'number' or type(d) == 'boolean' then
				str = str.."["..k.."]="..tostring(d)..","
			elseif type(d) == 'table' then
				str = str..'{'
				for e,f in pairs(d) do
					if type(e) == 'string' then
						if type(f) == 'string' then
							str = str..""..e.."='"..f.."',"
						elseif type(f) == 'number' or type(e) == 'boolean' then
							str = str..""..e.."="..tostring(f)..","
						elseif type(f) == 'table' then
							str = str..""..e.."="..tableToString(f)..","
						end
					elseif type(e) == 'number' then
						if type(f) == 'string' then
							str = str.."["..e.."]='"..f.."',"
						elseif type(f) == 'number' or type(f) == 'boolean' then
							str = str.."["..e.."]="..tostring(f)..","
						elseif type(f) == 'table' then
							str = str.."["..e.."]="..tableToString(f)..","
						end
					end
				end
				str = str..'},'
			end
		end
	end
	local str = str.."}"
	if string.sub(str,string.len(str)-2,string.len(str)-2) == "," then
		str = string.sub(str,0,string.len(str)-3).."}"
	end
	return str
end
--- Like table.maxn, but maxn does'nt work like this
function getMax(t)
	local n = 0
	for i,b in pairs(t) do
		n = n+1
	end
	return n
end
-- to use on debug mode
function print_(d,...)
	if d['debugmode'] and d['debugmode'] == "1" then
		print(...)
	end
end
-- break data in various pieces to send
function breakSend(b,s,va,u,size)
	local maxlen = size or 1024
	local more = {}
	tosend[u] = {}
	s = s:gsub('\n','€')
	if s:len() < maxlen  then
		b:send('BUFF='..s..'\n')
		b:send('DOBUF='..va..'\n')
		return
	end
	local aa = math.floor(s:len()/maxlen)+1
	for i=1, aa do
		if i == 1 then
			b:send('BUFF='..s:sub((i-1)*maxlen+1,((i)*maxlen))..'\n')
			b:send('SEND='..i..' TO='..(aa)..'.\n')
		else
			more[i] = {	'BUFF='..s:sub((i-1)*maxlen+1,((i)*maxlen))..'\n',i%2 == 1 and 'SEND='..i..' TO='..(aa)..'.\n' or ''}
		end
	end
	more[aa+1] = {('DOBUF='..va..'\n'),''}
	tosend[u] = more
end
-- Check if this file can send
function isFileOk(name,ignore)
	if name:find('/') then
		name = name:match('.+/+(.+)')
	end
	for i,b in pairs(ignore) do
		if b == name then
			return false
		end
		if (b:find('%%@%.(.+)')) then
			local infix = b:match('%%@%.(.+)')
			local _,infix2 = name:match('(.+)%.(.+)')
			if infix == infix2 then
				return false
			end
		end
	end
	return true
end
--[[
Here ends functions
and start script.
]]
-- Load XML config
local config = readXML()
if not config then
	error_ = true
end
--Here run the core
function run()
	ready:settimeout(0)
	local f = ready:accept()
	if f then
		if getMax(user) > tonumber(config['security']['maxconnections']) then
			b[1]:send('MSG=Max connections on limit. (Error 7)\n')
			f:close()
		else
			local ip = f:getpeername()
			if (config['security']['onlylocalhost'] and config['security']['onlylocalhost'] == '1') and (ip ~= '127.0.0.1') then
				f:send('MSG=Only localhost. (Error 14)\n')
				f:close()
			else
				nid = nid+1
				user[nid] = {f,access = {os.time()+5,pass=1,ip}}
				print_(config,'Join',i,ip)
			end
		end
	end
	for i,b in pairs(user) do
		if b.access[1] <= os.time() and b.access.pass == 0x0  then
			b[1]:send('MSG=Password timeout. (Error 1)\n')
			b[1]:close()
			tosend[i] = nil
			table.remove(user,i)
		end
		b[1]:settimeout(0)
		local ret,st = b[1]:receive()
		if not ret and st == 'closed' then
			user[i] = nil
			print_(config,st,i)
			tosend[i] = nil
		elseif ret then
			print_(config,i,ret)
			if ret:match('PASS:(.+)') then
				local pass = ret:match('PASS:(.+)')
				if tonumber(config['password']) == tonumber(pass) then
					b[1]:send('MSG=Password accepted.\n')
					b.access.pass = pass
					if config['security']['showfilesondir'] and config['security']['showfilesondir'] == "1" then
						b[1]:send('MSG=Loading data info please wait.\n')
						print_(config,'load')
						breakSend(b[1],tableToString(retDir('root')),1,i,tonumber(config['maxbuffersize'] or ''))
						b[1]:send('MSG=Done, please wait download finish.\n')
						print_(config,'send')
					else
						if config['security']['allowfilemannager'] and config['security']['allowfilemannager'] == "1" then
							b[1]:send('ACTIVE\n')
						else
							b[1]:send('DEACTIVE\n')
						end
					end
				else
					b[1]:send('MSG=Wrong password (Error 2)\n')
					b[1]:close()
					print_(config,'Close',i)
					tosend[i] = nil
					table.remove(user,i)
				end
			elseif ret:match('PRESS=(.-) VALUE=(.+)') then
				local but,var = ret:match('PRESS=(.-) VALUE=(.+)')
				if config.buttons[but:lower()] then
					var = var:gsub('€','\n')
					config.buttons[but:lower()](b,config,var)
				else
					b[1]:send('MSG=Press type not found (Error 15)\n')
				end
			else
				-- file mannager
				if tonumber(b.access.pass) == tonumber(config['password']) then
					if config['security']['allowfilemannager'] and config['security']['allowfilemannager'] == "1" then
						if ret:match('REQUEST=(.+)') then
							local file = ret:match('REQUEST=(.+)')
							if isFileOk(file,config.ignore) then
								local f = io.open(file,'r')
								if not f then
									b[1]:send('MSG=Cannot open file (Error 3)\n')
									b[1]:send('ACTIVE\n')
								else
									local data = f:read('*a')
									if data:len() == 0 then
										b[1]:send('MSG=File is empyt. (Error 5)\n')
										b[1]:send('ACTIVE\n')
									else
										b[1]:send('FNAME='..file..'\n')
										breakSend(b[1],data,2,i,tonumber(config['maxbuffersize'] or ''))
										f:close()
										data = nil
									end
								end
							else
								b[1]:send('MSG=Ascess dained (Error 11)\n')
								b[1]:send('ACTIVE\n')
							end
						elseif ret:match('DOBUF=(.+)') then
							local v = ret:match('DOBUF=(.+)')
							if not tonumber(v) then
								if isFileOk(v,config.ignore) then
									local ffl = io.open(v,'r')
									if ffl then
										ffl:close()
										local ffl = io.open(v,'w')
										buf = buf:gsub('€','\n')
										ffl:write(buf)
										ffl:close()
										buf = ''
										b[1]:send('MSG=Saved\n')
										b[1]:send('ACTIVE\n')
										print_(config,'saved')
									else
										b[1]:send('MSG=Ascess dained (Error 6)\n')
										b[1]:send('ACTIVE\n')
									end
								else
									b[1]:send('MSG=Ascess dained (Error 12)\n')
									b[1]:send('ACTIVE\n')
								end
							end
						elseif ret:match('SEND=(%d+) TO=(%d+)') then
							local nw,max = ret:match('SEND=(%d+) TO=(%d+)')
							b[1]:send('D:'..(nw+1)..'\n')
						elseif ret:match('BUFF=(.+)') then
							buf = buf..ret:match('BUFF=(.+)')
						elseif ret:match('M:(%d+)') then
							local naa = ret:match('M:(%d+)')
							if tosend[i][tonumber(naa)] then
								b[1]:send(tosend[i][tonumber(naa)][1])
								b[1]:send(tosend[i][tonumber(naa)][2])
							end
						end
					else
						b[1]:send('ERROR=File mannager is desactived. (Error 8)\n')
						b[1]:send('DEACTIVE\n')
					end
				else
					b[1]:send('MSG=Wrong password (Error 4)\n')
				end
			end
		end
	end
end
-- and finally here start the core and socket binding.
function onThink(interval, lastExecution)
	if not error_ then
		if not ready then
			ready = socket.bind(tostring(config['ip']) or '*',tonumber(config['port']) or 7178)
			print('Binding socket on '..(tostring(config['ip']) or '*')..':'..tostring(tonumber(config['port']) or 7178)..'.')
		end
		if ready then
			for i=1,10 do
				addEvent(run,i*100)
			end
		end
	end
	return true
end
-- =*
-- Cya

Now config remote.xml and open! :thumbup:


Remote:

Well look at this photo :D
remote.png

You can download the remote client for win32 attached on the thread.

Only change the dlls to .so and you can run it on linux.

Remote use:
Lua GD
IUP lua and iup lua controls(user portable interface)
Lua EX
Lua socket

If you want see here is the remote.lua
Lua:
--[[
Open Tibia Advanced Remote Control (OTARC) - Remote control client

By Mock the bear.
]]
require('ex')
require("iuplua")
require('socket')
require( "iupluacontrols" )
require('gd')
---Functions
function loadPhoto(name,t)
	local phto = {}
	local ce = {}
	local n = 0
	local gde
	if not t then
		gde= gd.createFromGif('images/'..name)
	else
		gde= gd.createFromPng('images/'..name)
	end
	assert(gde)
	for x=1,gde:sizeX()+1 do
		for y=1,gde:sizeY()+1 do
			if not phto[(y-1)] then phto[(y-1)] = {} end
			if not phto[(y-1)][(x-1)] then phto[(y-1)][(x-1)] = {} end
			local p = gde:getPixel(x-2, y-2)
			if  (gde:red(p) == 255 and gde:blue(p) ==255 and gde:green(p) == 255) then
				phto[(y-1)][(x-1)] = 0
			else
				local r, b, g = gde:red(p), gde:blue(p), gde:green(p)
				local clr  = r..' '..b..' '..g
				local go = true
				for i,b in pairs(ce) do
					if b == clr then
						go = false
						phto[(y-1)][(x-1)] = i
						break
					end
				end
				if go then
					n = n+1
					ce[n] = clr
					phto[(y-1)][(x-1)] = n
				end
			end
		end
	end
	cs = nil
	return iup.image{colors = ce,hotspot = "1:1",unpack(phto)}
end
function fixStr(s)
	local maxlen = 26
	local s2 = ''
	if math.floor(s:len()/maxlen) == 0 then
		s = s:gsub('€','\n')
		return s..'\n'
	end
	for i=1, math.floor(s:len()/maxlen)+1 do
		s2 = s2..s:sub((i-1)*maxlen+1,((i)*maxlen))..'\n'
	end
	s2 = s2:gsub('€','\n')
	return s2
end
function breakSend(b,s,va,size)
	local maxlen = size or 1024
	local more = {}
	s = s:gsub('\n','€')
	if s:len() < 1024  then
		b:send('BUFF='..s..'\n')
		b:send('DOBUF='..va..'\n')
		return
	end
	for i=1, math.floor(s:len()/maxlen)+1 do
		if i == 1 then
			b:send('BUFF='..s:sub((i-1)*maxlen+1,((i)*maxlen))..'\n')
			b:send('SEND='..i..' TO='..(math.floor(s:len()/maxlen)+1)..'.\n')
		else
		more[i] = {	'BUFF='..s:sub((i-1)*maxlen+1,((i)*maxlen))..'\n','SEND='..i..' TO='..(math.floor(s:len()/maxlen)+1)..'.\n',false,function()
			gaug.value = (i*100/(math.floor(s:len()/maxlen)+1))/100
			recs.title = "Uploading -  "..i.."/"..(math.floor(s:len()/maxlen)+1).."" end}
		end
	end
	more[#more+1] = {('DOBUF='..va..'\n'),'',true}
	tosend[1] = more
end
---
local wait_colorchange = 0
local stept = 0
local skt = {
buff = '',
}
tosend = {}
conect = nil

fr1 = iup.frame
{
	iup.hbox
	{
		title="Painel",
		iup.button{title="Connect",ACTIVE='YES',action = function()
			if pass.value ~= '0x' then
				tree.MARK = '1'
				skt.buff = ''
				tree.DELNODE = "CHILDREN"
				tree.redraw = "YES"
				wai.image= IMG_wait
				wait_colorchange = stept+5
				log_.insert = ('Conecting on:\n'..tostring(ip[1].value)..':'..tostring(port[1].value)..'.\n')
				conect = socket.connect(tostring(ip[1].value),tonumber(port[1].value) or 7178)
				if conect then
					log_.insert = ('Conected.\n\n')
					conc.image = loadPhoto('conected.png',1)
					desc.image = loadPhoto('desconectedno.png',1)
					conect:send('PASS:'..pass.value..'\n')
				else
					log_.insert = ('Cannot Conect\n')
					desc.image =  loadPhoto('desconected.png',1)
					conc.image = loadPhoto('conectedno.png',1)
				end
			else
				iup.Message("Info", "Please type the password!")
			end
		end},
		iup.button{title="Desconect",ACTIVE='NO',action = function()
			if conect then
				conect:close()
				conect = nil
				log_.insert = 'Connection closed.\n'
				wai.image= IMG_wait
				wait_colorchange = stept+5
				desc.image = loadPhoto('desconected.png',1)
				conc.image = loadPhoto('conectedno.png',1)
			end
		end},
		iup.fill{},
		};
}
IMG_waitno = loadPhoto('waitno.png',1)
IMG_wait = loadPhoto('wait.png',1)
desc = iup.label{title = "Status",image =loadPhoto('desconected.png',1)}
wai = iup.label{title = "Status",image =IMG_waitno}
conc = iup.label{title = "Status",image =loadPhoto('conectedno.png',1)}
ip = iup.frame{
	title = 'IP',
	iup.text{value = "localhost", expand = "NO",size='160x'},
	}
port = iup.frame{
	title = 'PORT',
	iup.text{value = "7178", expand = "NO",size='160x'},
	}
btsize = '19x16'
fr2 = iup.frame
{
	iup.hbox
	{
		iup.button{title="0",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="1",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="2",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="3",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="4",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="5",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="6",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="7",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		size='160x'
	};
}
fr3 = iup.frame
{
	iup.hbox
	{
		iup.button{title="8",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="9",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="a",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="b",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="c",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="d",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="e",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		iup.button{title="f",size=btsize,  action=function(self) pass.value = pass.value..tostring(self.title) end},
		size='160x'
	};

}
log_ = iup.multiline{insert="", size='160x220',ACTIVE='NO',bgcolor='233 233 233',fgcolor='198 156 37'}
ZKRIPT = iup.multiline{insert="",size='400x320',expand = "YES", ACTIVE='YES',MULTILINE='YES',fgcolor='0 0 0'}
pass = iup.text {value = "0x", expand = "NO",ACTIVE='NO',size='160x'}
dir = iup.text {value = "", expand = "NO",ACTIVE='YES',size='180x'}
lbl  = iup.label {title = "0",size='130x',alignment = "ACENTER"}
recs  = iup.label {title = "Donwloading -  ?/?",size='100x',alignment = "ACENTER"}
fname  = iup.label {title = 'File name: -',size='130x',alignment = "ACENTER"}
timer_pass = iup.timer{time=100,run = "YES"}
con = iup.timer{time=10,run = "YES"}
clear = iup.button{title="Clear",  action=function() pass.value = '0x' end,size='160x'}
tree = iup.tree{}
gaug = iup.gauge{size='100x'}
iup.TreeSetValue(tree,{branchname='root'})
arira = iup.label{title = "",image =loadPhoto('im1.png',1)}
function tree:renamenode_cb(id)
	if tree.name:find('(.+)%.(.-)') then
		dir.value = tree.name
	end
	return iup.DEFAULT
end
function tree:rightclick_cb(id)
	tree.value = id
	tree:renamenode_cb(tree.value)
  return iup.DEFAULT
end
DATA = iup.vbox{
					iup.hbox{
						iup.button{title="Save", ACTIVE='NO', action=function() log_.insert = fixStr('Saving...') conect:send('PRESS=SAVE VALUE=1\n') end,size='160x'},
						iup.button{title="Broadcast", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("Send Broadcast",'',"Message: %s\n",'')
						if ret == 1 then
							log_.insert = fixStr('Sending: '..tostring(var)..'...')
							conect:send('PRESS=BROADCAST VALUE='..tostring(var)..'\n')
						end
						end,size='160x'},
						iup.button{title="Reload", ACTIVE='NO', action=function() -- *8486
						local ret, var = iup.GetParam("Reload info",'','List: %l|RELOAD_ACTIONS|RELOAD_CHAT|RELOAD_CONFIG|RELOAD_CREATUREEVENTS|'..
						'RELOAD_GAMESERVERS|RELOAD_GLOBALEVENTS|RELOAD_GROUPS|RELOAD_HIGHSCORES|RELOAD_HOUSEPRICES|'..
						'RELOAD_ITEMS|RELOAD_MONSTERS|RELOAD_MOVEEVENTS|RELOAD_NPCS|RELOAD_OUTFITS|RELOAD_QUESTS|RELOAD_RAIDS|'..
						'RELOAD_SPELLS|RELOAD_STAGES|RELOAD_TALKACTIONS|RELOAD_VOCATIONS|RELOAD_WEAPONS|RELOAD_MODS|RELOAD_ALL|\n',0)
						if ret == 1 then
							log_.insert = fixStr('Reloading: '..tostring(var+1)..'...')
							conect:send('PRESS=RELOAD VALUE='..tostring(var+1)..'\n')
						end
						end,size='160x'},
						iup.button{title="Kick", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("Send Broadcast",'',"Message: %s\n",'')
						if ret == 1 then
							log_.insert = fixStr('Sending: '..tostring(var)..'...')
							conect:send('PRESS=KICK VALUE='..tostring(var)..'\n')
						end
						end,size='100x'},

						iup.fill{},
					},
					iup.hbox{iup.button{title="Execute a piece of script", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("Execute a piece of script",'',"Script: %m\n",'')
						if ret == 1 then
							local ret,err = loadstring(tostring(var))
							if not ret then
								log_.insert = fixStr('Error on sending lua code: '..err..'')
								iup.Message("ERROR", err)
							else
								log_.insert = fixStr('Executing lua code...')
								var = var:gsub('\n','€')
								conect:send('PRESS=LUA VALUE='..var..'\n')
							end
						end
						end,size='160x'},
						iup.button{title="Set state server", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("Server state",'','List: %l|GAMESTATE_STARTUP|GAMESTATE_INIT|'..
						'GAMESTATE_NORMAL|GAMESTATE_MAINTAIN|GAMESTATE_CLOSED|GAMESTATE_CLOSING|GAMESTATE_SHUTDOWN|\n',0)
						if ret == 1 then
							log_.insert = fixStr('Seting state server to : '..tostring(var+1)..'...')
							conect:send('PRESS=STATESERVER VALUE='..tostring(var+1)..'\n')
						end
						end,size='160x'},
						iup.button{title="Set world type", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("world type",'','List: %l|WORLDTYPE_NO_PVP|WORLDTYPE_PVP|WORLDTYPE_PVP_ENFORCED|\n',0)
						if ret == 1 then
							log_.insert = fixStr('Seting world type to: '..tostring(var+1)..'...')
							conect:send('PRESS=MODE VALUE='..tostring(var+1)..'\n')
						end
						end,size='160x'},
						iup.button{title="Ban", ACTIVE='NO', action=function()
						local ret, var = iup.GetParam("Send Broadcast",'',"Message: %s\n",'')
						if ret == 1 then
							log_.insert = fixStr('Sending: '..tostring(var)..'...')
							conect:send('PRESS=BAN VALUE='..tostring(var)..'\n')
						end
						end,size='100x'}
						,
						},
					iup.hbox{
						ZKRIPT,
						iup.vbox{
								fname,
								dir,
								iup.button{title="Request",size='180x', ACTIVE='NO',action = function()
									if conect then
										log_.insert = fixStr('Requesting '..dir.value..'.')
										conect:send('REQUEST='..dir.value..'\n')
										DATA[3][2][3].ACTIVE='NO'
										DATA[3][2][4].ACTIVE='NO'
									end
								end},
								iup.button{title="Save file",size='180x', ACTIVE='NO',action = function()
									if conect then
										breakSend(conect,ZKRIPT.value:gsub('\n','€'),dir.value,size)
										DATA[3][2][3].ACTIVE='NO'
										DATA[3][2][4].ACTIVE='NO'
									end
								end},
							tree,
							iup.hbox{
								iup.button{title="Information",image=loadPhoto('credit.png',1),action=function() show_info() end},
								iup.fill{},
									iup.frame{
										title='Status',
										iup.hbox{
											desc,
											wai ,
											conc,
										},
									},
									iup.fill{},
								},
						},
					},
					iup.fill{},
				}
function timer_pass:action_cb()
	if not first then
		log_.insert= 'Welcome to the Bear\nopen tibia remote control\n------------------------------------------\n'
		first = true
	end
	if pass.value ~= '0x' then
		if  tostring(tonumber(pass.value)) ~= lbl.title  then
			lbl.title = tostring(tonumber(pass.value))
		end
	else
		if  tostring(tonumber(pass.value)) ~= lbl.title  then
			lbl.title = 0
		end
	end
	if pass.value:len() > 10 then
		pass.value = pass.value:sub(1,10)
		iup.Message("Info", "Only 8 characters or less!")
	end
	if conect then
		fr1[1][1].ACTIVE = 'NO'
		fr1[1][2].ACTIVE = 'YES'

		for i=1,8 do
			fr2[1][i].ACTIVE= 'NO'
			fr3[1][i].ACTIVE= 'NO'
		end
		ip[1].ACTIVE= 'NO'
		port[1].ACTIVE= 'NO'
		clear.ACTIVE= 'NO'

		for de=1,2 do
			for i=1,4 do
				if DATA[de][i] then
					DATA[de][i].ACTIVE='YES'
				end
			end
		end
	elseif fr1[1][1].ACTIVE == 'NO' and not conect then
		fr1[1][1].ACTIVE = 'YES'
		fr1[1][2].ACTIVE = 'NO'

		for i=1,8 do
			fr2[1][i].ACTIVE= 'YES'
			fr3[1][i].ACTIVE= 'YES'
		end
		ip[1].ACTIVE= 'YES'
		port[1].ACTIVE= 'YES'
		clear.ACTIVE= 'YES'

		DATA[3][2][3].ACTIVE='NO'
		DATA[3][2][4].ACTIVE='NO'
		for de=1,2 do
			for i=1,4 do
				if DATA[de][i] then
					DATA[de][i].ACTIVE='NO'
				end
			end
		end
		tree.DELNODE = "CHILDREN"
		tree.redraw = "YES"
		iup.TreeSetValue(tree,{branchname='root'})
		tree.redraw = "YES"
		ZKRIPT.value = ''
		fname.title = 'File name: -'
		iup.Message("Info", "Connection closed.")
	end
end
function con:action_cb()
	stept = stept+1
	if stept == wait_colorchange then
		wai.image= IMG_waitno
	end
	--[[
	socket
	]]
	if conect then
		conect:settimeout(0)
		local ret,v = conect:receive()
		if ret then

			if ret:match('MSG=(.+)') and not ret:match('.+MSG=(.+)') then
				log_.insert = fixStr(ret:match('MSG=(.+)'))
			elseif ret:match('SEND=(%d+) TO=(%d+)') then
				wai.image= wai.image == IMG_waitno and IMG_wait or IMG_waitno
				local nw,max = ret:match('SEND=(%d+) TO=(%d+)')
				gaug.value = (nw*100/max)/100
				recs.title = "Donwloading -  "..nw.."/"..max..""
				conect:send('M:'..(nw+1)..'\n')
				conect:send('M:'..(nw+2)..'\n')

			elseif ret:match('D:(%d+)') then
				local naa = ret:match('D:(%d+)')
				if tosend[1][tonumber(naa)] then
					wai.image= wai.image == IMG_waitno and IMG_wait or IMG_waitno
					conect:send(tosend[1][tonumber(naa)][1])
					conect:send(tosend[1][tonumber(naa)][2])
					if tosend[1][tonumber(naa)][3] then
						tosend[1] = {}
						DATA[3][2][4].ACTIVE='YES'
					end
					if tosend[1] and tosend[1][tonumber(naa)] and tosend[1][tonumber(naa)][4] then
						tosend[1][tonumber(naa)][4]()
					else
						gaug.value = 0
						recs.title = "Donwloading -  ?/?"
						wai.image = IMG_waitno
						wait_colorchange = stept+5
					end
				end
			elseif ret =='ACTIVE' then
				DATA[3][2][3].ACTIVE='YES'
				DATA[3][2][4].ACTIVE='YES'
				ZKRIPT.ACTIVE = 'YES'
				DATA[3][2][4].ACTIVE='YES'
			elseif ret == 'DEACTIVE' then
				DATA[3][2][3].ACTIVE='NO'
				DATA[3][2][4].ACTIVE='NO'
				ZKRIPT.ACTIVE = 'NO'
				DATA[3][2][4].ACTIVE='NO'
			elseif ret:match('BUFF=(.+)') then
				skt.buff = skt.buff..ret:match('BUFF=(.+)')
				wai.image= wai.image == IMG_waitno and IMG_wait or IMG_waitno
				DATA[3][2][3].ACTIVE='NO'
			elseif ret:match('FNAME=(.+)') then
				fname.title = 'File name: '..tostring(ret:match('FNAME=(.+)'))
			elseif ret:match('DOBUF=(%d+)') then
				if skt.buff ~= '' then
					gaug.value = 0
					wai.image= IMG_wait
					wait_colorchange = stept+5
					recs.title = "Donwloading -  ?/?"
					local runing = ret:match('DOBUF=(%d+)')
					skt.buff = skt.buff:gsub('€','\n')
					if runing == '1' then
						DATA[3][2][3].ACTIVE='YES'
						local table_,err = loadstring('return '..skt.buff)
						if not table_ and err then
							log_.insert = fixStr('Error on setting dir table! '..err..' >: '..runing)
							local f = io.open('error.lua','w')
							f:write(skt.buff)
							f:close()
						else
							tree.DELNODE = "CHILDREN"
							tree.redraw = "YES"
							os.sleep(0.01)
							iup.TreeSetValue(tree,table_())
							tree.redraw = "YES"
						end
					elseif runing == '2' then
						DATA[3][2][3].ACTIVE='YES'
						DATA[3][2][4].ACTIVE='YES'
						ZKRIPT.ACTIVE = 'YES'
						ZKRIPT.value = skt.buff
						DATA[3][2][4].ACTIVE='YES'
						log_.insert = fixStr('Loaded file.')
					end
					skt.buff = ''
				end
			end
		elseif not ret and v == 'closed' then
			conect:close()
			conect = nil
		end
	end
	return iup.DEFAULT
end
function show_info()
	local lbl = iup.label { title = "Open Tibia Advanced Remote Control",
                  bgcolor = "219 195 195",
                  fgcolor = "0 0 0",
                  font = "COURIER_BOLD_14",
                  alignment = "ACENTER" }
	local lbla = iup.label { title ="By mock                           \nVersion 1.0.85                    \n",
                  bgcolor = "255 171 94",
                  fgcolor = "255 255 255",
                  font = "COURIER_NORMAL_14",
                  alignment = "ACENTER" }
	local lblR = iup.label { title = "Contact: [email][email protected][/email]   ",
                  bgcolor = "219 195 195",
                  fgcolor = "255 255 255",
                  font = "COURIER_BOLD_14",
                  alignment = "ACENTER" }
	local dlg = iup.dialog { iup.vbox { lbl,lbla,lblR},}
	dlg:showxy ( iup.CENTER, iup.CENTER )

	if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
		iup.MainLoop()
	end
end

dlg = iup.dialog
{
	icon=loadPhoto('ico.png',1),
	iup.frame
	{
	title="Advanced remote control",
		iup.hbox{
			iup.frame{
				title="General",
				iup.vbox
				{
					fr1,
					ip,
					port,
					iup.frame{
						title="Password",
						iup.vbox{
						fr2,
						fr3,
						pass,
						iup.hbox{iup.label{title = "Pass:"},lbl},
						clear,
						},
					};
					iup.frame{
						size='160x',
						title="Status",
						iup.vbox{
						log_,
						iup.hbox{
							size='160x',
							iup.vbox{arira,
							iup.label{title = "   By Mock"},
							},
							iup.vbox{
							gaug,
							recs,
							}
						},
						iup.fill{},
						},
						}
				},
			},
			iup.frame{
				title="Console",
				DATA,
			},
		}
	};
	size='500x400',
  title="The bear remote",

}

dlg:show()

if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
  iup.MainLoop()
end
-- :P enjoy

The bear remote on sourceforge:
https://sourceforge.net/projects/thebearremote/files
 

Attachments

Last edited:
great! but bad news is that it supports windows only :<
 
@Kula_
no
if you change the DLLs to .SO files it work in lunux :D
(for host and remote)
 
@Kuyt
lol... i say how to install on theread ¬¬'
 
nice we got the bearRemote ^^
 
I think he mean his latest release not his like "i will not release anything from now on" ;p

@Mock
This is awesome..
 
i cant find the things need download what about u put them in download?
 
Back
Top