Hey it's me again :P
So I'm trying to modify ULX's default "slay" command so that instead you add the player you want slayed into a queue and when the round next starts, the SlayQ automatically slays said player without the Admin needing to manually slay the player themselves.
Now this works perfectly fine, the player dies at Round start and no errors pop up but when I try to add a text for the SlayQ to say after someone is slain the console gives me an error.
Here is the Section for the SlayQ script:
[code]------------------------------ SlayQ ------------------------------
function ulx.slay( 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:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
hook.Add("TTTBeginRound", "Kill SlayQ", function()
v:Kill()
table.insert( affected_plys, v )
player.PrintMessage( HUD_PRINTTALK, v .. " was slain by SlayQ for RDM") -- The bit that says the message
end)
end
end
end
local slay = ulx.command( CATEGORY_NAME, "ulx slayq", ulx.slay, "!slayq" )
slay:addParam{ type=ULib.cmds.PlayersArg }
slay:defaultAccess( ULib.ACCESS_ADMIN )
slay:help( "Adds Target to slay queue." )[/code]
And this is the console error:
[code][ERROR] addons/ulx/lua/ulx/modules/sh/fun.lua:114: attempt to concatenate upvalue 'v' (a userdata value)
1. fn - addons/ulx/lua/ulx/modules/sh/fun.lua:114
2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
3. unknown - gamemodes/terrortown/gamemode/init.lua:671[/code]
Thanks,
Tarado
[QUOTE=Tarado;44971932]Hey it's me again :P
So I'm trying to modify ULX's default "slay" command so that instead you add the player you want slayed into a queue and when the round next starts, the SlayQ automatically slays said player without the Admin needing to manually slay the player themselves.
Now this works perfectly fine, the player dies at Round start and no errors pop up but when I try to add a text for the SlayQ to say after someone is slain the console gives me an error.
Here is the Section for the SlayQ script:
[code]------------------------------ SlayQ ------------------------------
function ulx.slay( 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:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
hook.Add("TTTBeginRound", "Kill SlayQ", function()
v:Kill()
table.insert( affected_plys, v )
player.PrintMessage( HUD_PRINTTALK, v .. " was slain by SlayQ for RDM") -- The bit that says the message
end)
end
end
end
local slay = ulx.command( CATEGORY_NAME, "ulx slayq", ulx.slay, "!slayq" )
slay:addParam{ type=ULib.cmds.PlayersArg }
slay:defaultAccess( ULib.ACCESS_ADMIN )
slay:help( "Adds Target to slay queue." )[/code]
And this is the console error:
[code][ERROR] addons/ulx/lua/ulx/modules/sh/fun.lua:114: attempt to concatenate upvalue 'v' (a userdata value)
1. fn - addons/ulx/lua/ulx/modules/sh/fun.lua:114
2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
3. unknown - gamemodes/terrortown/gamemode/init.lua:671[/code]
Thanks,
Tarado[/QUOTE]
v is the player object. Use v:Nick() instead.
Sincerely,
HumbleTH
You're attempting to concatenate the variable v which is a userdata value, you have to do, "v:Nick()".
Ok now it gives me an entirely new error:
[IMG]http://i.imgur.com/Ww3MM2A.png[/IMG]
Player:PrintMessage is an example given on the wiki, assuming player. is the player entity.
Player:PrintMessage( number type, string message )
v:PrintMessage( HUD_PRINTTALK, v:Nick() .. " was slain by SlayQ for RDM") -- The bit that says the message
Ok it works but it only shows the message to person being slayed (hence why its v:PrintMessage). But I need it to say the message globally to all players. How is this possible ?
Sorry for the inconvinience
remove the v:
Thank you very much, it works now :)
[QUOTE=AnonTakesOver;44972091]remove the v:[/QUOTE]
You're just spamming the PrintMessage function now.
Instead save the player nickname to a variable then do it with the global function.
[url]http://forums.ulyssesmod.net/index.php?topic=6279.0[/url]
There are already free releases with a command like this. Slaynr / Slay Next Round does exactly what you're talking about.
[QUOTE=SaintSin6;44973416][url]http://forums.ulyssesmod.net/index.php?topic=6279.0[/url]
There are already free releases with a command like this. Slaynr / Slay Next Round does exactly what you're talking about.[/QUOTE]
That's not what he's asking for; his already works. He's just wondering on how to do something.
[QUOTE=brandonj4;44972710]You're just spamming the PrintMessage function now.
Instead save the player nickname to a variable then do it with the global function.[/QUOTE]
Didn't realize it was in a for loop, you're right.
<snip>
Wait, isn't this a mess? The loop and the hook don't make sense. Won't this kill the guy every round, given that the hook is never being removed?
Ugh, retyped it quickly in notepad... but I've never really messed with ULX so no idea if this would work, but I'd do it like this:
[CODE]
function ulx.slay( calling_ply, target_plys ,reason)
local v
for i=1, #target_plys do
v = target_plys[ i ]
end
if ulx.getExclusive( v, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
ulx.fancyLogAdmin( calling_ply, "#A has qued punishment for #T for ", v ,reason )
v.SlayQ = true
end
end
local slay = ulx.command( CATEGORY_NAME, "ulx slayq", ulx.slay, "!slayq" )
slay:addParam{ type=ULib.cmds.PlayersArg }
slay:defaultAccess( ULib.ACCESS_ADMIN )
slay:help( "Adds Target to slay queue." )
hook.Add("TTTBeginRound", "Kill SlayQ", function()
for k,ply in pairs(player.GetAll()) do
if IsValid(ply) and ply.SlayQ then
ply:Kill()
ply:ChatPrint("Punishment dealth from previous round")
ply.SlayQ = false
end
end
end)
[/CODE]
Mines probably a mess, but one thing to take note of is the usage of: ulx.fancyLogAdmin( calling_ply, "#A has qued punishment for #T for ", v ,reason )
This command sets up the use of chat prints for the admin commands, uses the system built into ULX so it will log to ULX files, print to whoever has permissions etc etc etc.
Actually yeah it does keep repeating, ill try Pantho's script.
*EDIT* Yes his script works fine with no repeats and the text works.
And also with the
[QUOTE="SaintSin6"]http://forums.ulyssesmod.net/index.php?topic=6279.0
There are already free releases with a command like this. Slaynr / Slay Next Round does exactly what you're talking about.[/QUOTE]
That addon has been dicontinued and I had problems with it as when I added someone to the slay queue it would simpy say "<player> will not be slain" and nothing would happen.
Sorry, you need to Log In to post a reply to this thread.