Announcement

Collapse
No announcement yet.

Serial

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serial

    Hi guys i am trying to add a serial to my software it locks after so many times run then asks for a serial to unlock i found this but i get an error "Error: attempt to call a table value stack traceback:
    1:[Menu -> On Preload] line 31 in main chunk


    -- Set the serial table up.
    serials = {}
    serials[1] = "CDKEY-00000-00001";
    serials[2] = "CDKEY-00000-00002";
    serials[3] = "CDKEY-00000-00003";
    serials[4] = "CDKEY-00000-00004";
    serials[5] = "CDKEY-00000-00005";

    -- Set the number of times allowed
    times_allowed_after_extension = 60;
    times_allowed = 30;

    -- Retrieve the number of times run and convert the value to a number
    times_run = Application.LoadValue("My Application", "Has Been Run");
    times_run = String.ToNumber(times_run);

    -- Calculate the number of allowed run times remaining
    times_remaining = (times_allowed - times_run)

    -- Check if this is the first time the application has been run
    -- Save the new number of times run value
    if times_run == 0 then
    Application.SaveValue("My Application", "Has Been Run", "1");
    else
    Application.SaveValue("My Application", "Has Been Run", (times_run + 1));
    end

    -- Check if the application has been run more times than allowed
    if times_run > times_allowed then
    sn = Dialog.Input("Program Expired", "This program has expired, enter your serial number to extend your trial period", "", MB_ICONQUESTION);
    for i, v in serials do

    if (sn == "CANCEL") then Application.Exit(); end

    if (sn == v) then
    Application.SaveValue("My Application", "Has Been Run", times_allowed_after_extension);
    end
    end
    else
    Dialog.Message("Trial Period", "You can run this program "..times_remaining.." more times.");
    end


    any help at all would be great

  • #2
    in AMS8, the for loop syntax has changed, you should now put:
    for i, v in pairs(serials) do

    Comment

    Working...
    X