Game Development Community

Making a cheat system?

by Steve Howson · in Torque Game Engine · 11/01/2006 (1:17 pm) · 1 replies

Hi all!
I'm trying to make a simple cheat system that will bring up a dialog box, allow you to type the cheat and it will be activated.

Typical things like more ammo, 'God' mode, etc...

I'm pretty sure I can get it so the input gets written to a variable, then I check that for specific values and activate a funtion for the cheat.

What I'm not sure about is how to pass the player for the specific client to apply the cheat to.

Here's what I'm thinking:
- Send a command to server to get the client (passing in the cheat variable)
- Then pass the cheat variable and the client variable in command to client function that checks the variable and passes the client variable to a function that activates the cheat.

Am I close or totally off on that?

If that's how you do it, how do you then get the player from the client variable?
Is it something like %client.player?

Hopefully that makes sense and thanks a lot for any help.

#1
11/01/2006 (10:05 pm)
Ok I got it, in case anyone else is interested.
This is only for one cheat as that's all I'm doing for now because of testing.

I created a new server script called cheats.cs and in there is:
function ServerCmdcheater(%client, %code)
{
    if (%code $= "ammo")
    {
        %client.player.setInventory(SnowballAmmo, 100);
    }
    else
    {
        echo(%code);
    }
}

Then I created a new gui interface with a guiTextEdit control and a button. When the button is clicked it runs the following code:
commandToServer('cheater', cheatText.getValue());

I then set up a key in default.bind.cs to push the dialog:
function activateCheat(%val)
{
    if (%val)
        Canvas.pushDialog(cheat);
}

moveMap.bind(keyboard, semicolon, activateCheat);

That's it. Should be very easy to add multiple cheats and / or modify it for your own.

I hope that helps someone! :)

EDIT: I also submitted this as a code sample resource, don't know if it'll get approved though. ;)