ArcEmu: Server Lua from your Chatbox - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Server Lua from your Chatbox

#1 User is offline   hypersniper 

  • Advanced Member
  • Group: Retired
  • Posts: 227
  • Joined: 21-November 08
  • Gender:Male

Posted 18 October 2009 - 04:17 PM

Info
Requires LuaHypArc... duh :)

Welcome to my latest release, what I like to call Execute Chat Lua. This allows you, as an admin, to run server-side Lua from the chatbox. You can technically script bosses in-game with this system. The only limitation lies within the chatbox itself, you can only have a maximum of 255 characters. With that aside, let's get to the script. I recommend r19+ of HypArc, but I'm not going to force it.

Code
--------------------
--Execute Chat Lua--
-----hypersniper----
--------------------

--PREFIX: This is to tell the server that this chat message 
--should be executed as Lua. You must put this at the start
--of a chat message for it to be executed as Lua.
--DEFAULT: "@@ "

local PREFIX = "@@ "

--ECL_LOGGING: Set this to true if you would like console
--messages every time someone executes chat Lua.
--DEFAULT: true

ECL_LOGGING = true

function ExecuteChatLua(event, plr, message, type, language)
   PLR = plr
   local startpos, endpos = string.find(message, PREFIX)
   if (startpos == 1 and plr:CanUseCommand("AZ")) then
      local execute_string = message:gsub(PREFIX, "")
      local t = os.date("*t", os.time())
      if (t.hour < 10) then
         t.hour = "0"..t.hour
      end
      if (t.min < 10) then
         t.min = "0"..t.min
      end
      plr:SendBroadcastMessage("|cFFFF0000Executing:|r "..execute_string)
      if (ECL_LOGGING) then
         logcol(10)
         print(t.hour..":"..t.min.." "..plr:GetName().." executed Lua: "..execute_string)
         logcol(7)
      end
      loadstring(execute_string)()
      return 0
   end
end

if (GetLuaEngine() == "LuaHypArc") then
   RegisterServerHook(16, "ExecuteChatLua")
else
   print("LuaEngine: Did not load 'Execute Chat Lua' script - LuaHypArc not installed.")
   print("LuaEngine: Please visit luahyparc.zapto.org for more information.")
end

Additionally
You cannot access pUnits or any other creature arguments through this system, unless you make them global variables. To add a larger degree of flexibility for you guys, I've set the global PLR to the player sending the chat-Lua.

Examples
Making the player say his guild name:
@@ PLR:PlayerSendChatMessage(1,0,PLR:GetGuildName())


Making the player's target insult himself
@@ PLR:GetSelection():PlayerSendChatMessage(1,0,"LFG ToC I do 200 dps")


Killing all players online
@@ for k,v in pairs(GetPlayersInWorld()) do PLR:Kill(v) end


Security
Yep, there's a risk guys. If an admin got naughty he could do some damage. No I'm not going to tell you how. But, if an admin does ever get naughty and you need to remove the system, you should execute this piece of code in your chatbox to make the command useless:
@@ ExecuteChatLua = nil

If you have other OnChat server hook functions, you should set them to nil in the same way as above for additional safety, THEN set ExecuteChatLua to nil. And of course, I take no responsibility for damages. It's up to you to choose admins wisely.

Finale
I hope you enjoy this! It should a whole new level of debugging for servers... bah what am I saying, I'm off to kill everyone online!! Laters xD!!
Please don't PM me asking to fix, correct or look-over your scripts. Please post a new thread in the Lua Scripting section so others can learn and help.
0

#2 User is offline   Bob Herman 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 452
  • Joined: 11-October 08
  • Gender:Male

Posted 19 October 2009 - 04:27 PM

Wow. That's pretty intense. :)
0

#3 User is offline   Shauren 

  • Helper
  • Group: Contributor
  • Posts: 808
  • Joined: 04-November 08
  • Gender:Male
  • Location:Poland
  • Interests:hmm, wow?

Posted 20 October 2009 - 08:27 AM

plr:CanUseCommand("AZ")

shouldnt be

plr:CanUseCommand("Z")

?
0

#4 User is offline   Terrorblade 

  • ArcEmu Lover
  • Group: Banned
  • Posts: 440
  • Joined: 07-June 08
  • Gender:Male
  • Location:Arcemu

Posted 20 October 2009 - 10:10 AM

yea it should be Z since you don't really need A and Z to be a admin I think.

View PostHasbro, on 14 June 2009 - 01:07 PM, said:

I'm a flaming homosexual.
Do not advertise here by the way.

Posted Image
Posted Image

#5 User is offline   hypersniper 

  • Advanced Member
  • Group: Retired
  • Posts: 227
  • Joined: 21-November 08
  • Gender:Male

Posted 20 October 2009 - 10:42 PM

Doesn't really matter to me, feel free to change it just to "Z" on your servers. If you want more security you can use :GetAccountName() to restrict it to just your characters :( .
Please don't PM me asking to fix, correct or look-over your scripts. Please post a new thread in the Lua Scripting section so others can learn and help.
0

#6 User is offline   Major Cooke 

  • Member
  • Pip
  • Group: Members
  • Posts: 10
  • Joined: 23-October 08

Posted 09 November 2009 - 10:00 PM

So how would one execute :ReloadLUAEngine()?
0

#7 User is offline   hypersniper 

  • Advanced Member
  • Group: Retired
  • Posts: 227
  • Joined: 21-November 08
  • Gender:Male

Posted 09 November 2009 - 10:27 PM

@@ ReloadLuaEngine()
Please don't PM me asking to fix, correct or look-over your scripts. Please post a new thread in the Lua Scripting section so others can learn and help.
0

#8 User is offline   Major Cooke 

  • Member
  • Pip
  • Group: Members
  • Posts: 10
  • Joined: 23-October 08

Posted 09 November 2009 - 10:53 PM

Odd... I tried it earlier it didn't work, but now it does. I suppose it's the capital/lowercase sensitivity. Godlike dude. Thanks!

Edit: Since LuaHypArc is now the default, you'll want to edit this part:

if (GetLuaEngine() == "LuaHypArc") then
   RegisterServerHook(16, "ExecuteChatLua")
else
   print("LuaEngine: Did not load 'Execute Chat Lua' script - LuaHypArc not installed.")
   print("LuaEngine: Please visit luahyparc.zapto.org for more information.")
end


so it just has:

RegisterServerHook(16, "ExecuteChatLua")


Otherwise, it will not load at all. This is a heads up for those who are wondering about the execution saying "Did not load 'Execute Chat Lua' script" part.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users