Ulysses
General => Developers Corner => Topic started by: Tomzen on May 05, 2015, 02:57:42 AM
-
Source:
local CATEGORY_NAME = "Custom"
function ulx.impersonate( calling_ply, msg, target_plys )
target_plys:ConCommand("say ", msg)
ulx.fancyLogAdmin( calling_ply, true, "#A impersonated #T", target_plys )
end
local impersonate = ulx.command( CATEGORY_NAME, "ulx impersonate", ulx.impersonate, "!imp" )
impersonate:addParam{ type=ULib.cmds.PlayersArg }
impersonate:addParam{ type=ULib.cmds.StringArg, hint="msg" }
impersonate:addParam{ type=ULib.cmds.BoolArg, invisible=true }
impersonate:defaultAccess( ULib.ACCESS_SUPERADMIN )
impersonate:help( "Impersonates a player." )
Error:
[ERROR] addons/ulx/lua/ulx/modules/sh/custom.lua:3: bad key to string index (number expected, got string)
-
For one, you have your parameters backwards. They must be in the order you added them. Try fixing that and see where the script stands. I see possibly a few other things that need tweaking.
-
Interesting command! What's you plans for this?
-
Pretty obvious.
Kind of like gimp, but, you control what the target says real time rather than from a table of pre-configured gimp sayings.
Fun idea.
Though I see this as the opportunity to give someone the ability to do this that you might not trust with "ulx cexec" access, it can also be done using cexec.
ulx cexec <target> say "string"
Cexec is pretty powerful though, I can imagine not trusting as many people with it as you might this impersonate command.
-
well what would this be used for? why would you need to talk in someone else?
-
well what would this be used for? why would you need to talk in someone else?
Purely for fun... I used to do it all the time with cexec. Mainly just to give people the rusty bullet hole achievement.
-
Yeah, looking back, I now see I'm a complete idiot haha:
function ulx.impersonate( calling_ply, target_plys, msg )
for k,v in pairs( target_plys ) do
v:ConCommand( "say " .. msg .. "" )
end
ulx.fancyLogAdmin( calling_ply, true, "#A impersonated #T", target_plys )
end
local impersonate = ulx.command( CATEGORY_NAME, "ulx impersonate", ulx.impersonate, "!imp" )
impersonate:addParam{ type=ULib.cmds.PlayersArg }
impersonate:addParam{ type=ULib.cmds.StringArg, hint="string", ULib.cmds.takeRestOfLine }
impersonate:addParam{ type=ULib.cmds.BoolArg, invisible=true }
impersonate:defaultAccess( ULib.ACCESS_SUPERADMIN )
impersonate:help( "Impersonates a player." )
-
Heh.
Using multiple targets.
] ulx impersonate !^ "The cake is a lie"
] say "no it's not!"
-
heheh, just added that incase I feel like doing so :P
-
heheh, just added that incase I feel like doing so :P
Don't need to add anything. Our target object PlayerArgs would already allow for it.
-
Also JamminR, I would not trust this command to anyone but HeadAdmins, or someone I really trust, because it can be used to force a player to type a command, example I could force you to "!ban *" or "!mode maintenance" etc.
-
Also JamminR, I would not trust this command to anyone but HeadAdmins, or someone I really trust, because it can be used to force a player to type a command, example I could force you to "!ban *" or "!mode maintenance" etc.
!ban doesn't accept multiple targets. You can't do !ban *
I see your point though. ;)