• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TalkAction Command /lua <script>

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
104
Location
Brazil
I have to thanks first our friend Capaverde (user form another forum) he have done thue fist version of this script (first but too much bugged)

But now is another version better ;D

What this command does?
You say can execute some piece of script like this:

/lua doCreatureSay(getPlayerByName('Player'),'omg!',1)
/lua doRemoveCreature(getPlayerByName('Player'))
/lua print('Hello word!')
/lua saveServer() os.exit()
/lua ...
And more. :D
Well, to install is easy, add this tag on talkactions.xml:
Code:
<talkaction log="yes" access="5" words="/lua" event="script" value="lua.lua"/>
And on lua.lua
add this:
Lua:
function onSay(cid, words, param) --- command /lua By mock
    _G.cid = cid
	local f , err = loadstring(param)
	if f then
		local ret,err = pcall(f)
		if not ret then
			doPlayerSendTextMessage(cid, 25,'Lua error:\n'..err)
		end
	else
		doPlayerSendTextMessage(cid, 25,'Lua error:\n'..err)
	end
	return TRUE
end
:thumbup:
 
OP
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
104
Location
Brazil
@PAXTON
thx ^^
@topic
Verry VERRY usefull function. i think it is the most.
 

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Solutions
1
Reaction score
68
Location
Chile
Nice ;) Simple use of pcall, no one though about this before? ;) Rep+

pff none? it was done by a user of otfans inlike 2006 cant remember name ill search.

/lua broadcast -> get config info -> sqluser .. " " .. sql pass

lols

edit: found name Ispiro i think
 
Last edited:
OP
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
104
Location
Brazil
@Nahruto
it was done by capaverde at january of 2006 ^^
but not pcall only loadstring
 

slaw

MyAAC Creator
Premium User
Joined
Aug 27, 2007
Messages
3,509
Solutions
113
Reaction score
943
Location
Germany
GitHub
slawkens
Nice, although we made something similar time ago.

http://tfs-mods.googlecode.com/svn/trunk/command-lua.xml

It also returns result, so you can use for example:

Code:
06:39 God: /return getItemInfo(2160)
06:39 Result: (table)
     ["attackSpeed"] = 0     ["showAttributes"] = false     ["extraDefense"] = 0     ["wieldInfo"] = 0     ["writeOnceItemId"] = 0     ["movable"] = true     ["hangable"] = false     ["runeMagicLevel"] = 0    
["allowPickupable"] = false     ["defense"] = 0     ["corpseType"] = 0     ["decayTime"] = 0     ["blockPickupable"] = false     ["usable"] = false     ["fluidSource"] = 0     ["combatType"] = 0     ["rotateTo"] = 0  
  ["transformEquipTo"] = 0     ["extraAttack"] = 0     ["decayTo"]
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,892
Solutions
5
Reaction score
851
Thanks for releasing, some time ago I made something like this for myself (for testing).
 

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,426
Solutions
19
Reaction score
195
Location
Sweden
i have made this already :p i can't find where i posted it tho :/

ohoh there found it xD
Best script idea ever


@slawkens
I'd rather just have a function ready for printing tables... e.g. "table.toString(getItemInfo(2160))"
Then you'd just use /eval table.toString(getItemInfo(2160))


And I wonder how it could have been made in 2006 when there were no Talkactions by then?
 
Last edited:
OP
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
104
Location
Brazil
@slawkens
good ^^
@colandus:
or something like this:
Lua:
function var_dump(...)
	table.getn = function (table)
		local n = 0
		for _ in pairs(table) do
			n = n + 1
		end
		return n
	end
	local dumped = #arg == 0 and 'nil' or ''
	for _, var in ipairs(arg) do
		local ret_str,x,ret = function (var)
			local VAR_TYPE,str = type(var)
			if (VAR_TYPE == "string") then
				str = VAR_TYPE.."("..var:len()..") \""..var.."\""
			elseif (VAR_TYPE == "number") then
				var = tostring(var)
				if var:find("%D+") then
					VAR_TYPE = "bool"
				else
					VAR_TYPE = "int"
				end
				str = VAR_TYPE.."("..var..")"
			elseif (VAR_TYPE == "boolean") then
				str = "bool("..tostring(var)..")"
			else
				str = tostring(var)
			end
			return str
		end
		if (type(var) == "table") then
			local function ret_array(var,tab)
				ret = ""
				for i, v in pairs(var) do
					if (type(v) == "table") then x = tab + 1 end
					ret = ret.."\n\t"..string.rep("\t",tab).."["..(type(i) == "number" and i or '"'..i..'"').."] => "..(type(v) ~= "table" and ret_str(v) or ((v == _G or v == _G.package.loaded) and tostring(v).." (global environment)" or ret_array(v,x)))
				end
				return "array("..table.getn(var)..") {"..ret.."\n"..string.rep("\t",tab).."}"
			end
			ret = ret_array(var,0)
		end
		dumped = dumped..(ret or ret_str(var))..(#arg<=_ and '' or ' ')
	end
	return dumped
end
 

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
342
mock,i explained that part
(EM PORTUGUES OK?) :p

Lua:
    _G.cid = cid
        local f , err = loadstring(param)
        if f then
                local ret,err = pcall(f)
                if not ret then
 
OP
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
104
Location
Brazil
@Beon
Lua:
_G.cid = cid -- Define cid como variavel global
local f , err = loadstring(param) -- Transforma o string em function
if f then -- verifica se f nao é nulo
local ret,err = pcall(f) -- executa f
 
Top