• Running IsAdmin() on RCon (or something similar)?
    5 replies, posted
I downloaded [url=http://www.garrysmod.org/downloads/?a=view&id=62671]this awesome Ravebreak script[/url], and tried to run it though RCon with HLSW. I get this Lua error: [code]20:14:28 autorun/rave.lua:18: attempt to call method 'IsAdmin' (a nil value)[/code] So I looked at it, and saw that the script was trying to check if RCon was an admin. Now, I'm not very good at Lua, but even I know the problem here. [lua] function RaveCommand( pl, cmd, args ) if pl:IsAdmin() then if not Raving then RaveBreak() else pl:ChatPrint("You're already raving dude!") end end end [/lua] Is there a way to recode this function so that the console command works with RCon?
I think ply:IsValid() returns false if you're in RCON
[QUOTE=iRzilla;19097882]You shouldn't really be adding these checks to see if it's RCON as it can be exploited by calling commands before the player has loaded. But this script couldn't cause much harm. [lua] function RaveCommand( pl, cmd, args ) if !pl:IsValid() | pl:IsValid() & pl:IsAdmin() then if not Raving then RaveBreak() else pl:ChatPrint("You're already raving dude!") end end end [/lua] Should work I suppose.[/QUOTE] I think you meant to write || and && not | and &.
[QUOTE=iRzilla;19097882]You shouldn't really be adding these checks to see if it's RCON as it can be exploited by calling commands before the player has loaded. But this script couldn't cause much harm. [lua] function RaveCommand( pl, cmd, args ) if !pl:IsValid() || pl:IsValid() && pl:IsAdmin() then if not Raving then RaveBreak() else pl:ChatPrint("You're already raving dude!") end end end [/lua] Should work I suppose.[/QUOTE] Is there any way to check if they have the proper rcon password, and then go ahead and allow the rest of the function to run?
Sorry, you need to Log In to post a reply to this thread.