Author Topic: help pls  (Read 3173 times)

0 Members and 1 Guest are viewing this topic.

Offline Ducks

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
help pls
« 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" )


Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: help pls
« Reply #1 on: April 03, 2015, 02:36:32 AM »
RunConsoleCommand( "ulx", "ban", target_ply, 120 )
Once you get to know me, you'll find you'll have never met me at all.

Offline Ducks

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: help pls
« Reply #2 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" )


Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: help pls
« Reply #3 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() instead.  With the current version, anyone with access to the command could ban anyone.  An admin could ban a superadmin.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: help pls
« Reply #4 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() 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.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Ducks

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: help pls
« Reply #5 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

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: help pls
« Reply #6 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() works differently.
Try doing:
Code: [Select]
calling_ply:ConCommand( "ulx ban " .. target_ply:Name() .. " 120" )
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Ducks

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: help pls
« Reply #7 on: April 03, 2015, 05:37:40 PM »
Command "ulx ban", argument #2: invalid number or time string "Ducks" specified

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: help pls
« Reply #8 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.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: help pls
« Reply #9 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.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.