Ulysses
General => Developers Corner => Topic started by: xXGhostieXx 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.
-
Also where would i put that code?
-
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?
-
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." )
-
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.
-
For the traitor code add this after v:SetRole(ROLE_TRAITOR)
v:AddCredits(GetConVarNumber("ttt_credits_starting"))
And add this after v:SetRole(ROLE_DETECTIVE)
v:AddCredits("1")
This is to give the players that are cheating the right amount of credits, otherwise they would change with zero credits.