Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need script help asap! extremely difficult script!
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#4
RE: Need script help asap! extremely difficult script!

(12-19-2012, 10:32 AM)TheGreatCthulhu Wrote: Please use the code-tags when posting code (especially when posting looong code), and make sure the formating stays preserved - it helps us make sense of everything, and help you in return.

Instead of Set/Add-LocalVarInt() functions, you can simply use an integer variable (or more than one), as it is a bit easier to deal with.
You can declare them near the top of your script, outside of any function. Something like this:
int code;
int userEntry;


Then you can use the code & userEntry variables throughout your script file.
Note that the codes are just numbers - so once you have converted a sequence of the button presses to corresponding numbers, you can simply compare for equality.

You can even internally consider the whole 123-098-678 sequence as a single number, namely 123098678.

The trick is how to get from a sequence of button presses to the actual multi-digit number. Let's assume for the moment that the code has only 3 digits. If the user presses the button a, then b then c, you should be able to get the number abc. Well, take a look at this:

abc = (a * 100) + (b * 10) + (c * 1)

So, all you need to do is count how many buttons have been pressed since the start of the sequence, and multiply the digit connected to the current button by a corresponding power of 10, and then add the result to the overall sum. So, for the first button press, you do nothing, for the second, you multiply by 10, for the third, you multiply by 10*10, etc... (it helps if you start counting from 0, instead from 1 - then you can make the indices and the exponents match).

The steps are:
  1. Check what button is it in a row.
  2. Multiply it's digit by the corresponding power of 10 (say: int temp = 6 * 100;)
  3. Add the result to the overall sum: userEntry = userEntry + temp;
  4. If this was the last number, check if it is equal to the code.
  5. Respond accordingly.

WOW... never used those a b c things...
in can script a lot but never used those kind of thngs!!!

I know for some reason it can be very short..
let me explane what i have done for better instructions.
-----
I have a controlpanel with 1-0 and *#
ALL of them are NOT toutchable -> there are scriptarea's in front of them so in fact you toucht those!

I want a 4 digit code for example 1 3 5 7 THEN press ACCEPT ={ # in the editor }

IF Done right ..... like a door opens..
IF wrong ...... it will reset and you can try again over and over....
THIS button * i already fixed , it respwns you to the other plr-start.

Could someone make a script for this?

I don't really think so, might be to diffficulty... Sad

If it is NOT possible let me know wwhat i can do then.

THIS part is really importent to my FC.

THANKS for everyone trying to help me!
(This post was last modified: 12-19-2012, 03:08 PM by DnALANGE.)
12-19-2012, 03:07 PM
Find


Messages In This Thread
RE: Need script help asap! extremely difficult script! - by DnALANGE - 12-19-2012, 03:07 PM



Users browsing this thread: 2 Guest(s)