Author Topic: TTT Module not working  (Read 6536 times)

0 Members and 4 Guests are viewing this topic.

Offline TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
TTT Module not working
« on: March 18, 2013, 05:37:09 PM »
Hi all. I have the following files in my /modules/sh/ folder.

Traitor.lua:
Code: [Select]
local CATEGORY_NAME = "Traitor"

function ulx.Traitor( ply, targs )
    for _,v in pairs(targs) do
        v:SetTeam( TEAM_TERROR )
        v:Spawn()
v:SetRole(ROLE_TRAITOR)
    end
     SendFullStateUpdate()
    ulx.fancyLogAdmin( ply, true, "#A has made #T a Traitor!", targs )
end
local Traitor = ulx.command( "Traitor", "ulx Traitor", ulx.Traitor, "!Traitor" )
Traitor:addParam{ type=ULib.cmds.PlayersArg }
Traitor:defaultAccess( ULib.ACCESS_SUPERADMIN )
Traitor:help( "Make target a Traitor." )

Innocent.lua:
Code: [Select]
local CATEGORY_NAME = "Innocent"

function ulx.Innocent( ply, targs )
    for _,v in pairs(targs) do
        v:SetTeam( TEAM_TERROR )
        v:Spawn()
v:SetRole(ROLE_INNOCENT)
    end
     SendFullStateUpdate()
    ulx.fancyLogAdmin( ply, true, "#A has made #T an Innocent!", targs )
end
local Innocent = ulx.command( "Innocent", "ulx Innocent", ulx.Innocent, "!Innocent" )
Innocent:addParam{ type=ULib.cmds.PlayersArg }
Innocent:defaultAccess( ULib.ACCESS_SUPERADMIN )
Innocent:help( "Make target a Innocent." )

Detective.lua:
Code: [Select]
local CATEGORY_NAME = "Detective"

function ulx.Detective( ply, targs )
    for _,v in pairs(targs) do
        v:SetTeam( TEAM_TERROR )
        v:Spawn()
v:SetRole(ROLE_DETECTIVE)
    end
     SendFullStateUpdate()
    ulx.fancyLogAdmin( ply, true, "#A has made #T a Detective!", targs )
end
local Detective = ulx.command( "Detective", "ulx Detective", ulx.Detective, "!Detective" )
Detective:addParam{ type=ULib.cmds.PlayersArg }
Detective:defaultAccess( ULib.ACCESS_SUPERADMIN )
Detective:help( "Make target a Detective." )

For some reason none of these files work while another is placed in the folder. Why is this, and how do I fix it?

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: TTT Module not working
« Reply #1 on: March 19, 2013, 10:55:14 AM »
any errors ? and you should use a combo command like !role targs,role  changes  target players to t/i/d
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 TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: TTT Module not working
« Reply #2 on: March 19, 2013, 11:50:04 AM »
any errors ? and you should use a combo command like !role targs,role  changes  target players to t/i/d

There are errors in the console for my server. When I get home I will take screenshots and post.

Thanks,
TheSpy7

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Module not working
« Reply #3 on: March 19, 2013, 01:49:47 PM »
Text preferred. Copy/paste it instead of the images.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: TTT Module not working
« Reply #4 on: March 19, 2013, 04:16:49 PM »
Text preferred. Copy/paste it instead of the images.

Got it.

Server console is returning with this:

Code: [Select]
[ERROR] addons/ulib/lua/ulib/shared/commands.lua:1296: Invalid command!
1. __fn - [C]:-1
2. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
3. Run - lua/includes/modules/concommand.lua:69
4. unknown - addons/ulib/lua/ulib/shared/commands.lua:1310
5. unknown - lua/includes/modules/concommand.lua:69

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Module not working
« Reply #5 on: March 19, 2013, 07:20:45 PM »
Are the role and team variables set globally, before those commands are run?
You use setrole and setteam several times, and the error seems to refer to a global variable (__fn) and says 'unknown'.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: TTT Module not working
« Reply #6 on: March 19, 2013, 08:46:26 PM »
Are the role and team variables set globally, before those commands are run?
You use setrole and setteam several times, and the error seems to refer to a global variable (__fn) and says 'unknown'.

How can I check that?

Offline TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: TTT Module not working
« Reply #7 on: March 19, 2013, 11:45:08 PM »
Are the role and team variables set globally, before those commands are run?
You use setrole and setteam several times, and the error seems to refer to a global variable (__fn) and says 'unknown'.

Nevermind. After hours of debugging, it turns out that ULX just doesn't like capitals (Traitor, Detective, etc.)

Well, that was frustrating.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: TTT Module not working
« Reply #8 on: March 20, 2013, 09:36:15 AM »
doing a check to see if they are dead  then spawn them if they are could help prevent people geting spawned on kill boxes


shity old post bellow
==
that reminds me -face ground - you don't need to set there team  because TTT does it  how do you think people become terrorists they get set to it by the game mode
ps: this would only cause adverse effects on spectators but Why would you set a spectator to a role anyways they are spectating for a reason
==
« Last Edit: March 21, 2013, 08:37:04 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 JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Module not working
« Reply #9 on: March 20, 2013, 01:25:06 PM »
Nevermind. After hours of debugging, it turns out that ULX just doesn't like capitals
Wait, what?
Except for making sure you type in the same commands/case sensitivity in lua, ULib shouldn't care.
Megiddo, is there something in ULib that would prevent these from loading if he's using mixed-case.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: TTT Module not working
« Reply #10 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.
Experiencing God's grace one day at a time.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: TTT Module not working
« Reply #11 on: March 21, 2013, 09:52:44 AM »
Code: [Select]
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." )
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 :()
« Last Edit: March 22, 2013, 07:26:59 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 TheSpy7

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: TTT Module not working
« Reply #12 on: March 21, 2013, 05:03:16 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.

Ok. Weird! Here is the new code that works perfectly.

Code: [Select]
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." )

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: TTT Module not working
« Reply #13 on: March 22, 2013, 07:28:17 AM »
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
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 Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: TTT Module not working
« Reply #14 on: June 01, 2013, 02:35:45 PM »
Nevermind. After hours of debugging, it turns out that ULX just doesn't like capitals (Traitor, Detective, etc.)

Fixed, sorry about that.
Experiencing God's grace one day at a time.