well, i want to replicate a function from sourcemod for gmod, but for some reason its not working for me :(
this is the code i have got:
[CODE]
function mycommand( args)
PrintMessage(HUD_PRINTCENTER, "ADMIN: "..args)
end
concommand.Add("print",mycommand)
[/CODE]
i want "args" to be what comes after the cmd, like in "print "test"" , args would be "test"
but i gee the error
[CODE]
autorun/S_print.lua:2: attempt to concatenate local 'args' (a userdata value)
[/CODE]
can someone help me please?
concat args, and you gotta loop through all players and do player:PrintMessage
[lua]concommand.Add("print", function(ply, cmd, args)
if ply:IsAdmin() then -- Checks if the player is an admin
for _, pl in ipairs(player.GetAll()) do -- Loops through all players on the server
pl:PrintMessage(HUD_PRINTCENTER, "ADMIN: "..table.concat(args, " ")); -- Prints the args
end
end
end)[/lua]
Needs to go in [i][b]lua/autorun/server/[/b][/i].
Sorry, you need to Log In to post a reply to this thread.