General > Developers Corner

Adding Custom Commands?

(1/2) > >>

xXGhostieXx:
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.

xXGhostieXx:
Also where would i put that code?

TheAndroid1:
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?

xXGhostieXx:
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." )

MrPresident:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version