Detect if cheats are on
Moderator: Moderators
Detect if cheats are on
I want to make my games detect if cheatmode has been enabled, and in case it is maybe not send any replays to the spring replays site. Is this possible?
I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?
Or is spads aware if this somehow?
I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?
Or is spads aware if this somehow?
Re: Detect if cheats are on
Don't think there is a callin. If you really want you could make your own in your widgethandler.
Don't know anything about spads.
Don't know anything about spads.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Detect if cheats are on
Just check Spring.IsCheatingEnabled when you need to know it? (In your case, at game over)
Re: Detect if cheats are on
What if someone enables cheats, gives 100 krogs and then disables cheats and continues to play?
Re: Detect if cheats are on
I don't see why you can't just do:
And then use it when you need to?
Stop premature optimization.
Code: Select all
local cheatingWasEnabled = false
function gadget:GameFrame()
cheatingWasEnabled = cheatingWasEnabled or Spring.IsCheatingEnabled()
end
Stop premature optimization.
-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: Detect if cheats are on
What if they cheat only while the game is paused? Then a game frame check would not detect cheats.
Re: Detect if cheats are on
I thought of checking if cheats are enabled after each time you press return. Is it possible to enable cheats without return? Maybe with new uikeys.txt it is with a keystroke.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Detect if cheats are on
You can send a /cheat from lua, of course whether it works depends on if you have permission to enable cheats.
Re: Detect if cheats are on
So the most fool-proof way would be to check this in gadget:Update(), then send to synced via LuaRulesMsg?
Re: Detect if cheats are on
Hm, didn't know you could do that when paused, i thought all commands would happen in the next frame, but guess not.
I'm not sure there is a safe way to do that then, the player could always do /cheat /give all /cheat in sequence by using one widget.
I'm not sure there is a safe way to do that then, the player could always do /cheat /give all /cheat in sequence by using one widget.
Re: Detect if cheats are on
Why check them in a fixed interval at all? You should ALWAYS check when you DO something.Jools wrote:I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?
Re: Detect if cheats are on
But in this case, the action is done after the game (upload replay, declare winner etc) and it is affected by what is done during the game. As others pointed out.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: Detect if cheats are on
This sounds like a valid feature request. Perhaps if nothing comes of it, you can solve it on the autohost layer by disallowing cheating unless the user enables an option. If the option is enabled, the replay is not uploaded. It's not a perfect solution, but probably less stressful than dealing with polling spring in the gadget level.
Re: Detect if cheats are on
In that case I would say catch the `/cheat` chat command. Problem is that, in contrast to mouse & key handling, Lua is not the first one who receives those. So make a feature request to make its handling consistent to the others.
Re: Detect if cheats are on
SPADS isn't directly aware of the cheat mode. But if you consider that the !cheat command is always used to enable cheats, then it can easily be made aware of it using a plugin. This is done in SPADS ZeroK plugin for example to prevent reporting games where cheats have been enabled:Jools wrote:Or is spads aware if this somehow?
Code: Select all
sub new {
my $class=shift;
my $self = { isCheating => 0,
[...]
}
sub onSpringStart {
my $self=shift;
$self->{isCheating}=0;
[...]
}
sub postSpadsCommand {
my ($self,$command,undef,undef,undef,$commandResult)=@_;
$self->{isCheating}=1 if($command eq 'cheat' && (! defined $commandResult || $commandResult ne '0'));
}