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

Similar Messages

  • 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.

  • Creating High Score With loadMovie

    Hey,
    I'm trying to make a high score log for a bunch of flash
    games on my site. THe game I'm working on is called Double Wires.
    The ways I'm doing it is my loading the game into a seperate flash
    file using loadMovie, and in the flash file having a little box
    where the user can type in his name and submit his score. The mySQL
    part is not the problem. My problem is that I can't get the box
    where the user types in his or her name to appear on top of the
    game, so the user can actually see the box. So far my code for
    loading the main game swf is this:
    loadMovie("doublewires_main.swf", this);
    I have that code on frame one of layer one, and I have, on
    the layer above it, the box where the user's name is displayed.
    I have other highscore logs functioning, I just can't get
    this one to work. Here's an example of a working one:
    http://www.wintallo.com/highscores/tetris/tetris.php
    Thanks for the read! If you have any questions about... my
    question, please post a reply!
    -Joel
    Wintallo

    you're replacing your main swf with doublewires. create a
    target movieclip and load your game into the target.

  • Showing high scores with showMessageDialog

    is it possible to do so?
    i mean i tried doing this
    JOptionPane.showMessageDialog(null, "Name Score\n"
                                                                +"====== =======\n"
                                                                for(int i=0; i < scorename.size(); i++)
                   pname" "+score+"\n";
                   }                                        +"\n");
    its expecting a ')' in the second line somewhere!
    i dunno y it doesnt like it...can ne one help out? or suggest ne thing else?
    thanks

    hi there (again),
    assuming your names and scores are the Player objcts in a vector:
    (This is for a start, the layout will not be very nice.)
    String table ="Name Score\n"+"====== =======\n";
    for(k=0; k< v.size(); k++){
      Player p = (Player)v.elementAt(k);
      table = table + p.name + ": " + p.score+ "\n";
    JOptionPane.showMessageDialog(null, table);HTH

  • 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

  • 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.

  • 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

  • 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 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?

  • Online high score list

    Hi guys,
    I was wondering how I could implement a high score list into a java applet game i wrote. The logic isnt what im worried about, its writing to a file that is on a server that i dont own. It's my school's webspace...do i have access to do this?
    If I dont have access, how would I do this, there are tons of online games with high score lists, so how do they do it?
    Appreciate the help,
    Brian

    Only you would know if you have the permission to do this!. BTW you cannot write to a file from an Applet unless it is signed.
    What I would do if I wanted to do this is, Create a webpage that has access to write to a file or database, then inside my applet use a HttpURLConnection to call this webpage with the paramaters passed along the query line:
    http://www.yourHost.com/TopScores?name=Gary&score=12345

  • 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.

  • 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.

  • 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

Maybe you are looking for

  • Getting K7T Turbo limited edition what is the fastest processor it will run

    As the subject sugests my friend is about to give me his motherboard, ram and cpu the motherboard is a K7T Turbo-R (I'm assured this is the limited edition one) but he only has a slow old 1ghz processor on it. I've looked at the bios upgrades and I'm

  • Multi Mapping : How to get Message count after splitting

    Hi all, I am following below blog. /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi Can any body please tell me how to get the count of messages generated after splitt

  • How do I export a Keynote 09 presentation to work with Adobe Connect??

    Hi - I have imported the .MOV file from keynote into Flash and then exported it as a .FLV file but the problem is that all of my 'on click' build requests have disappeared so it just plays as one continuous movie. Can anyone help me please? It seems

  • SAP Portal J2EE logon groups

    Please can you help. Within ABAP you can go into SMLG and configure logon groups so you can separate user groups to particular application instances. I would like to do the same within NW Portal and CE.  We have external and internal users accessing

  • Security Camera / DVR

    Trying to monitor my security camera on my dvr,-all mobile apps work fine but can't seem to get mac / SMS to connect with all the same settings,any other software for Mac for dvr monitoring,-running OSX Lion 10.7.5 ? Thanks Joe P.