• Would this work? (ulx command)
    12 replies, posted
I'm making a ulx command so when you type !kill it kills you. Would this work? local kill = ulx.command( CATEGORY_NAME, "ulx kill", ulx.kill, "!kill" ) kill:addParam{ type=ULib.cmds.PlayersArg } kill:defaultAccess( ULib.ACCESS_ADMIN ) kill:help( "Kills yourself." ) function ulx.kill() LocalPlayer():ConCommand( "kill" ) end
Depending on the gamemode a player may not be able to suicide in which case you'd have to kill them from the server.
Deathrun
Have you tried it? Usually works to try it yourself instead of coming onto a forum and asking us to.
[QUOTE=DiTTo4;46145605]I'm making a ulx command so when you type !kill it kills you. Would this work? local kill = ulx.command( CATEGORY_NAME, "ulx kill", ulx.kill, "!kill" ) kill:addParam{ type=ULib.cmds.PlayersArg } kill:defaultAccess( ULib.ACCESS_ADMIN ) kill:help( "Kills yourself." ) function ulx.kill() LocalPlayer():ConCommand( "kill" ) end[/QUOTE] Easy as hell to break it. [sp]alias "kill" "say nope"[/sp]
You're defining the function after using it in ulx.command, so you're passing it a nil value instead of a function and so of course it won't work. Instead of making the player run a console command you can actually just kill them, the server side way. Why are you even giving a parameter as player if you intend to kill the caller? The caller is given regardless of the parameters you add. [lua] ulx.kill = function( caller ) caller:Kill() end local kill = ulx.command( CATEGORY_NAME, "ulx kill", ulx.kill, "!kill" ) kill:defaultAccess( ULib.ACCESS_ADMIN ) kill:help( "Kills yourself." )[/lua]
Why not just have something like this? and you can just change target_ply to calling_ply to make it work on that person without needing a target ply [lua] function ulx.kill( calling_ply, target_ply ) target_ply:Kill() ulx.fancyLogAdmin( calling_ply, "#A killed #T.", target_ply ) end local kill = ulx.command( CATEGORY_NAME, "ulx kill", ulx.kill, "!kill" ) kill:defaultAccess( ULib.ACCESS_ALL ) kill:addParam{ type=ULib.cmds.PlayerArg } kill:help( "Kills a player." )[/lua]
Thank you for the help covey88. It works!
How would I make it so it doesn't have a list to choose who you want to kill. I just want it the have a button (like the ulx command the time) so when you click it, it kills yourself. [CODE]function ulx.kill( calling_ply, target_ply ) target_ply:Kill() ulx.fancyLogAdmin( calling_ply, "#A killed #T.", target_ply ) end local kill = ulx.command( "DiTTo", "ulx kill", ulx.kill, "!kill" ) kill:defaultAccess( ULib.ACCESS_ALL ) kill:addParam{ type=ULib.cmds.PlayerArg } kill:help( "Kills a player." )[/CODE]
[QUOTE=DiTTo4;46167634]How would I make it so it doesn't have a list to choose who you want to kill. I just want it the have a button (like the ulx command the time) so when you click it, it kills yourself. [CODE]function ulx.kill( calling_ply, target_ply ) target_ply:Kill() ulx.fancyLogAdmin( calling_ply, "#A killed #T.", target_ply ) end local kill = ulx.command( "DiTTo", "ulx kill", ulx.kill, "!kill" ) kill:defaultAccess( ULib.ACCESS_ALL ) kill:addParam{ type=ULib.cmds.PlayerArg } kill:help( "Kills a player." )[/CODE][/QUOTE] if you have any interest in learning & improving now is a great time to go into the ULX files and see how they've done the time button, then copy it over (write it out, it sticks in your head easier) to make it do the same for your kill function
I can't figure it out.
[QUOTE=DiTTo4;46167634]How would I make it so it doesn't have a list to choose who you want to kill. I just want it the have a button (like the ulx command the time) so when you click it, it kills yourself.[/QUOTE] I don't see why you don't use the kill command already in gmod but if you want in ulx here you go: [CODE] function ulx.kill( calling_ply ) calling_ply:Kill() end local kill = ulx.command( "DiTTo", "ulx kill", ulx.kill, "!kill" ) kill:defaultAccess( ULib.ACCESS_ALL ) kill:help( "Kills yourself." ) [/CODE] Not tested but should work
Thank you, it works!
Sorry, you need to Log In to post a reply to this thread.