Author Topic: Adding Custom Commands?  (Read 3180 times)

0 Members and 1 Guest are viewing this topic.

Offline xXGhostieXx

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Adding Custom Commands?
« on: February 15, 2013, 07:32:05 PM »
Hello, I have my own server but for some reason I don't have like a !respawn <name> or ulx_force_traitor etc. in my !menu so i was wondering how i could upload customs commands to do that.
- /=[GG]=\Ghostie

Offline xXGhostieXx

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Adding Custom Commands?
« Reply #1 on: February 15, 2013, 08:14:06 PM »
Also where would i put that code?
- /=[GG]=\Ghostie

Offline TheAndroid1

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: Adding Custom Commands?
« Reply #2 on: February 16, 2013, 11:01:19 AM »
Please be specific!
Where did you put the LUA file that has the command scripts?
Could you post the LUA here so we could help if it is to be a LUA error?

Offline xXGhostieXx

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Adding Custom Commands?
« Reply #3 on: February 16, 2013, 01:09:39 PM »
Uhh thanks for the wanting to help but i got it...i put it in.../garrysmod/addons/ulx/lua/ulx/modules/sh  the lua was.


local CATEGORY_NAME = "ForcingStuff"

-- RESPAWN PLAYER --
function ulx.respawn( calling_ply, target_plys )

for _,v in pairs(target_plys) do
v:SetTeam( TEAM_TERROR )
v:Spawn()
end
ulx.fancyLogAdmin( calling_ply, "#A has respawned #T!", target_plys )
end
local strip = ulx.command( "TTT", "ulx respawn", ulx.respawn, "!respawn" )
strip:addParam{ type=ULib.cmds.PlayersArg }
strip:defaultAccess( ULib.ACCESS_SUPERADMIN )
strip:help( "Respawn the target(s)." )
------------------------------ Traitor ------------------------------
function ulx.cc_traitor( ply, targs )

    for _, v in ipairs( targs ) do
       v:SetRole(ROLE_TRAITOR)
    end
    SendFullStateUpdate()
 end
 local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.cc_traitor, "!traitor", true )
 traitor:addParam{type=ULib.cmds.PlayersArg, hint = "<user(s)>"}
 traitor:defaultAccess( ULib.ACCESS_SUPERADMIN )
 traitor:help( "Turns target(s) into a traitor." )

------------------------------ Detective ------------------------------
function ulx.cc_detective( ply, targs )

    for _, v in ipairs( targs ) do
       v:SetRole(ROLE_DETECTIVE)
    end
    SendFullStateUpdate()
 end
 local traitor = ulx.command( CATEGORY_NAME, "ulx detective", ulx.cc_detective, "!detective", true )
 traitor:addParam{type=ULib.cmds.PlayersArg, hint = "<user(s)>"}
 traitor:defaultAccess( ULib.ACCESS_SUPERADMIN )
 traitor:help( "Turns target(s) into a detective." )

------------------------------ Innocenct ------------------------------
function ulx.cc_innocent( ply, targs )

    for _, v in ipairs( targs ) do
       v:SetRole(ROLE_INNOCENT)
    end
    SendFullStateUpdate()
 end
 local traitor = ulx.command( CATEGORY_NAME, "ulx innocent", ulx.cc_innocent, "!innocent", true )
 traitor:addParam{type=ULib.cmds.PlayersArg, hint = "<user(s)>"}
 traitor:defaultAccess( ULib.ACCESS_SUPERADMIN )
 traitor:help( "Turns target(s) into a innocent." )

- /=[GG]=\Ghostie

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Adding Custom Commands?
« Reply #4 on: February 16, 2013, 01:44:48 PM »
It seems that you already have a little (or a lot) or knowledge of how LUA works. That's great! Most people who come to these forums asking for help for things that aren't even ULX related have little to no experience.

I would make one suggestion though.

Instead of putting your file in addons/ulx/lua/ulx/modules/sh

I would create my own addon... something like...

addons/ForceStuff/lua/ulx/modules/sh

It would work exactly the same, except as you have it right now, when you update ULX you will inevitably lose your custom files.

Offline TheAndroid1

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: Adding Custom Commands?
« Reply #5 on: February 17, 2013, 06:21:56 AM »
For the traitor code add this after v:SetRole(ROLE_TRAITOR)
Code: [Select]
v:AddCredits(GetConVarNumber("ttt_credits_starting"))
And add this after v:SetRole(ROLE_DETECTIVE)
Code: [Select]
v:AddCredits("1")
This is to give the players that are cheating the right amount of credits, otherwise they would change with zero credits.
« Last Edit: February 26, 2013, 02:53:43 PM by TheAndroid1 »