dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Serial code varibles.

  1. #1
    Member
    Join Date
    Mar 2004
    Location
    uk
    Posts
    30

    Serial code varibles.

    In a game I'm making, I want to have the aboil for users to edit the vars of the game to create game levels, which puts the vars as a serial code; which could be used for players to send other people challenges ect

    E.G.

    if the user used the code

    111-222-333

    Vars would be

    Var1 111
    Var2 222
    Var3 333

    So basically I want to extract data from a code like that

    How would I go about doing that. (If I have to use other script types (eg php) as well, thats ok.)

    All I need is the code for extracting, I can do the code for generating the serial.
    i am your god

  2. #2
    Glorioso SLB
    Join Date
    Jan 2005
    Location
    Portugal
    Posts
    79
    for extracting use

    Code:
    code = "1111-2222-3333";
    var1 = code.slice(0, 4);
    var2 = code.slice(5, 9);
    var3 = code.slice(10, 14);

  3. #3
    Member
    Join Date
    Mar 2004
    Location
    uk
    Posts
    30
    Thanks now back to scripting lol

    (I've finished the game its self, I'm just making it look better and adding features such as that.
    Last edited by kangaro; 01-31-2005 at 02:12 PM.
    i am your god

  4. #4
    Senior Member
    Join Date
    Mar 2001
    Posts
    536
    How are you handling the serial number code?

    Will you have it emailed to the customer after purchase?

  5. #5
    Member
    Join Date
    Mar 2004
    Location
    uk
    Posts
    30
    It's just a thing so people can make custom levels. I've made a genarater that converts vars to a none understandable code.

    It first sets the vars out like so

    var1-var2-var3

    (all are nummbers)

    and then I use a code ( I put together) that encripts it into letters only. For example

    24-55-737

    would be somthing like

    BDKEEKGCG

    (I'm going to make the code a bit harder to understand latter.)



    and when the user puts the code in the game it unencripts it and then runs the slice code and works with the vars.
    i am your god

  6. #6
    Senior Member
    Join Date
    Mar 2001
    Posts
    536
    What do you use to generate the code?
    Do you have a php script example?

  7. #7
    Member
    Join Date
    Mar 2004
    Location
    uk
    Posts
    30
    All actionScrip.
    Heres the code for it.






    Functions used

    /* This a function someone made, I saw it some where and have found it usefull. */

    function searchAndReplace(holder, searchfor, replacement) {
    temparray = holder.split(searchfor);
    holder = temparray.join(replacement);
    return (holder);
    }

    Incripting
    ///////////////////////////////////////////////////////////////////////////
    //set your vars to one var called input

    code = input;


    code2 = code;

    //////////////////////// edit arrays to you specks////////////
    tofind = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "'", "-");
    toreplace = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L");
    i = 0;
    do {
    code2 = searchAndReplace(code2, tofind[i], toreplace[i]);
    i++;
    ////////set this to the amount of items in the arrays
    } while (i<12);

    Output = code2;
    and the result will be in the var output.


    Unincripting



    //set incripted ver to input
    code3 = input;
    tofind = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L");
    toreplace = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "'", "-");
    i = 0;
    do {
    code3 = searchAndReplace(code3, tofind[i], toreplace[i]);
    i++;
    } while (i<12);
    output=code3;

    Again the result will be in the var output.
    Last edited by kangaro; 02-25-2005 at 05:24 PM.
    i am your god

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center