Ulysses

General => Developers Corner => Topic started by: TheSpy7 on March 18, 2013, 05:37:09 PM

Title: TTT Module not working
Post by: TheSpy7 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?
Title: Re: TTT Module not working
Post by: nathan736 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
Title: Re: TTT Module not working
Post by: TheSpy7 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
Title: Re: TTT Module not working
Post by: JamminR on March 19, 2013, 01:49:47 PM
Text preferred. Copy/paste it instead of the images.
Title: Re: TTT Module not working
Post by: TheSpy7 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
Title: Re: TTT Module not working
Post by: JamminR 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'.
Title: Re: TTT Module not working
Post by: TheSpy7 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?
Title: Re: TTT Module not working
Post by: TheSpy7 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.
Title: Re: TTT Module not working
Post by: nathan736 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
==
Title: Re: TTT Module not working
Post by: JamminR 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.
Title: Re: TTT Module not working
Post by: 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.
Title: Re: TTT Module not working
Post by: nathan736 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 :()
Title: Re: TTT Module not working
Post by: TheSpy7 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." )
Title: Re: TTT Module not working
Post by: nathan736 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
Title: Re: TTT Module not working
Post by: Megiddo 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.
Title: Re: TTT Module not working
Post by: JamminR on June 01, 2013, 08:35:36 PM
And thanks for bringing it to our attention.