Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: Ducks on April 03, 2015, 02:10:47 AM

Title: help pls
Post 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:
Code: [Select]
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" )

Title: Re: help pls
Post by: Caustic Soda-Senpai on April 03, 2015, 02:36:32 AM
RunConsoleCommand( "ulx", "ban", target_ply, 120 )
Title: Re: help pls
Post by: Ducks on April 03, 2015, 03:37:05 AM
(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:
Code: [Select]
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" )

Title: Re: help pls
Post by: Aaron113 on April 03, 2015, 06:58:20 AM
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.
Title: Re: help pls
Post by: Decicus on April 03, 2015, 10:27:36 AM
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.
Title: Re: help pls
Post by: Ducks on April 03, 2015, 05:18:54 PM
My Code:
Code: [Select]
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
Title: Re: help pls
Post by: Decicus on April 03, 2015, 05:26:37 PM
My Code:
Code: [Select]
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:
Code: [Select]
calling_ply:ConCommand( "ulx ban " .. target_ply:Name() .. " 120" )
Title: Re: help pls
Post by: Ducks on April 03, 2015, 05:37:40 PM
Command "ulx ban", argument #2: invalid number or time string "Ducks" specified
Title: Re: help pls
Post by: Aaron113 on April 03, 2015, 09:31:43 PM
Code: [Select]
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.
Title: Re: help pls
Post by: Decicus on April 04, 2015, 08:01:05 AM
Code: [Select]
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.