Ulysses
General => Developers Corner => Topic started by: TheSpy7 on March 18, 2013, 05:37:09 PM
-
Hi all. I have the following files in my /modules/sh/ folder.
Traitor.lua:
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:
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:
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?
-
any errors ? and you should use a combo command like !role targs,role changes target players to t/i/d
-
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
-
Text preferred. Copy/paste it instead of the images.
-
Text preferred. Copy/paste it instead of the images.
Got it.
Server console is returning with this:
[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
-
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'.
-
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?
-
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.
-
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
==
-
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.
-
Maybe, we specifically lower case most everything since the console is case-insensitive anyways. Or at least it historically was. Will check into it.
-
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 :()
-
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.
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." )
-
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
-
Nevermind. After hours of debugging, it turns out that ULX just doesn't like capitals (Traitor, Detective, etc.)
Fixed, sorry about that.
-
And thanks for bringing it to our attention.