Is it possible with a binary module to make "thirdperson" a non FCVAR_CHEAT command (sv_cheats required command) and make it admin only? If so, which module.
Thanks, help is appreciated. <3
I think it's this one that would help you:
[url]http://www.facepunch.com/showthread.php?t=729841[/url]
As for admin only, you would probably have to do that with lua.
[QUOTE=yakahughes;18194235]I think it's this one that would help you:
[url]http://www.facepunch.com/showthread.php?t=729841[/url]
As for admin only, you would probably have to do that with lua.[/QUOTE]
Any ideas on how? and thanks for the link.
Perhaps this?
[code]cvar2.SetFlags( cvar2.GetFlags("thirdperson") - FCVAR_CHEAT ) )[/code]
And then you could use [url=http://wiki.garrysmod.com/?title=G.engineConsoleCommand]engineConsoleCommand/concommand.Run[/url] to disallow non-admin use.
[QUOTE=Entoros;18194370]Perhaps this?
[code]cvar2.SetFlags( cvar2.GetFlags("thirdperson") - FCVAR_CHEAT ) )[/code]
And then you could use [url=http://wiki.garrysmod.com/?title=G.engineConsoleCommand]engineConsoleCommand/concommand.Run[/url] to disallow non-admin use.[/QUOTE]
I didn't mean how to make it a non-cheat command, I meant how to restrict it to admins only.
[url]http://www.facepunch.com/showthread.php?t=828945[/url]
Just add if not ply:IsAdmin() then return end into that and enjoy.
[QUOTE=Gbps;18194550][url]http://www.facepunch.com/showthread.php?t=828945[/url]
Just add if not ply:IsAdmin() then return end into that and enjoy.[/QUOTE]
I specifically want "thirdperson" not some custom addon. I want the original valve thirdperson. :|
[QUOTE=Helix Alioth;18194627]I specifically want "thirdperson" not some custom addon. I want the original valve thirdperson. :|[/QUOTE]
And how are you expecting to use a cheat command without making it non-cheat?
[QUOTE=Crazy Quebec;18194716]And how are you expecting to use a cheat command without making it non-cheat?[/QUOTE]
Read the thread.
Didn't you say
[quote]Is it possible with a binary module to make "thirdperson" a non FCVAR_CHEAT command[/quote]
?
[QUOTE=yakahughes;18194903]Didn't you say?[/QUOTE]
That's also what I read.
Yaka told me about cvar2, so I found out how to make it [b]non-cheat[/b]. Now I am asking "How do I make it admin only?".
[QUOTE=Entoros;18194370]Perhaps this?
[code]cvar2.SetFlags( cvar2.GetFlags("thirdperson") - FCVAR_CHEAT ) )[/code]
[b]And then you could use [url=http://wiki.garrysmod.com/?title=G.engineConsoleCommand]engineConsoleCommand/concommand.Run[/url] to disallow non-admin use.[/b][/QUOTE]
.
[QUOTE=Entoros;18194980].[/QUOTE]
Didn't see that but how would I use it to block the command?
[QUOTE=Gbps;18194550]Just add if not ply:IsAdmin() then return end into that and enjoy.[/QUOTE]
.
[QUOTE=yakahughes;18195113].[/QUOTE]
I know but how? I mean How the fuck do I use this "engineConsoleCommand"?
[url]http://www.facepunch.com/showthread.php?t=791247&highlight=engineConsoleCommand[/url]
OR
[url]http://www.facepunch.com/showthread.php?t=836990&highlight=engineConsoleCommand[/url]
mk, done. Let me test this out...
[editline]02:45AM[/editline]
[code]
if (SERVER) then
require("cvar2")
cvar2.SetFlags( cvar2.GetFlags("thirdperson") - FCVAR_CHEAT ) )
AdminOnlyCommand = {}
AdminOnlyCommand[1] = {cmd = "thirdperson"}
newEngineConCommand = engineConsoleCommand
function engineConsoleCommand(ply , cmd , args)
for k , v in pairs(AdminOnlyCommand) do
if cmd = v.cmd then
if (!ply:GetNWString( "colz_usergroup" ) == "respected" or !ply:IsAdmin()) then
ply:PrintMessage( HUD_PRINTTALK, "You must be Respected or above to use thirdperson!" )
return end
else
newEngineConCommand(ply , cmd , args)
end
end
end
end
[/code]
Not working.. Hmmm..
I can't see whats wrong with that code.
if (SERVER) then
require("cvar2")
cvar2.SetFlags( cvar2.GetFlags("thirdperson") - FCVAR_CHEAT ) )
AdminOnlyCommand = {}
AdminOnlyCommand[1] = {cmd = "thirdperson"}
newEngineConCommand = engineConsoleCommand
function engineConsoleCommand(ply , cmd , args)
for k , v in pairs(AdminOnlyCommand) do
if cmd =[highlight]=[/highlight] v.cmd then
if (!ply:GetNWString( "colz_usergroup" ) == "respected" or !ply:IsAdmin()) then
ply:PrintMessage( HUD_PRINTTALK, "You must be Respected or above to use thirdperson!" )
return end
else
newEngineConCommand(ply , cmd , args)
end
end
end
[highlight]end[/highlight]
Obvious errors are obvious.
[editline]09:43PM[/editline]
Next time, read the errors in console before assuming it doesn't work and only we can fix it.
[editline]09:43PM[/editline]
Lua is known for having errors that actually make sense to the average person
[sp]Unlike C/C++[/sp]
[lua]
function engineConsoleCommand(ply , cmd , args)
for k , v in pairs(AdminOnlyCommand) do
if cmd == v.cmd then
if not(ply:GetNWString( "colz_usergroup" ) == "respected" or ply:IsAdmin()) then
ply:PrintMessage( HUD_PRINTTALK, "You must be Respected or above to use thirdperson!" )
return
else
newEngineConCommand(ply , cmd , args)
end
end
end
[/lua]
Learn to fix errors properly before criticizing, some of them aren't that obvious.
Adding and "end" at the end of the file wouldn't work, as the mistake is "return end", which makes no sense at all here.
A common mistake is to think "return end" ends the function, because a lot of coders write if conditions that look like this:
[lua]if condition then return end[/lua]
The only part which really tells Lua to exit the function is "return", the "end" part belongs to the if ... then block.
The second mistake Gbps pointed out is right though. Don't get confused between = and ==. = is an affectation operator, basically, "a=1" means "set the value of a to 1". == is a comparison operator, which means that "a==1" is true if a is equal to 1, and false else.
Another mistake which isn't so obvious is the condition you are using for checking if the player is an admin or a respected user.
Your condition means "if the player is not a respected user, or if he is not an admin then". Now think of it, this condition will always be verified. If the player is a respected user, he is not an admin, and the result will be true. If the player is an admin, he is not a respected user, and the result will be true. It will be false ONLY when the player is both an admin and a respected user.
So the right condition that you should be using is "if the player is neither a respected user, nor an admin", which is basically the negation of "if the player is a respected user or an admin". See the difference?
Also, for fuck's sake, use Lua syntax, because it's fucking Lua. It just pisses me off when people can't make the difference between C and Lua syntax. I know Garry modified Lua so C syntax is supported too, but it's still fugly and unfitting, Lua is Lua, and C is C.
[lua]
function engineConsoleCommand(ply , cmd , args)
for k , v in pairs(AdminOnlyCommand) do
if cmd == v.cmd then
if not(ply:GetNWString( "colz_usergroup" ) == "respected" or ply:IsAdmin()) then
ply:PrintMessage( HUD_PRINTTALK, "You must be Respected or above to use thirdperson!" )
return end
else
newEngineConCommand(ply , cmd , args)
end
end
end
[/lua]
This just shows how much tabs are important. The line [lua]if not(ply:GetNWString( "colz_usergroup" ) == "respected" or ply:IsAdmin()) then
ply:PrintMessage( HUD_PRINTTALK, "You must be Respected or above to use [/lua] was being closed by the return end, but the end wasn't on a new line, and the return had no semicolon. I almost thought that was an error like you, Killburn, but I decided it would come out with no error. I believe that would work just fine, even though it's very ugly.
You're all being idiots. Thirdperson is a clientside command and so must be run clientside.
We're running it clientside, durd te dur
[QUOTE=Gbps;18203357]We're running it clientside, durd te dur[/QUOTE]
[code]
if (SERVER) then
[/code]
No, herp a derp. That guy is actually right.
Wow, I would assume someone would have pointed that out around 5 posts ago, but apparently we're too stupid. :v:
Thanks Gbps
Sorry, you need to Log In to post a reply to this thread.