General > Developers Corner
TTT Module not working
Megiddo:
Maybe, we specifically lower case most everything since the console is case-insensitive anyways. Or at least it historically was. Will check into it.
nathan736:
--- Code: ---local CATEGORY_NAME = "TTT"
function ulx.Traitor( ply, targs,role )
if role =="T"or role == "t" then role == ROLE_TRAITOR end
else if role == "D"or role == "d" then role == ROLE_DETECTIVE
else if role == "I"or role == "i" then role == ROLE_INNOCENT
else ULib.tsayError( calling_ply, "invalid role use T,D,I")
return
end
for _,v in pairs(targs) do
if not v:alive() then
v:Spawn()
end
v:SetRole(role)
end
SendFullStateUpdate()
ulx.fancyLogAdmin( ply, true, "#A has made #T "..role, targs )
end
local Traitor = ulx.command( CATEGORY_NAME, "ulx Role", ulx.role, "!role" )
Traitor:addParam{ type=ULib.cmds.PlayersArg }
Traitor:addParam{ type=ULib.cmds.StringArg, hint="T,D,I" }
Traitor:defaultAccess( ULib.ACCESS_SUPERADMIN )
Traitor:help( "sets the player to a role T,D,I." )
--- End code ---
this may or may not work but is a combination of the role commands
im not sure if spectators are dead so i did not put it in the not alive check
ps: formating with numbers (nope :()
TheSpy7:
--- Quote from: Megiddo on March 20, 2013, 06:47:30 PM ---Maybe, we specifically lower case most everything since the console is case-insensitive anyways. Or at least it historically was. Will check into it.
--- End quote ---
Ok. Weird! Here is the new code that works perfectly.
--- Code: ---local CATEGORY_NAME = "TTT"
function ulx.cc_traitor( ply, targs )
for _, v in ipairs( targs ) do
v:SetRole(ROLE_TRAITOR)
end
SendFullStateUpdate()
ulx.fancyLogAdmin( ply, true, "#A turned #T into a traitor", targs )
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." )
--- End code ---
nathan736:
spy you should re add v:spawn() because setting the dead persons role and not spawning him can get the round traped so use a check to see if they are dead like the code i wrote above
Megiddo:
--- Quote from: TheSpy7 on March 19, 2013, 11:45:08 PM ---Nevermind. After hours of debugging, it turns out that ULX just doesn't like capitals (Traitor, Detective, etc.)
--- End quote ---
Fixed, sorry about that.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version