Ulysses
Ulysses Stuff => General Chat & Help and Support => Topic started by: Ducks on April 03, 2015, 02:10:47 AM
-
i may sound like a noob but how do i make a ulx command to run a console command this is what i have now its supposed to ban the target for 2 hours but it doesn't work D:
local CATEGORY_NAME = "Utility"
function ulx.ban2( command, target_ply, minutes )
RunConsoleCommand( "ulx ban", target_ply, 120 )
end
local ban2 = ulx.command( CATEGORY_NAME, "ulx ban2", ulx.ban2,
"!ban2", true)
ban2:addParam{ type=ULib.cmds.PlayerArg }
ban2:defaultAccess( ULib.ACCESS_ADMIN )
ban2:help( "Bans A Player For 2 Hours" )
-
RunConsoleCommand( "ulx", "ban", target_ply, 120 )
-
(Console) Banned Ducks For 2 Hours
ServerLog: [ULX] (Console) Banned Ducks For 2 Hours
Command "ulx ban", argument #1: No target found or target has immunity! (never banned me)
;-;
My Code: local CATEGORY_NAME = "Utility"
function ulx.ban2( calling_ply, target_ply, minutes, reason )
RunConsoleCommand( "ulx", "ban", 120, target_ply )
ulx.fancyLogAdmin(calling_ply, false, "#A Banned #T For 2 Hours", target_ply)
end
local ban2 = ulx.command( CATEGORY_NAME, "ulx ban2", ulx.ban2,
"!ban2", true)
ban2:addParam{ type=ULib.cmds.PlayerArg }
ban2:defaultAccess( ULib.ACCESS_ADMIN )
ban2:help( "Bans A Player For 2 Hours" )
-
I think you have the wrong arguments in the code above. I don't know if that's for sure the reason or not, but it's: target_ply, minutes, reason
Also, I would use calling_ply:ConCommand() (http://wiki.garrysmod.com/page/Player/ConCommand) instead. With the current version, anyone with access to the command could ban anyone. An admin could ban a superadmin.
-
I think you have the wrong arguments in the code above. I don't know if that's for sure the reason or not, but it's: target_ply, minutes, reason
Also, I would use calling_ply:ConCommand() (http://wiki.garrysmod.com/page/Player/ConCommand) instead. With the current version, anyone with access to the command could ban anyone. An admin could ban a superadmin.
This, but also remember to use target_ply:Nick() to get the in-game name of the user instead of the player object.
-
My Code:
local CATEGORY_NAME = "Utility"
function ulx.ban2( calling_ply, target_ply, minutes, reason )
calling_ply:ConCommand( "ulx", "ban", 120, target_ply:Name() )
ulx.fancyLogAdmin(calling_ply, false, "#A Banned #T For 2 Hours", target_ply)
end
local ban2 = ulx.command( CATEGORY_NAME, "ulx ban2", ulx.ban2,
"!ban2", true)
ban2:addParam{ type=ULib.cmds.PlayerArg }
ban2:defaultAccess( ULib.ACCESS_ADMIN )
ban2:help( "Bans A Player For 2 Hours" )
it says this in my client console : You Banned Yourself For 2 Hours
No command entered. If you need help, please type "ulx help" in your console.
and this in server console You Banned Yourself For 2 Hours
No command entered. If you need help, please type "ulx help" in your console.
but it doesnt ban me
-
My Code: local CATEGORY_NAME = "Utility"
function ulx.ban2( calling_ply, target_ply, minutes, reason )
calling_ply:ConCommand( "ulx", "ban", 120, target_ply:Name() )
ulx.fancyLogAdmin(calling_ply, false, "#A Banned #T For 2 Hours", target_ply)
end
local ban2 = ulx.command( CATEGORY_NAME, "ulx ban2", ulx.ban2,
"!ban2", true)
ban2:addParam{ type=ULib.cmds.PlayerArg }
ban2:defaultAccess( ULib.ACCESS_ADMIN )
ban2:help( "Bans A Player For 2 Hours" )
it says this in my client console : You Banned Yourself For 2 Hours
No command entered. If you need help, please type "ulx help" in your console.
and this in server console You Banned Yourself For 2 Hours
No command entered. If you need help, please type "ulx help" in your console.
but it doesnt ban me
calling_ply:ConCommand() (http://wiki.garrysmod.com/page/Player/ConCommand) works differently.
Try doing:
calling_ply:ConCommand( "ulx ban " .. target_ply:Name() .. " 120" )
-
Command "ulx ban", argument #2: invalid number or time string "Ducks" specified
-
calling_ply:ConCommand( "ulx ban \"" .. target_ply:Name() .. "\" 120" )
That is one fix, but I'm not sure if it will fix your problem or not.
Perhaps it would be better to change the PlayersArg to a StringArg and just pass the string straight into the ban command? Let ulx.ban do all the work instead of doing twice the work.
-
calling_ply:ConCommand( "ulx ban \"" .. target_ply:Name() .. "\" 120" )
That is one fix, but I'm not sure if it will fix your problem or not.
Perhaps it would be better to change the PlayersArg to a StringArg and just pass the string straight into the ban command? Let ulx.ban do all the work instead of doing twice the work.
That would probably be a better idea.
You also have 'minutes' and 'reason' parameters in the function that aren't used. You can remove those as well.