Saiyans King
Forum friend
- Joined
- Feb 6, 2009
- Messages
- 97
- Reaction score
- 18
Opis: Jest to okienko dialogowe pozwalaj?ce pisa?/testowa? skrypty i funkcje in-game.
Skrypt:
data/chatchannels/chatchannels.xml:
[XML]<channel id="65533" name="Lua Output" script="console.lua" />[/XML]
data/chatchannels/scripts/console.lua:
[LUA]function canJoin(player)
return player:getAccountType() >= ACCOUNT_TYPE_GOD
end
function onSpeak(player, type, message)
return false
end[/LUA]
data/talkactions/talkactions.xml:
[XML]<talkaction words="/console" script="console.lua" />[/XML]
data/talkactions/scripts/console.lua:
[LUA]local channel = 65533
function onSay(player, words, param)
if(player:getAccountType() < ACCOUNT_TYPE_GOD) then
return true
end
playerpenChannel(channel)
player:showTextDialog(1978, "", true, 8192)
return false
end[/LUA]
data/creaturescripts/creaturescripts.xml:
[XML]<event type="textedit" name="Console" script="console.lua" />[/XML]
data/creaturescripts/scripts/console.lua:
[LUA]local channel = 65533
local function luainp(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_Y, channel)
end
local function luaout(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_O, channel)
end
local function errout(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_R1, channel)
end
local environment = {}
local sandboxed = setmetatable({}, {__index = function(t, index) return rawget(t, index) or environment[index] or _G[index] end})
sandboxed._G = sandboxed
sandboxed.os = {time = os.time, date = os.date, clock = os.clock}
sandboxed.io = {}
sandboxed.debug = {}
sandboxed.package = {}
sandboxed.pcall = {}
sandboxed.xpcall = {}
sandboxed.load = {}
sandboxed.loadstring = {}
sandboxed.loadfile = {}
sandboxed.dofile = {}
sandboxed.error = function(msg)
errout(environment.player, msg)
end
sandboxed.print = function(...)
local r = {...}
local retTable = {}
local tSize = #r
for i = 1, tSize do
table.insert(retTable, tostring(r))
end
local ret = table.concat(retTable, string.rep(' ', 4))
return luaout(environment.player, #ret > 0 and ret or 'nil')
end
function onTextEdit(player, item, text)
if(player:getAccountType() < ACCOUNT_TYPE_GOD or item:getId() ~= 1978) then
return true
end
environment = {cid = player:getId(), player = player}
local luainput = text
local inputlines = luainput:split("\n")
local func, error = loadstring(luainput, 'Lua Input')
if(func) then
setfenv(func, sandboxed)
luainp(player, "Lua Input Start;")
local iSize = #inputlines
for i = 1, iSize do
luainp(player, '> '..inputlines)
end
luainp(player, "Lua Input End;")
local status, error = pcall(func)
if not(status) then
errout(player, error)
end
else
errout(player, error)
end
return true
end[/LUA]
data/creaturescripts/scripts/login.lua:
po:
[LUA]player:registerEvent("DropLoot")[/LUA]
dodaj:
[LUA]player:registerEvent("Console")[/LUA]
SS:
Skrypt:
data/chatchannels/chatchannels.xml:
[XML]<channel id="65533" name="Lua Output" script="console.lua" />[/XML]
data/chatchannels/scripts/console.lua:
[LUA]function canJoin(player)
return player:getAccountType() >= ACCOUNT_TYPE_GOD
end
function onSpeak(player, type, message)
return false
end[/LUA]
data/talkactions/talkactions.xml:
[XML]<talkaction words="/console" script="console.lua" />[/XML]
data/talkactions/scripts/console.lua:
[LUA]local channel = 65533
function onSay(player, words, param)
if(player:getAccountType() < ACCOUNT_TYPE_GOD) then
return true
end
playerpenChannel(channel)
player:showTextDialog(1978, "", true, 8192)
return false
end[/LUA]
data/creaturescripts/creaturescripts.xml:
[XML]<event type="textedit" name="Console" script="console.lua" />[/XML]
data/creaturescripts/scripts/console.lua:
[LUA]local channel = 65533
local function luainp(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_Y, channel)
end
local function luaout(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_O, channel)
end
local function errout(player, msg)
player:sendChannelMessage(nil, msg, TALKTYPE_CHANNEL_R1, channel)
end
local environment = {}
local sandboxed = setmetatable({}, {__index = function(t, index) return rawget(t, index) or environment[index] or _G[index] end})
sandboxed._G = sandboxed
sandboxed.os = {time = os.time, date = os.date, clock = os.clock}
sandboxed.io = {}
sandboxed.debug = {}
sandboxed.package = {}
sandboxed.pcall = {}
sandboxed.xpcall = {}
sandboxed.load = {}
sandboxed.loadstring = {}
sandboxed.loadfile = {}
sandboxed.dofile = {}
sandboxed.error = function(msg)
errout(environment.player, msg)
end
sandboxed.print = function(...)
local r = {...}
local retTable = {}
local tSize = #r
for i = 1, tSize do
table.insert(retTable, tostring(r))
end
local ret = table.concat(retTable, string.rep(' ', 4))
return luaout(environment.player, #ret > 0 and ret or 'nil')
end
function onTextEdit(player, item, text)
if(player:getAccountType() < ACCOUNT_TYPE_GOD or item:getId() ~= 1978) then
return true
end
environment = {cid = player:getId(), player = player}
local luainput = text
local inputlines = luainput:split("\n")
local func, error = loadstring(luainput, 'Lua Input')
if(func) then
setfenv(func, sandboxed)
luainp(player, "Lua Input Start;")
local iSize = #inputlines
for i = 1, iSize do
luainp(player, '> '..inputlines)
end
luainp(player, "Lua Input End;")
local status, error = pcall(func)
if not(status) then
errout(player, error)
end
else
errout(player, error)
end
return true
end[/LUA]
data/creaturescripts/scripts/login.lua:
po:
[LUA]player:registerEvent("DropLoot")[/LUA]
dodaj:
[LUA]player:registerEvent("Console")[/LUA]
SS: