PurplePoot you are wrong on many levels. Please stop fagging up the thread. When it's possible to do someting in gui you should do it in gui.
Teifi All you have to do is create event:
Player types chat message containing code as a substring.
Then get a substring from entered string, from char 6 to char [length of string] (ie if entered string is "code 345" you'll get "345"), convert it to integer and compare with your code.
Teifi random numbers are always the same when you run map from worldedit, for testing purposes. You can change that in Preferences of editor, "keep random seed" checkbox (or something).
Oh well I figured it out anyway - i just didnt put the [Generate Random Number] variable action in a timed trigger, eg map initialization. Anyway, ill do what you said.