Author Topic: Ulx respawn command - ttt  (Read 12244 times)

0 Members and 1 Guest are viewing this topic.

Offline Nordic Husky

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Ulx respawn command - ttt
« 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:

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Ulx respawn command - ttt
« Reply #1 on: January 03, 2013, 05:21:16 AM »
What are the errors?
Experiencing God's grace one day at a time.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Ulx respawn command - ttt
« Reply #2 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
« Last Edit: January 03, 2013, 09:29:08 AM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline Nordic Husky

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Ulx respawn command - ttt
« Reply #3 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" )

Offline Nordic Husky

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Ulx respawn command - ttt
« Reply #4 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

Offline Nordic Husky

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
Re: Ulx respawn command - ttt
« Reply #5 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

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Ulx respawn command - ttt
« Reply #6 on: January 04, 2013, 06:11:34 AM »
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ulx respawn command - ttt
« Reply #7 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. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: Ulx respawn command - ttt
« Reply #8 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.
My TTT server. Join the fun!

Offline [TET] Tobias

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Ulx respawn command - ttt
« Reply #9 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.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Ulx respawn command - ttt
« Reply #10 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
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Re: Ulx respawn command - ttt
« Reply #11 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

Offline [TET] Tobias

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Ulx respawn command - ttt
« Reply #12 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.