Ulysses

General => Developers Corner => Topic started by: Nordic Husky on January 03, 2013, 01:47:39 AM

Title: Ulx respawn command - ttt
Post by: Nordic Husky on January 03, 2013, 01:47:39 AM
Hello, I'm having some issues coding a respawn command for a ttt server,
I can not find out what's wrong.....
Even if I change the "v:Kill()" in the slay command to "v:Spawn()" and change "elseif not" to "elseif"
it still comes up with lua errors, Can someone give me / help me make a working respawn command? C:
Title: Re: Ulx respawn command - ttt
Post by: Megiddo on January 03, 2013, 05:21:16 AM
What are the errors?
Title: Re: Ulx respawn command - ttt
Post by: nathan736 on January 03, 2013, 09:21:39 AM
might want to hunt down the lua for spawning in the ttt game mode see any args you need to have for tables in the gamemode
im not at home atm so cant do it for you  :-X
Title: Re: Ulx respawn command - ttt
Post by: Nordic Husky on January 04, 2013, 02:12:13 AM
I managed to make the script working now, 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?
Code: [Select]
local CATEGORY_NAME = "ttt"

------------------------------ Spawn ------------------------------
function ulx.tspawn( 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("Terrorists")
v:Spawn()
table.insert( affected_plys, v )
end

ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local tspawn = ulx.command( CATEGORY_NAME, "ulx tspawn", ulx.spawn, "!tspawn" )
tspawn:addParam{ type=ULib.cmds.PlayersArg }
tspawn:defaultAccess( ULib.ACCESS_ADMIN )
tspawn:help( "Spawn target(s) as terrorist." )

function ulx.traitor( 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 not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is dead!", true)
elseif v:IsFrozen() then
Ulib.tsayError( calling_ply, v:Nick() .. " is frozen!", true)
else
v:SetRole(ROLE_TRAITOR)
sendFullStateUpdate()
end
end
end
local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.traitor, "!traitor" )
traitor:addParam{ type=ULib.cmds.PlayersArg }
traitor:defautlAccess( ULib.ACCESS_ADMIN )
traitor:help( "Force target(s) to traitor" )

function ulx.detective( 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 not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is dead!", true)
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true)
else
v:SetRole(ROLE_DETECTIVE)
sendFullStateUpdate()
end
end
end
local detective = ulx.command( CATEGORY_NAME, "ulx detective", ulx.detective, "!detective" )
detective:addParam{ type=Ulib.cmds.PlayersArg }
detective:defaultAccess( ULib.ACCESS_ADMIN )
detective:help( "Force target(s) to detective" )

function ulx.innocent( 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 not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is dead!", true )
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
v:SetRole(ROLE_INNOCENT)
sendFullStateUpdate()
end
end
end
local innocent = ulx.command( CATEGORY_NAME, "ulx innocent", ulx.innocent, "!innocent" )
innocent:addParam{ type.ULib.cmds.PlayersArg }
innocent:defaultAccess( ULib.ACCESS_ADMIN )
innocent:help( "Froce target(s) to innocent" )
Title: Re: Ulx respawn command - ttt
Post by: Nordic Husky on January 04, 2013, 02:54:56 AM
I just tested the code, It apparently did not work, I got a different working code at home :P
Title: Re: Ulx respawn command - ttt
Post by: Nordic Husky on January 04, 2013, 05:40:17 AM
Code: [Select]
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." )
That's the working code
Title: Re: Ulx respawn command - ttt
Post by: Megiddo on January 04, 2013, 06:11:34 AM
That's the working code

Awesome! :)
Title: Re: Ulx respawn command - ttt
Post by: JamminR on January 04, 2013, 03:51:39 PM
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?
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. :)
Title: Re: Ulx respawn command - ttt
Post by: krooks on January 04, 2013, 05:45:12 PM
Code: [Select]
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)." )
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.
Title: Re: Ulx respawn command - ttt
Post by: [TET] Tobias on March 27, 2013, 09:10:18 PM
When I do the make traitor or detective command it doesn't spawn with credits please help.
Title: Re: Ulx respawn command - ttt
Post by: bender180 on March 28, 2013, 10:03:02 AM
Code: [Select]
for _, v in ipairs( target_plys ) do
       v:SetRole(ROLE_DETECTIVE)
       v:Give("weapon_ttt_wtester")
       v:AddCredits("1")
    end
Title: Re: Ulx respawn command - ttt
Post by: ambro on April 01, 2013, 10:49:37 PM
Code: [Select]
for _, v in ipairs( target_plys ) do
       v:SetRole(ROLE_DETECTIVE)
       v:Give("weapon_ttt_wtester")
       v:AddCredits("1")
    end

Thats actually not the proper way of doing that.

Instead use,
v:SetDefaultCredits()

in place of the Give and AddCredits, this will provide the base credits for T/D respectively
Title: Re: Ulx respawn command - ttt
Post by: [TET] Tobias on April 07, 2013, 05:47:40 PM
Thats actually not the proper way of doing that.

Instead use,
v:SetDefaultCredits()

in place of the Give and AddCredits, this will provide the base credits for T/D respectively
Can you show me where to put the command. Every time I use it will make LUA errors.