Enter the serial number every time
-
Hi, I tried this serial number code that worked well for me, but when I export the plugin, every time I opened the plugin, I was asked to take the serial number. Can anyone help me?
const var serials = { "Data": [ "O83X-AT20-040F-8MJ5", "K0XE-06PP-31T0-5EUM", "8B6P-57Y5-8D1M-NYY7", "6BPO-6YAN-QE85-AH4M", "1HP8-6XKO-K3TS-WU2V", "L0Q5-T56B-7VHW-ED11" ] }; // 2. Main authorization system namespace Authorisation { const var SerialInput = Content.getComponent("SerialInput"); const var Description = Content.getComponent("Description"); const var SerialStateLabel = Content.getComponent("SerialStateLabel"); const var AuthorisationDialogue = Content.getComponent("AuthorisationDialogue"); const var GlobalMute = Synth.getMidiProcessor("GlobalMute"); /** Checks if the serial input is valid and stores the result if successful. */ inline function onSubmitButtonControl(component, value) { if(!value) // Just execute once return; local v = SerialInput.getValue(); Console.print(v); // Checks if it's in the input if(serials.Data.contains(v)) { Console.print("Serial number found"); local data = { "Serial": v }; // Stores the file to the hard drive. In HISE it will be the project folder // but in the compiled plugin it will use the parent directory to the // user preset directory (which is usually the app data folder). Engine.dumpAsJSON(data, "../RegistrationInfo.js"); setValidLicense(true); } else { Console.print("Invalid serial number"); Description.set("text", "Invalid serial number. The number you supplied does not match"); setValidLicense(false); } }; Content.getComponent("SubmitButton").setControlCallback(onSubmitButtonControl); inline function setValidLicense(isValid) { // Do whatever you want to do here. I suggest a MIDI muter... GlobalMute.setAttribute(0, 1 - isValid); if(isValid) { // Change this to any other visual indication... SerialStateLabel.set("bgColour", Colours.greenyellow); AuthorisationDialogue.set("visible", false); } else { SerialStateLabel.set("bgColour", Colours.red); AuthorisationDialogue.set("visible", true); } } inline function checkOnLoad() { // Clear the input SerialInput.set("text", ""); // Load the serial from the stored file local pData = Engine.loadFromJSON("../RegistrationInfo.js"); Console.print("Checking serial"); if(pData) { local v = pData.Serial; Console.print("Restored serial: " + v); if(serials.Data.contains(v)) { setValidLicense(true); return; } } setValidLicense(false); } // Call this on startup checkOnLoad(); } // 3. Optional serial number generator /** This namespace contains the logic to create a new list of serials. Feel free to remove this when not needed. */ namespace SerialGenerator { inline function getNewRandomChar() { // ASCII, fuck yeah! local a = String.fromCharCode(Math.randInt(65, 90)); local b = String.fromCharCode(Math.randInt(48, 57)); return Math.random() > 0.5 ? a : b; } inline function createNewSerial() { local s = ""; s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += "-"; s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += "-"; s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += "-"; s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); s += getNewRandomChar(); return s; } const var NUM_SERIALS = 1000; inline function createNewSerials() { local d = []; d.reserve(NUM_SERIALS); for(i = 0; i < NUM_SERIALS; i++) { d.push(createNewSerial()); } local obj = { "Data": d }; Engine.dumpAsJSON(obj, "../Serials.js"); } // Uncomment this line to regenerate serials. //createNewSerials(); }
-
@xsaad Have you checked if the RegistrationInfo.js file was created correctly in the plugin folder? After you enter the serial number, the plugin generates this file to store the license. Each time you open the plugin, if the file is missing, it will prompt you to enter the serial number again.
-
@bendurso Yes The file is within the project files
It contains serial number. -
@xsaad Are you saying that the file was created in the app data folder?
On Windows, it's located at %AppData%/Your Brand/Your Plugin, and on macOS, it's in Library/Application Support/Your Brand/Your Plugin.
If you mean it was created inside the HISE project folder, that has no connection to the exported plugin. It's only for working inside HISE.
-
@bendurso Ah I understood whether I should create this file myself or it should be created automatically when exporting plugin?
-
@xsaad That file is created automatically after you insert the serial and click submit (check dumpAsJSON). Here:
inline function onSubmitButtonControl(component, value) { if(!value) // Just execute once return; local v = SerialInput.getValue(); Console.print(v); // Checks if it's in the input if(serials.Data.contains(v)) { Console.print("Serial number found"); local data = { "Serial": v }; // Stores the file to the hard drive. In HISE it will be the project folder // but in the compiled plugin it will use the parent directory to the // user preset directory (which is usually the app data folder). Engine.dumpAsJSON(data, "../RegistrationInfo.js"); setValidLicense(true); } else { Console.print("Invalid serial number"); Description.set("text", "Invalid serial number. The number you supplied does not match"); setValidLicense(false); } }; Content.getComponent("SubmitButton").setControlCallback(onSubmitButtonControl);
If the file is not created in the app data folder after you insert the serial, then there is a problem with the creation of this file. Most likely a system permissions issue.
-
@bendurso I found that the file is not created when adding the serial number, I tried it on another computer and the file was not created.
-
@xsaad Are you using mac or windows? Are you using global app data or user app data? Because if you are using global app data with mac, the file cannot be created if the folder does not exist (Application Support/Your Brand/Your plugin)
You can check in your project settings if you have enabled "Use Global App Data Folder"
-
@bendurso I am using Windows and I have enabled "Use Global App Data Folder" and after searching I found that the file containing the serial number is saved in users/Hp/AppData/brand/plugin but the problem is still with me even though the file is in app data
-
@bendurso Hi brother I was able to find out the cause of the problem I had to deactivate "saveInPrest" for the submitbutton and it worked for me
I would also like to thank you for your time. I really appreciate your help. Thank you. -
@xsaad You're welcome!
Oh yeah, you have to remove saveInPreset from all momentary buttons :)