General > Developers Corner

Ulx respawn command - ttt

<< < (2/3) > >>

Nordic Husky:

--- Code: ---local CATEGORY_NAME = "Trouble in Terrorist town"
------------------------------ Slay ------------------------------
function ulx.spawn( calling_ply, target_plys )
local affected_plys = {}

for i=1, #target_plys do
local v = target_plys[ i ]

if ulx.getExclusive( v, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
elseif v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is already alive!", true )
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
v:SetTeam(1)
v:Spawn()
table.insert( affected_plys, v )
end
end

ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local spawn = ulx.command( CATEGORY_NAME, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawns 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." )

--- End code ---
That's the working code

Megiddo:

--- Quote from: Nordic Husky on January 04, 2013, 05:40:17 AM ---That's the working code

--- End quote ---

Awesome! :)

JamminR:

--- Quote from: Nordic Husky on January 04, 2013, 05:40:17 AM ---Tho' I now want to know if it's possible to disguise an admin? by changing the name showing and the picture and printing that your normal name disconnected and that the new name connected?. If so, how?

--- End quote ---
You could somewhat fake a reconnect.
As for not having every other script that looks for admins using standard group checks NOT see them as an admin anymore, well, no.
Not without removing them from actual admin group.
In theory, you COULD make a totally separate usergroup in ULX, like, "fakeadmin", and give it individually all the access that admin and below have, but, you can't have it inherit admin. You'd need to do each access individually. If you tinker with that idea, make sure you give them access back so they can get 'real' admin back using some command to.
You'd also have to make your own functions for group change, so it wouldn't get announced normally to the server.

So, those are just some general thoughts. My complication may be done easier, but another set of eyes would need to correct me. :)

krooks:

--- Code: ---local CATEGORY_NAME = "TTT"

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

--- End code ---
Didn't make this but it works (forgot where I grabbed it from, was probably a random FP thread about something completely different), the bodies don't get removed, I was going to try and fix that, but have been working on other things.

[TET] Tobias:
When I do the make traitor or detective command it doesn't spawn with credits please help.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version