OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ModestNovice on 26 Jun 2008, 04:25:28

Title: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 26 Jun 2008, 04:25:28
K I have this script. It works, only, its will remove your gun even if its not rifle AND when I holster it, then try to unholster, it says I have no weapon.

SOO:

How do i make it only remove if its a rifle.

AND

How do make it save your weapon, then add it back later?

Code: [Select]
_weps = weapons player;
_mags = magazines player;
_howmuch = count _weps;
_weapon = [vehicle player] call mando_my_weapon;
_sWeap = secondaryWeapon player;

if (holstered) then
{
{player addWeapon _x} foreach _weps;
{player addmagazine _x} foreach _mags;
ctrlSetText [33, "Unholstered"];
Sleep 1;
ctrlSetText [33, ""];
holstered = false;
} else {
if (_weapon == "") then
{
ctrlSetText [33, "You don't have a rifle!"];
_holstered = false;
Sleep 1;
ctrlSetText [33, ""];
} else {
if (_howmuch > 1) then
{
ctrlSetText [33, "You can only holster one rifle!"];
Sleep 1;
ctrlSetText [33, ""];
} else {
removeAllWeapons player;
_holstered = true;
ctrlSetText [33, "Holstered"];
Sleep 1;
ctrlSetText [33, ""];
};
};
};
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Mr.Peanut on 26 Jun 2008, 14:05:59
Take a look at Cheetah's holster pistol script here: http://www.ofpec.com/ed_depot/index.php?action=details&id=414&page=0&cat=xyz (http://www.ofpec.com/ed_depot/index.php?action=details&id=414&page=0&cat=xyz) and Spooner's getWeaponType script here:http://www.ofpec.com/forum/index.php?topic=30473 (http://www.ofpec.com/forum/index.php?topic=30473). Combining those should get you what you need.

edit: Reading down further in Spooner's thread I think he states that you need only check that the weapon is of type primary. Check the code snippet in his second post.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Spooner on 26 Jun 2008, 15:33:02
If you are looking at weapons in a soldier's inventory, you can work out the rifle, since it is also your primaryWeapon. Any launcher is your secondaryWeapon and your pistol is neither of these. You only need to know the type of a weapon if it isn't in someone's inventory and all you know is its class name (e.g. when it is in a SPON Money (http://www.ofpec.com/forum/index.php?topic=30551) shop).

To save you some time, what you want has already been done by Colonel Sanders Light (Weapon switching (http://www.ofpec.com/ed_depot/index.php?action=details&id=415&page=2&cat=xyz)).

This also isn't an advanced topic.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 26 Jun 2008, 20:57:04
OKAY Will someone please help we with this ?? ??!?!?!

 :dunno: ??? :confused:
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 06 Jul 2008, 00:42:49
Well no help for over a week now.

Thanks!  >:(
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Planck on 06 Jul 2008, 11:35:51
DaChevs,

Both Mr Peanut and Spooner responded to you on the 26th June, which you seemingly decided to ignore, also on the 26th June.

This does not tend to encourage anyone else to offer some other solution when you have obviously ignored suggestions so far.


Planck
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 07 Jul 2008, 01:23:03
I DID NOT ignore them. I said I would look again, but as I stated clearly before, I looked in Cheetah's script and DID NOT understand it that much! That is why I asked again for the help. So again I will say it, I know they responded, and I did not ignore their posts, I have talked to ColonelSandersLite himself, but he hasn't been able to help yet. I know you guys have better things to do, but I would appreciate if someone would please help me get this sorted out?
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Spooner on 07 Jul 2008, 01:47:29
I'd suggest you go back and actually read the thread again and see if any of your statements are true. Is it possible that you edited out the comments you are talking about so we didn't actually see them?

You made an initial request. Both Peanut and I made reasonable suggestions within a very short time scale. Then you just repeatedly asked for help without acknowledging our replies, explaining why our solutions were not appropriate or giving any further details. What were we supposed to do?

When we make suggestions, we try to point you in the direction before we roll up our sleeves and do the work for you. If we don't help you to your satisfaction, then spitting out your dummy won't encourage us to help you next time. No more flaming on this thread, though. If you feel you have a genuine gripe with us, please continue this in PM or nowhere at all.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Cheetah on 07 Jul 2008, 11:22:54
Please let's get it clear for me what you exactly want. The holster script works for you I guess? That's what you want, only then not for pistols but the holstering of the primary weapon (rifle, SAW etc). Correct?

Also, please reduce the size of your avatar to something like 85x85.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Mr.Peanut on 07 Jul 2008, 14:06:45
Well, there are two problems with that script:
Code: [Select]
removeAllWeapons player;The command you are using is removeAllWeapons, and you obviously don't want to remove all of them.

Your second problem is that you are saving the magazines and weapons in a local variable. Once the script exits those variables are erased from memory. You should either change them to global variables, or save them to the unit using the setVariable command.

What you should have done was read Cheetah's holster script, which is almost identical to what you want, and then asked us about anything that you did not understand. We are trying to help you to help yourself. You can learn a lot by understanding other people's scripts and modifying them.

As for the avatar. OFPEC has a strict policy. We want our forums to be clean and easy to read with as few distractions as possible. I am not a football fan, but even before your avatar grew I hated it. I hate the look on his face. Please reduce it before I vomit. (http://www3.ns.sympatico.ca/brendan.detracey/vomitchums.gif)


#Avatar removed - bedges
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 08 Jul 2008, 03:46:07
I'm sorry about the avatar, an admin told me/changed my signature, but never said anything about my avatar. And, Football (SOCCER) is the greatest sport ever invented.  :yes:

And Juninho is awesome.

And yes, Cheetah, I am looking for exactly what you stated.

And yes, when you guys suggested Cheetah's script, I had already looked in there 3-4 times, and again when you stated to. but could not understand what was going on with all the save weapons and isPistol commands.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Mr.Peanut on 08 Jul 2008, 19:18:11
In Cheetah's script, try changing:
Code: [Select]
_pistolConfig = configFile >> "CfgWeapons" >> "PistolCore";to
Code: [Select]
_pistolConfig = configFile >> "CfgWeapons" >> "RifleCore";
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 08 Jul 2008, 20:29:25
okay thanks Peanut  ;)

sry for my thick skull.  :D


Woooowww...I can now holster me rifle. Thanks Peanut, and I shall admit, I am one dumbshit. Excuse my language, but hey, you know you agree  ;).
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: Mr.Peanut on 08 Jul 2008, 20:57:25
You are not a dumbshit, you are simply learning to script and Cheetah's script is hard to understand, especially for a beginner. I had to read it a few times myself to unravel it.
Title: Re: Rifle Holster Script (HELPP PLEASE)
Post by: ModestNovice on 09 Jul 2008, 22:20:52
Heh. Thx Peanut  :)