• Print

Author Topic: ULX ExLua - Run lua code on your server.  (Read 16872 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
ULX ExLua - Run lua code on your server.
« on: January 15, 2014, 06:39:28 pm »
Have you ever played on servers like GCinema and saw them execute lua code with their fancy name syntax?
Well now you can do that too with full error reporting, and even working ULX keywords such as ^ to target your self.

Code: Lua
  1. /*-------------------------------------------------------------------------------------------------------------------------
  2. |       ULX ExLua for ULX SVN/ULib SVN by LuaTenshi
  3. |       Steam: [url]http://steamcommunity.com/profiles/76561198096713277[/url]
  4. |       Email: luatenshi@gmail.com
  5. -------------------------------------------------------------------------------------------------------------------------*/
  6.  
  7. function ulx.exlua( calling_ply, str )
  8.         local tab, out, s, p, err = {}, "", ""
  9.         local ply = calling_ply
  10.        
  11.         if string.Trim(str) == "" or string.Trim(str) == "Lua Code" then ULib.tsayError( ply, "ExLua:1: Please enter some code to run." ) return end
  12.         if string.len(str) <= 3 then ULib.tsayError( ply, "ExLua:1: The string you entered is too short." ) return end
  13.        
  14.         for v in string.gmatch(str, "%S+:") do v = string.Replace(v,":","") table.insert(tab, v) end
  15.        
  16.         for k,v in pairs(tab) do
  17.                 s = tostring(tab[k])
  18.                 p,err = ULib.getUser(s,true,ply)
  19.                 if p and not err then
  20.                         out = string.Replace(str, s, "Entity(" .. tostring(p:EntIndex()) .. ")")
  21.                 elseif p and err then
  22.                         ULib.tsayError( ply, err )
  23.                 end
  24.         end
  25.        
  26.         local func = CompileString( out, "ExLua", false )
  27.        
  28.         if type(func) == "function" and func and not err then
  29.                 if Entity(p:EntIndex()) and IsValid(Entity(p:EntIndex())) then
  30.                         local succ, err = pcall(func)
  31.                         if err then ULib.tsayError( ply, err ) return end
  32.                         if succ then
  33.                                 ulx.fancyLogAdmin( calling_ply, true, "#A ran some code." )
  34.                         else
  35.                                 ulx.fancyLogAdmin( calling_ply, true, "#A attempted to run code." )
  36.                                 ULib.tsayError( ply, "ExLua:1: pcall returned false." )
  37.                         end
  38.                 else
  39.                         ULib.tsayError( ply, "ExLua:1: The target entity has vanished." )
  40.                 end
  41.         elseif func then
  42.                 ULib.tsayError( ply, tostring(func) )
  43.         else
  44.                 ULib.tsayError( ply, "ExLua:1: No callback found. This should not happen." )
  45.         end
  46. end
  47. local exlua = ulx.command( "Extra Utility", "ulx exlua", ulx.exlua, "!l" )
  48. exlua:addParam{ type=ULib.cmds.StringArg, hint="Lua Code", ULib.cmds.takeRestOfLine }
  49. exlua:defaultAccess( ULib.ACCESS_SUPERADMIN )
  50. exlua:help( [[Run a lua script on the server.
  51.  
  52. Excepts player arguments such as a players name or the ULX keywords.
  53.  
  54. Accepted Keywords: ^, @, $10 ]] )
  55.  

MD5 Hash: e2bee6ac0251f1315f7cc36234746ded
Steam: http://steamcommunity.com/profiles/76561198096713277
Email: luatenshi@gmail.com

If you find a glitch, or an exploit please email me or PM me. For other inquiries and or comments please post below. Also if you like my script feel free to let me know.
The forums add [url] tags to the link in the comment of my code, those make the MD5 no longer match, so before verifying make sure to remove those tags.
« Last Edit: January 15, 2014, 06:42:48 pm by LuaTenshi »
I cry every time I see that I am not a respected member of this community.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: ULX ExLua - Run lua code on your server.
« Reply #1 on: January 15, 2014, 06:48:01 pm »
Wouldn't this be better in RCON rather than Extra Utility?
Out of the Garry's Mod business.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX ExLua - Run lua code on your server.
« Reply #2 on: January 15, 2014, 07:55:33 pm »
Wouldn't this be better in RCON rather than Extra Utility?

Probably would, I just like to keep the stuff I make under one category, feel free to change it.
I cry every time I see that I am not a respected member of this community.

  • Print