Jump to content

Recommended Posts

Interesting problem I know. It probably is something quite simple but I can't figure it out. Now, I'm fairly new to scripting (about six months) so I'm not 100% sure what I should do.

 

The basic premise is that the player has a UAV with an M136 launcher on it. The drone then fires that launcher. Got that part down. I've even got it so that the drone rearms when it goes back to "Home". Now, what I'd like to do is to have the players rearm it in the field. They can have a launcher on their back, bring the drone to them and then attach the launcher onto the drone. The drone has a new launcher and the player looses theirs. Here is the code that I have so far.

 

Spoiler

    if (SecondaryWeaponplayer ==  "rhs_weap_M136_hedp") then
        {
            hint "Play sec weapon found";
            [UAV3, "rhs_weap_M136_hedp", 1, "rhs_m136_hedp_mag"] call BIS_fnc_addweapon;};
            _unit removeWeapon (secondayWeapon _unit);
        };
    else
    {
        hint "There is nothing for you to rearm";
    };

 

 

I know that it must be very simple but any help is very much welcome in advance. For you're consideration, I'm using ACE, CBA, RHS (All four modules) and more quality of life mods. Nothing that would effect scripting in any way.

Share this post


Link to post
Share on other sites

@HazJ Oh, I've alredy gotten to the point that I can attach the launcher to the drone. That's not the problem. The problem is that I cannot seem to get the script to take away the players launcher and give it to the drone.

Share this post


Link to post
Share on other sites
player removeWeapon (secondaryWeapon player);

Should work, but you have that... Hmm. Ah, you have a typo:

if (SecondaryWeaponplayer ==  "rhs_weap_M136_hedp") then
if (secondaryWeapon player isEqualTo "rhs_weap_M136_hedp") then // or use: in ["rhs_weap_M136_hedp", "moreClassnames"]

I recommend you use -showScriptErrors parameter on startup. Helps a lot!

Share this post


Link to post
Share on other sites

@HazJ A typo?....

 

...

...

Oh my god...

 

I forgot that sqf doesn't view == and isEqualTo as the same thing! Thank you muchly but I'm still having issues with it. I'll tinker a little more but here is what I have so far.

 

Also, it's throwing the error "Error:If. Type String, expected Bool."

 

Spoiler

    if (secondaryWeapon player isEqualTo "rhs_weap_M136_hedp") then
        {
            hint "Play sec weapon found";
            Removeallweapons UAV3;
            [UAV3, "rhs_weap_M136_hedp", 1, "rhs_m136_hedp_mag"] call BIS_fnc_addweapon;
            _Player removeWeapon (secondayWeapon _Player);
        };
    else
    {
        hint "There is nothing for you to rearm.";
    };

 

Share this post


Link to post
Share on other sites

You can do == as well. I just prefer isEqualTo, I believe it is faster. Not by much I don't think. Don't quote me on it though. You have }; which is wrong. Here, fixed it for you:

if (secondaryWeapon player isEqualTo "rhs_weap_M136_hedp") then
{
	hintSilent format [":: %1", secondaryWeapon player];
	removeAllWeapons UAV3; // does this work on UAV drones? Can't remember, never tried I don't think, not this way haha
	[UAV3, "rhs_weap_M136_hedp", 1, "rhs_m136_hedp_mag"] call BIS_fnc_addWeapon;
	player removeWeapon (secondayWeapon player);
} else
{
	hintSilent "There is nothing for you to rearm.";
};

What was _Player / _unit and where are you executing this from and how?

Share this post


Link to post
Share on other sites

_Player was supposed to be the local value that is executed client-side. Anyway, it doesn't matter now because you fixed it and I could kiss you!

 

I'm not sure that RemoveAllWeapons works on UAV drones but I have this

Spoiler

[UAV3, "rhs_weap_M136_hedp", 1, "rhs_m136_hedp_mag"] call BIS_fnc_addweapon;

[UAV3] joinSilent createGroup west;

hint "Armed"

 that is called when the drone becomes alive.

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×