THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/10/2005 at 13:01, xxxxxxxx wrote:
Cinema 4D Version: 9.5
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
I've searched and read thru threads about making/using serialnumbers for plugins here.
My thought/question is. Are plugins, in general ,"done" /compiled for delivery or does one compile each and every plugin for delivery, when a customer have sent their 11 digit serial number?
Since I'm using coffee only, my thought was just to include that serial number in each compile( using SysGetUserInfo( ) ) and then deliver it.
Is that safe/easy enough? Or is there a much smarter way?(Within COFFEE)
On 12/10/2005 at 14:57, xxxxxxxx wrote:
Never hardcode serials into source. Not that it makes any difference to crackers, just easier to crack. And why would you want to compile every plugin for customers? What would you do it you have 100 orders on a single day? It would take many hours (or days) to do this. And everytime you make an upgrade, voila, you need to recompile every customer's plugin!
Better to create a file stored somewhere on harddrive which contains registration code/serial number, encrypted if possible or desired. Reference this file from your plugin. Updates/upgrades to your plugin now only require one compile and distribution.
In my case, and the standard way to do this, is to get the user's 11-digit serial number and base the plugin's serial number/registration code from this. I created a little utility to generate (encrypt) the license key file from input information and the source for decryption and validation is in the plugin.
On 12/10/2005 at 15:33, xxxxxxxx wrote:
Ah. Thanks. I guess it was more to it than I thought.
My programming is pretty limited, I sort of manage to do things in the Execute part of Coffee. Anything before that is still a total mystery..
So it is possible to do stuff "outside" of the plugin code....
So it doesn't have to do the check on each animation cycle?
Darn. And I thought I was almost done ...
I will now spend some more time looking in the SDK (COFFEE).
Would it be anything specific I should look for?
On 12/10/2005 at 21:10, xxxxxxxx wrote:
Lennart, do it in main(), first thing (or after loading resources if needed). main() is only called once at the start of the plugin.
On 14/10/2005 at 17:42, xxxxxxxx wrote:
Thanks! I now now how to find and read files.
But...even if the serial number is a number it is still a string in the coffee code.
In my search all I find is "stringToReal" but it seems as it is a C++ thing?
What should I look into to get number characters seen as numbers instead? So I can use the serial number and the external textfile(password in numbers) for calculations.
On 14/10/2005 at 18:18, xxxxxxxx wrote:
Use Filename class to construct/hold file paths and names.
Use BrowseFiles class to search directories.
Use BaseFile class to read/write files.
I don't see anything in COFFEE to convert a string to a number. If the string represents an integer, there are methods to build the number from the individual numerical characters:
var numString = "1234567890";
var t = 1;
for (j = sizeof(numString)-1; j >= 0; --j)
k = k + (numString[j] * t);
t = t * 10;
print(numString+" = "+tostring(k));
What this does is extract each digit from the lowest order (end of string) to highest order (start of string), multiplies by a power of 10 (t), and adds that to the accumulating number.
On 14/10/2005 at 21:46, xxxxxxxx wrote:
One thing that I missed:
(numString[j] * t) needs to be ((numString[j]-48) * t)
In ASCII/Unicode, "0" = 48 (yes, text characters have numeric values). Subtracting 48 from the ASCII value turns it into the pure number "0" = 48 - 48 = 0.
Been some time since doing this, pulling the code off the top of my head.
On 15/10/2005 at 07:01, xxxxxxxx wrote:
Thanks Robert. I see how you think (but don't understand it yet )
I use a "nothing" plugin to test only this part (your example).
To me it looks as if it may be a little of a catch22.
k = k + ((numString[j]-48) * t);
gives a Incompatible value NIL / INTEGER, COFFEE error message.
Given that numString is a string, it doesn't look as it can be calculated.
I do most likely make a mistake somewhere here....
(The reading of textfiles work fine, using FileName- and BaseFile classes but in this test that part is taken out, only using "var numstring = "1234567890" " as input)
On 15/10/2005 at 13:52, xxxxxxxx wrote:
The problem isn't numString[j], it's 'k'. 'k' is uninitialized. Change 'var k;' to 'var k = 0;' and it will work!
On 15/10/2005 at 15:50, xxxxxxxx wrote:
I'll investigate further this week.
Many thanks (but I'm dure I might return in the issue )
On 16/10/2005 at 16:31, xxxxxxxx wrote:
Gosh Robert, it really works! You will be rewarded, I promise.
May I check one more thing? The registration method I'm thinking of is to provide the user with a .txt file (Plain text). This .txt file contains the usercode. The .txt file is to be placed at a certain location to be read by Cinema. So far that works fine. However, I'm on Mac. Will a .txt file done on a Mac be the same on a PC? Or is there a risk that it will be interpretet as "something else"? (Magicaly become a .doc or whatever)
On 16/10/2005 at 22:57, xxxxxxxx wrote:
Yes, should work identically. Cinema 4D's file read/write facilities compensate for the platform differences (little-endian/big-endian, filesystem, etc.).
One caveat to be aware of when converting strings representing integers to actual integers: there is a limit to the sizes available. 32-bit unsigned precision for integers is from 0 to 4294967296. COFFEE's int is signed, so you are limited to the range –2147483648 to 2147483647. After that, you'll get errors. Basically, anything 9 digits or more is in the 'danger zone'.
Now, one can circumvent this by breaking the string and the conversions into multiples. So, "999999998888888" can be converted by splitting the string appropriately (every 8 digits, for instance) and converting into several int variables. Then do your comparisons on the individuals ints.
Or, you can do the calculations on the string characters, individually. You can always employ the (x-48) to convert the digit character into an integer from 0 to 9 if needed.
On 26/08/2008 at 15:42, xxxxxxxx wrote:
Since your setup has worked flawlessly Robert, I haven't had any reason to look into it, until today when I just found the
evaluate("1234") COFFEE function!
So far it handles anything I throw at it.
(Number textfiles, tostring("123")etc.)