Home   Help Search Login Register  

Author Topic: ArmA-ified (by Wolfrug) CodePad by Blanco (ACCEPTED)  (Read 3359 times)

0 Members and 1 Guest are viewing this topic.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Hey there!

I was browsing the Ed.Depot the other day and came across a great old resource by our resident Blanco, apparently saved after the crash by RichUK (this one here : clicky)

I've converted it to work with ArmA, fixed most of the bugs that Blanco had found in it (only one codepad/code, edit-box bug), and generally updated a bunch of features. CodePad.sqf script made from scratch. All description.ext entries have been made unique, so it won't interfere with anything else, just a simple matter of using #include. :) Contains demo mission. Scripts more or less wholly commented. Edit: Oh yes, and I asked Blanco if I could release this and he said yes. :D So it's even with permission!

readme.txt:

Quote
RUG Codepad

NOTE: All credits for the appearance of the codepad, the default codepad sounds (button.ogg, codefound.ogg and wrongcode.ogg) and the description.ext (with some minor ArmA-fication changes done by me) go to Blanco! This is essentially NOTHING BUT A CONVERSION OF BLANCO'S CODEPAD FOR OFP INTO ARMA.

Features:
- Dialog with a numeric pad. - paper with code
- Display and 2 leds (red & green).
- Custom sounds
- A from scratch created Codepad.sqf script that allows for an unlimited number of unique codepads + codes (unlike Blanco's original that only featured one set), as well as allowing the user to decide what script will be run upon completion/failure.
- 1.08 compatible (will upgrade with new string commands once 1.12 final is out)
- ArmA-ified description.ext : made it independent of RscXXXX by adding RUG_CodePad_ tags in front, so it can be #included in any description.ext. Added displaySetEventhandler to the Codepad.sqf that recognizes all the number keys, and removed the editbox, thereby fixing another bug in Blanco's original script (writing in the edit box directly messed with the scripts).

Usage:

Works either directly as a user-action (with addaction) or run via execvm. Needs three parameters: 1) an array of numbers/special characters 2) a script (ontrue) that launches on succesful entering of code and 3) a script (onfalse) that launches on the wrong entering of the code.

Example : nul = [[1, 5, "*", 4], {sleep 1;closeDialog 0; Obj1 = true; hint "You entered the right code!"}, {sleep 1; closeDialog 0; AlarmOn = true; hint "You triggered the alarm!"}] execvm "CodePad.sqf";

Example 2 : Door1 addAction ["Security keypad", "CodePad.sqf", [["#", 5, 6], {nul=[]execvm "openGate.sqf"; sleep 1; closeDialog 0; hint "Gate opened!"}, {ctrlSetText [999,"Wrong code!"]; sleep 1; ctrlSetText [999, ""];}]];

For advanced, and less crowded, use it's suggested you pre-compile your OnTrue and OnFalse scripts.

Also: If you add the string version of your code to the global array RUG_CodePad_KnownCodes, the code will be displayed on a piece of paper under the appropriate codepad when opened. Usage: RUG_CodePad_KnownCodes = ["15*4", "#56"];

NOTA BENE:
- The two special characters * (star) and # (num) need to be added as strings to the array of numbers.
- The dialog does not close by itself when successful/non-succesful. You need to add a closedialog 0 in your ontrue/onfalse scripts to make that happen.
- You can have more than one keypad with the same code, but if the code-string is in the RUG_CodePad_KnownCodes array, the code will be shown on the piece of paper for ALL code pads with the same code.
- If you want to use the codepad's number area (IDC = 999) for text etc,. that is possible, but note that unless you disable the "KeyDown" displayEventHandler and the buttons, users will be able to spam the area with numbers and most probably bring about an OnFail event. See the OnFail in the example mission for a way to entirely "lock" the keypad.
- There are sounds for all the different buttons (0 - Num), however at the moment they (should) be identical. Simply replace the .ogg files with your own sounds if you want! Button.ogg is Blanco's default sound.

Enjoy!

Wolfrug out.

CodePad v1.0
« Last Edit: 21 Apr 2008, 22:33:50 by Mandoble »
"When 900 years YOU reach, look as good you will not!"

Offline GaReb

  • Members
  • *
Re: ArmA-ified (by Wolfrug) CodePad by Blanco (ACCEPTED)
« Reply #1 on: 23 Apr 2008, 00:03:06 »
I want to use the codepad on an ammo crate.  I want the ammo crate to stay locked until the code is entered...then it will open the crate to reveal whats inside.  If someone can show me how to do this it would be a great help.

Thanks in advance

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: ArmA-ified (by Wolfrug) CodePad by Blanco (ACCEPTED)
« Reply #2 on: 23 Apr 2008, 09:51:31 »
Hey there GaReb!

The simple solution is to clearWeapon/MagazineCargo initially, and then in the OnTrue event addWeapon/Magazinecargo as you want.

Well, there's a slight problem with using an ammo-crate here. Say for instance you want the ammocrate's contents to only be accessible to someone who enters the correct code. The problem here is that there's no way to count the amount of ammo inside a crate, meaning if that someone opens the crate, changes weapons around, and then closes it again, there's no way to tell how much has been changed. Furthermore, there's no way to prevent people from accessing the empty ammo crate and depositing guns n' ammo there, that might in turn be deleted when the ammo crate is "locked" again.

If this isn't a problem, and you don't mind the ammobox being refilled every time it's "opened" (and everything extra put into it deleted) then something like this should work. If you don't want the ammobox emptied, just remove everything after Player action ["gear"...] and instead use a removeAction to prevent the player from continually filling the box:

Code: [Select]
OnTrueAmmoBox1 =
{
// Start of script. Sleeps one second to let the player know he's succeeded, then closes the codepad dialog.
sleep 1;
closeDialog 0;

// Adds the ammo and weapons : put whatever you want here.
AmmoBox1 addweaponcargo ["M4", 2];
AmmoBox1 addmagazinecargo ["PipeBomb", 10];

// Extra stuff. Using the gear action makes the player automatically try to access the box - might not work if the player is too far away.
Player action ["gear", AmmoBox1];
sleep 1;
// Uncomment the following line if you just want a one-shot unlock, and delete the clearMagazine/weapon cargo entries!
// AmmoBox1 removeAction 0;

// Waits until the gear dialog is closed
waitUntil {(isNull (findDisplay 106))};

// Clears the magazine and ammo cargo again
clearMagazineCargo AmmoBox1;
clearWeaponCargo AmmoBox1;
//End of script
};

Name of the Ammo box is AmmoBox1 of course. The action would look something like:

Code: [Select]
AmmoBox1 addAction ["Unlock Box", "CodePad.sqf", [[1, 2, 3], OnTrueAmmoBox1, {ctrlSetText [999,"Wrong code!"]; sleep 1; ctrlSetText [999, ""];}]];
Hope that helps, and isn't too complicated! :D

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"