High Score and Applet

Dear All,
I'm trying to put a high scroe system in my applet (game). Therefor I would like to write a file (that is located on my ftp server) were I can save the scores. But how do I acces that File ? With an aplication it's easy, but applet doesn't do it (not even offline) I have thought about the following solutions:
1) Direct acces file and change it (read, change,safe)
2) Download the file to temp directory of user en edit is en then upload it trough FTP
3) Save the high scores in a database ?
I get the following error if I try to use the same code as in a application:
java.security.AccessControlException: access denied (java.io.FilePermission highscore.txt write)
     at java.security.AccessControlContext.checkPermission(Unknown Source)
     at java.security.AccessController.checkPermission(Unknown Source)
     at java.lang.SecurityManager.checkPermission(Unknown Source)
     at java.lang.SecurityManager.checkWrite(Unknown Source)
     at java.io.FileOutputStream.<init>(Unknown Source)
     at java.io.FileOutputStream.<init>(Unknown Source)
     at java.io.FileWriter.<init>(Unknown Source)
     at Bestandentest.init(Bestandentest.java:24)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Please Help me

@ zadok : If I use this I can nog save other players
there high scores.You would still need to send it back to the server see DrLaszloJamf 's post. The advantage here is that you could make changes to the format of the table and not have to change to program.
@Dr : I want a global high score for the game and
keep it on my server. In a file or database. Because
I thought I couldn't save it in an applet. A cookies
doesn't solve the problem here unfornutlyI think that is what he is saying.
>
Whats's a servlet ?Google.

Similar Messages

  • High Score with Applets

    Well, I'm currently in a 'gaming club' at my high school. We are a small group of about 10-12 people that enjoy playing and designing games. Recent accomplishments consist of Battleship, Snake, Airhockey, and a few other minor 3D games.
    As of late, we wanted to take it to the next level. We'd like to put these games on a website in applet-form for everyone to enjoy and comment on. To do this, we'd like to implement a high score count to see who is the best at these games. However, when we tried to do this we ran into a security error. Aparently applets can't write to files. Is there any way around this? Any help would be greatly appriciated. Much thanks.
    - Sange

    Set up a php database. You can communicate between it and your Applet. That's how I do it on GameLizard.com

  • High Score Security

    Hi I recently made a game(dosen't really matter what kind) in which the user gets a score and saves the score to my high score table.
    I do this by connecting to a .php page and passing the score and name variables on to it. (www.random.com/blablabla.php?name=bla&score=676) The page then opens the mySQL table and saves the high scores. THe page is opened from within the applet and the user dosen't see the page opening.
    The problem I am having is security, and i'm trying to make it so that nobody can access that php page from their browser and input whatever score they want and what not. THis was brought to my attention by my friend who put images(none rude) and hyperlinks allover my high score page. He was nice enough to tell me so now I am trying to fix it.
    THe first steps I took were to not package the source code with the jar(which he downloaded and extracted). But even then I could decompile the class file and search the file for ".php" and easily know what url to type into the browser to input any score for my game. I then tried using an obfuscator, ProGuard, which didn't help me much. It only renamed all the classes and variables, but the String I open for the high score I still very easily visible. Also from other people I got the general opinion that they(obfuscators) aren't much good as they only make it slightly harder to people to get the information, not make it impossible.
    Basically what I want to do is to make it as hard as possible for people(namely my friend...) to find out the page which saves the high scores, and type it into their browsers so they can input whatever high score they want. Obfusticating didn't help much and now I am running out of ideas. I was thinking about:
    Making sure the thing that oppened the page is an applet, but I'm not sure how to do this. This would be my ideal solution as I am not too worried about people who would go out of their way to make an applet with the same name as mine just to "hack" my high scores which aren't even worth hacking. But how would I go about doing this?

    You could do this using a client/server system comminicating using sockets, rather than simply a HTML request sent from the client. This way the client could be required to provide some validation before the server accepts score updates from it.
    The trick is to decide how the validation is done; you need to be able to differentiate between genuine clients and a client your friend has decompiled and changed so he can cheat.
    Remember that your friend can see exactly how the client works, but cannot see how the server works. Maybe you could send a copy of the client class object to the server and then the server could checksum it?

  • Hosting a server for simple game related info, rankings, high scores, etc.

    I have a quick question about servers. I want to implement a ranking system for one of my games, the server would store player high scores and world rankings based on their score and perhaps other fairly easy stuff. Writing the server and communicating from
    it with the app is the easy part in my mind, ive done it numerious times for personal projects (Like a Raspberry PI based quadrocopter i wrote). My question is this. If i wrote the server where do i host it? How do people typically host their servers that
    are simple like this? Do they get a static ip address and host it from a extra computer in there homes? Im not talking about big corporations like microsoft that have large server centers, just individual developers like me.  Any thoughts?
    thank you for your time.

    Yes, the server  app runs on the machine it is hosted on.
    See http://azure.microsoft.com/en-us/documentation/services/mobile-services/ to get started with Azure Mobile Services.
    If you want to write a web service yourself from scratch you'll need to pick your technology and look for documentation there. It's off topic in this forum, but check out http://www.asp.net/get-started and the http://forums.asp.net/ forums for asp.net.
    --Rob

  • I bought a new Iphone 4s and when I sync my apps over I lost all of my high scores. How can I get back my high scores as I do not want to start all over on some of the games

    I bought the new Iphone 4s. I backed up my old 3gs on Itunes store before trading in my old Iphone. I sync my new phone and I have all of my apps but non of the high scores. For example I played all of the angry birds and had three stars on all levels. Now I have the app on my Iphone but I am back no levels completed. How do I fix this problem. My Itunes store is on a PC running Windows 7

    Under the answer you want to mark as correct you should see a box that says Correct with a green symbol to the left and a box with Helpful with an orange star to the left. Click on the one you want.
    And thanks for thinking about that, it is appreciated.

  • High Score Table: Writing a Simple Text File with Flash and PHP

    I am having a problem getting Flash to work with PHP as I need Flash to read and write to a text file on a server to store simple name/score data for a games hi score table. I can read from the text file into Flash easily enough but also need to write to the file when a new high score is reached, so I need to use PHP to do that. I can send the data from flash to the php file via POST but so far it is not working. The PHP file is confirmed as working as I added an echo to the file which displayed a message so I  could check that the server was running PHP - the files were also uploaded to a remote server so I  could test them properly. Flash code is as follows:
    //php filewriter
    var myLV = new LoadVars();
    function sendData() {
    //sets up variable 'hsdata' to send to php
    myLV.hsdata = myText;
    myLV.send("hiscores.php");
    I believe this sends the variable 'myText' to the php file as a variable called 'hsdata' which I want the php file to write into a text file. The mytext variable is just a long string that has all the scores and names in the hiscore. OK, XML would be better way of doing this but for speed I just want to get basic functionality working, so storing a simple text sting is adequate for now. The PHP code that reads the Flash 'hsdata' variable and writes it to the text file 'scores.txt' follows:
    <?php
    //assigns to variable the data POSTed from flash
    $flashdata = $_POST["hsdata"];
    //file handler opens file and erases all contents with w arg
    $fh = fopen("scores.txt","w");
    //adds data to file
    fwrite ($fh,$flashdata);
    //closes file
    fclose ($fh);
    echo 'php file is working';
    ?>
    Any help with this would be greatly appreciated - once I can get php to write simple text files I should be ok. Thanks.

    Thanks for your help.
    I have got Flash working to a certain extent with PHP using loadVars but have been unable to get flash to receive a variable declared in PHP. Here's my Flash code:
    var outLV = new LoadVars();
    var inLV = new LoadVars();
    function sendData() {
    outLV.hsdata = "Hello from Flash";
    outLV.sendAndLoad("http://www.mysite.com/hiscores/test23.php",inLV,"post");
    inLV.onLoad = function(success) {
    if (success) {
      //sets dynamic text box to show variable sent from php
      statusTxt.text = phpmess;
    } else {
      statusTxt.text = "No Data Received";
    This works ok and the inLV.onLoad function reports that it is receiving data but does not display the variable received from PHP. The PHP file is like this:
    <?php
    $mytxt =$_POST['hsdata'];
    $myfile = "test23.txt";
    $fh = fopen($myfile,'w');
    //adds data to file
    fwrite($fh, $mytxt);
    //closes file
    fclose ($fh);
    $mess = "hello there from php";
    echo ("&phpmess=$mess&");
    ?>
    The PHP file is correctly receiving the hsdata from flash and writing it to a text file, but there seems to be a problem with the final part of the code which is intended to send a variable called 'phpmess' back to Flash, this is the string "hello there from php". How do I set up Flash and PHP so that PHP can send a variable back to Flash using echo? Really have tried everything but am totally baffled. Online tutorials have given numerous different syntax configurations for how the PHP file should be written which has really confused me - any help would be greatly appreciated.

  • So i have created a quiz with scoring and stuff but now i want to make a high score system just for one user any ideas?

    The questions each have a invisible dynamic text box that when the right answer is pressed it goes up by one and at the final score page i have a dynamic text box which has a simple code which adds the contents of these invisible text boxes, so i need a code which would use another dynamic text box which will hold the high score of the player, all i need is a one player and session cookie high score system any ideas anyone? (this is action script 2 BTW)

    you can use the sharedobject if you only want each user to compare their own scores.

  • High score in an applet

    I wrote a game and I'd like to be able to implement a high score. I've alreaedy looked at the other posts for the same problem, and it looks like I have to do it using PHP and SQL. I've looked at PHP sample code and I think I understand how to get that to work. My question is how do I create the database in mySQL? Everywhere I look, it just says to type certain commands in to create the database, but what confuses me is where do I type the commands? Is there a program I need to download? Do I do it on command line?
    Thanks - Any help would be greatly appreciated

    I think it's
    mysql -p That'll prompt you for your password, and you should be in the shell (assuming that the user you're logged in as is a valid user for mysql--otherwise use -u I think).
    Once you're in, you should use the CREATE DATABASE SQL statement to create the database (look at the mysql ref). You can then use CONNECT databaseName to connect to your database, or, from the command line, use
    mysql -p databaseName However, I agree with coder that there may be better alternatives, especially if it's already a Java game.
    Edited by: endasil on Oct 21, 2007 7:34 PM

  • How can I make a high scores list?

    I've heard a lot of options. I've tried writing to a perl script, I've read about signing an applet (which seems needlessly complicated). I just would like to know what is the easiest way to save a list of 10 high scores for a game that I'm making? If anyone out there has tried this already any advice would be REALLY appreciated
    thanks!

    What I'm trying to do is make just a high scores list for the game as a whole. It will be one high scores list of 10 names/scores that will be there for the applet. I already have everything set up to read the scores and order the scores in the program, i just need to know what the best way to save them permanently for the next time they need to be used is. I have the scores saved in a string array and I could write all the code myself to get those strings set up in whatever format I may need. But I just need to know how to save them once the applet is closed.

  • Saving High Scores

    Hi,
    I have a written a small game as a Java applet. I would like to add the ability to store high scores in a database on my webserver. I was thinking of calling some PHP script which I have written which would handle the server side task of adding the score to the database. But I'm having difficulty calling the script and passing some basic parameters such as username, score from the applet. Can anyone please point me in the right direction. Some code examples would be great.
    Thanks in advance for any help,
    Raz

    <applet
       code="Game.class"
       archive="game.jar"
       codebase="/games/Game/"
       name="Game Name"
       width="300"
       height="400">
       <param name="username" value="Bob">
       <param name="game" value="GameName">
    </applet>You can pass data like that, which you can easly set up with your database. That's how I manage saved games and scores on my games. If you pass "-1" for the username if the person hasn't signed in, you can use this code:
    public Score(Applet applet, boolean isDebugging) {
         DEBUG = isDebugging;
         user = applet.getParameter("u");
         game = applet.getParameter("g");
         if (user == null || user.equals("-1"))
              canScore = false;
         else     canScore = true;
    }That's the constructor I use for my score class.
    url = new URL("http",v"www.siteaddress.com", "/dbcodefilename.php");
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    PrintWriter out = new PrintWriter(connection.getOutputStream());
    out.println("u=" + user + "&g=" + game + "&s=" + score);
    out.close();
    InputStream in = connection.getInputStream();
    byte[] b = new byte[in.available()];
    in.read(b);
    response = new String(b);And you can use that code to pass the info you're wanting to pass.

  • High Score Lists

    I am new to Java--I started learning about 2 weeks ago. I have just programmed my first game in Java, but I don't know how to make a high score list. As of now, during gameplay, the game keeps track of the user's score like this:
    g.drawString("Score: " + GameState.cur.tailLength*10, 25, 30);GameState is a class. cur is an instance of GameState.
    tailLength is an integer variable that keeps track of how long the tail is (the game is a snake game, where you eat food and your tail grows & scoring is 10 pts per food eaten).
    If anyone has any ideas for how to make a high score list inside the java applet, I would greatly appreciate it.

    You're going to need to store previous game scores somewhere (start with an ArrayList) when each game has ended. Then, you can draw then whenever you want to. Later on you can store the scores in a file or even a database.

  • How can you get back a lost high score after a partial sync?

    I was playing a Temple Run game, which I was currently getting a high score on, when I plugged it into my computer to charge. Since it was the first time I had plugged it in, the Mac asked me to do some stuff. After my iPod started to sync, everything was fine. I then had to leave, so I ejected it and left. It kept syncing until I was out of the wi-fi range and down the road. I go into Temple Run, and find my game I was playing gone. The coins weren't added, and the high score wasn't even updated. When I came home, I tried syncing it again, and the info still didn't come back. Is is possible to regain the data back? I just really want the 7 million high score back...

    Try restoring from backup.  If yu did not backup since you messed up, restoring from backup should get you back to when the backup was made. Got to iTunes>Preferences>Devices and check the box that says "Prevent iPod...syncing" otherwise when you connect, a backup will be made that does not contain the info you want.

  • Flash Game High Scores Board

    Hello everyone,
    I know this is a subject that gets covered a lot as i have found a ton of tutorials that show a million dfferent ways to create a high scores board on a flash game.  So i decided to go out on a limb and pick a tutorial out to try.  Well I have now tried 3 different ones and have yet to get a working high scores board with my game.
    http://www.flashkit.com/tutorials/Games/How_to_c-Nick_Kuh-771/index.php
    That is the link to the most recent attempts to creat my high scores board.  When i finished everything the way the tutorial said it seemed like everything would work and then it just didnt.  After spending oh about 40 plus hours trying to make a high scores board i am getting very frustrated.  My game is scripted in AS2 and i have access to mysql and can set up unlimited databases.
    Can anyone please help me by sending an easy to follow tutorial that will work with AS2?  I would just like any kind of help right now as I feel ALL of my valid ideas have been ehausted.  Thanks in advance to anyone that can help!
    kapelskic

    Okay not a problem.
    This is my code on the very first frame of the game that initializes the the highscores.php script
    command = "init";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    This is the code that I have on a submit button, next to the input text box where the user enters their name for the scoreboard.
    on (release) {
    if(name ne ""){
    command = "update";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    gotoAndStop ("highScores");
    In every place the code says _root. I have also tried this. and neither of them work.  I have also tried a million other things.  So far the game plays through, goes to the game over screen where it asks for a user name and tells them their score.  Then once they press submit the game goes to the highScores screen but the name and score are not there.  The high scores screen cosists of 2 dynamic text fields one named "players" and one named "scores".  I hope this helps because I spent another 5 or so hours after my initial posts trying more tutorials with still no luck.  (the problem i am having is that i am new to flash, however not to PHP)
    kapelskic

  • Keeping a high score

    I'm not sure whether to put this topic here or on the game section, so forgive me if it's not supposed to be here. Just like the title says, I'd like to keep simply one high score. I'd like to write it into a file (along with the name of the person who holds the high score). I simply do not know what to do, I will post what I have so far (it's just a piece of a bigger class):
    public void openFile(){
              BufferedReader file;
              try
                   file = new BufferedReader (new FileReader ("data.dat"));
              catch (FileNotFoundException e)
                   System.out.println("File not found.");
              try
                   int highCombo = file.read();
                   if(MovingBar.p1Hits > highCombo && MovingBar.p1Hits > MovingBar.p2Hits){
                        JOptionPane.showMessageDialog(null, "Congratulations! Player 1 has beat the high score of " + highCombo + " hits with " + MovingBar.p1Hits + " hits!", "Congratulations!", JOptionPane.PLAIN_MESSAGE);
                        String name = JOptionPane.showInputDialog("Enter your name:");
                   if(MovingBar.p2Hits > highCombo && MovingBar.p2Hits > MovingBar.p1Hits){
                        JOptionPane.showMessageDialog(null, "Congratulations! Player 2 has beat the high score of " + highCombo + " hits with " + MovingBar.p2Hits + " hits!", "Congratulations!", JOptionPane.PLAIN_MESSAGE);
                        String name = JOptionPane.showInputDialog("Enter your name:");
         }I know there are a lot of random pieces of info, but more importantly, MovingBar.p#Hits is a variable in another class which I want to keep as a high score if it is one. highCombo is the current high score (hopefully read from the file data.dat which is simply a text file). I pretty much scrounged this code up from random places so I really dunno exactly what I'm doing. Also, I realize that I'm missing something from the last "try" statement and I don't know what to put. I'm sorry if this is confusing and amateur, but I really need some help. Thanks in advanced.

    Hi
    Create one class that want to be Serializable and implements the Serializable interface on it, then you can serialize the Whole object at once..........
    // Write to disk with FileOutputStream
    FileOutputStream f_out = new
         FileOutputStream("myobject.data");
    // Write object with ObjectOutputStream
    ObjectOutputStream obj_out = new
         ObjectOutputStream (f_out);
    // Write object out to disk
    obj_out.writeObject ( myObject )
    // Read from disk using FileInputStream
    FileInputStream f_in = new
         FileInputStream("myobject.data");
    // Read object using ObjectInputStream
    ObjectInputStream obj_in =
         new ObjectInputStream (f_in);
    // Read an object
    Object obj = obj_in.readObject();
    Regards
    Vinoth

  • Help with online high scores

    I'm working on a marathon runner game ( http://www.locopuyo.com/MarathonRunnerBeta1.zip ) just for the fun of it. What I am wondering is what the best way to make a high scores list would be.
    I have mySQL on my server, I don't know if that is the best way to do it though.
    I don't know at all how to connect files on the internet with java.
    I was thinking it might be easier if I just had a plain html web site that I could edit in my java program using ftp, but I don't know how to do that and dont' even know if it is possible.
    Any help would be much appretiated.

    since you have MySQL on your server, I'm going to go ahead and assume you have PHP installed also. If so, you can do the highscore work in PHP and just have the game query that script. Basically (if you know anything about PHP and web queries in general) you just query the URL of the PHP script with a few GETVARS. In the simplest (and most easily hacked) way is something like:
    http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000highscore.php (your script) would then use MySQL to store the data of the GETVARS ($action,$name, and $score).
    All you need in Java to query this script is the URL class.
    URL url = new URL("http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000");
    url.openConnection(); // this is where it is queriedhighscore.php is where you need to do your database work. If you don't know anything about PHP or if this sounds too easily hacked, you might look into connecting to MySQL via JDBC (see tutorial)
    If I find the time I can make a simple template for you to build off of

Maybe you are looking for

  • Connection leaks and application is running out of connection

    Hi All, We have configured the SQL Database external resource for OBPM specific connection pool. All the business processes are using the Fuego.Sql package for the data base transaction calls. I have no clue how this package is managing the database

  • Hp f4580 printer stopped working with Microsoft Surface RT 2

    Have just bought a Surface RT2 (Windows 8.1 RT is the operating system).  It recognised my HP Deskjet F4580 all in one printer fine at first, but now does not.  First it showed it as off line, so I followed Microsoft advice and removed the device fro

  • Adding Root Element

    Hi I have an existing structure in XML <article> <text> </text> </article> Here the element article is holding the content and is associated with the text frame. I would like to modify the structure to <Root> <article> <text> </text> </article> </Roo

  • Does anyone know why the Setting NAME & DESCRIPTION fields are grayed out?

    Hi, I'm using Compressor 3.0.5 and it works fine, except that I cannot reach the Settings "Name" or "Description" fields to alter them. As I'm going about finding the perfect setting for whatever application I need, I'd like to change the name and de

  • Automatic Non-Breaking Hyphen

    Hi, Is there a way to make InDesign CS5.5 to automatically use a non-breaking hyphen when I paste a bunch of text with regular hyphens in it? Or, is there a way to tell it to treat a regular hyphen in the middle of the word as if it were a letter; th