Life python script

Is it possible to have a live python script that is constantly updating a number onto a online database without performance loss. I have the script to update to the database but I’m unsure how to make it live without a performance loss.

The number is experience points and if these points are not constantly updating then the game will have problems with hacking/cheating issues.

Thanks, bearmey

Any script that’s constantly running will affect performance, particularly if it’s a slow script. One way would be to optimise the script and have it run occassionally, such as once a second, rather than constantly, you’ll still have a performance cost, but might not be as high. Alternatively, use another method to prevent hacking/cheating and only update the experience points on the database when they change.

EDIT: if you’re using python to update a database then I can’t image that it would be hard to cheat if the player knew a little python through altering the updates.

Database access is (like fileaccess) because of its nature slow.
As battery wroter avoid permanent accessing it. It makes no sense at all.
If you want to prevent cheating, you could send encrypted data.

other ways are:

  • plausibility checks (e.g is it plausible to get 1000 Points in 1second)
  • server stored data

If you are aiming for a multiplayer game, you need to implement a verification anyway. In case of two game instances calculate different results, you need an algorithm to decide what the final result should be. Here you can add the plausibility checks (if there is to much difference == suspiciuos data)

I hope it helps

@battery - If the file used is a compiled Python file (.pyc), then the Player won’t be able to see the ‘stream’ happen - the code will be unalterable (I guess they could de-compile the code file, though).

I think Monster raises a good point - rather than have constant access, it might be better to simply check to see if the ‘proposed’ amount of points attained is plausible. If it isn’t, check them out.

Thanks so much for the tips. The script I have go’s to a webpage and retrieves the info that way. I found it to be the safest and fastest way to send or retrieve skills.