Game Development Community

Deleting ".cs" files leaving ".dso" files through script

by Andrew H · in Torque Game Builder · 08/09/2011 (1:10 pm) · 6 replies

I am going to save my player profiles in a ".cs" file. Then I am going to execute it and delete the ".cs" file, leaving only the ".dso" file - thus preventing clever players from cheating by editing the file. Is there any way to delete a file through code?

#1
08/09/2011 (9:53 pm)
just take whatever file you are using for a save (.cs .txt .xml) and encrypt the data. I personally do an rsa encrypt on my player saves

Here is a nice happy GPL source for you to look at if you decide to go down this road
http://code.google.com/p/rsa/


If you just want to delete the file then check out this thread
http://www.garagegames.com/community/forums/viewthread/72728
it will help you delete files and folders
#2
08/10/2011 (7:53 pm)
I am also interested in ways of protecting saves, and I bet this is an extremely silly question, but would I be able to build that into my game, and would that work on a mac build of the game?
#3
08/10/2011 (8:14 pm)
@Justin, I haven't tried it, but I have a feeling that if you did it in this fashion - with TorqueScript - it would work just fine on both systems.
#4
01/06/2012 (11:55 am)
fileDelete(filename);
#5
01/06/2012 (12:15 pm)
I'll take advantage of the necro to throw out this suggestion. A better method than exec'ing the .cs you write out, as the information you just saved out is likely already loaded, you can use compile() instead. This way you avoid any potential problems if you're doing this all in datablocks.

Here's some pseudo code as an example:

if(compile("somedirectory/savedplayerprofile.cs"))
{
    //File was successully compiled, source script can now be safely deleted
    fileDelete("somedirectory/savedplayerprofile.cs");
}
#6
01/06/2012 (2:02 pm)
Oh, yeah. That looks like it would work a lot better. Thanks.