G.RunString

From GMod Wiki

(Redirected from RunString)
Jump to: navigation, search
Function
Syntax RunString( String command )
Where is this used?
Description:
Runs the specified string as a Lua command. Same as putting lua_run in console.
Returns: nil
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.RunString]G.RunString [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionThis will kill every player in the server.
Used onNewerServer.png
Code
 RunString("for k,v in pairs( player.GetAll() ) do v:Kill() end");
OutputN/A


DescriptionA replacement for lua_run_cl.
Used onNewerClient.png
Code
 local RunString = _G["RunString"]
 concommand.Add("runlua",function (objPl,strCmd,tblArgs)
	if #tblArgs and #tblArgs ~= 0 then
		local strLua = table.concat(tblArgs," ")
		print("Running lua: \""..strLua.."\"")
		RunString(strLua)
		return
	end
	print("Must contain code to run code")
 end)
OutputN/A


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox