Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
PixeL_GaMMa

BIS_fnc_spawnGroup related weapon vanishing

Recommended Posts

I'm currently working on a new mission and found that any AI created with BIS_fnc_spawnGroup, the weapons seem to vanish when "looting"

 

        _grp = [[_pos select 0, _pos select 1, 500], east, 4+floor(random 5)] call BIS_fnc_spawnGroup; 
        _grp deleteGroupWhenEmpty true;
        {
            removeBackpack _x; 
            _x addBackpack "B_Parachute";          
            _x call PX_fnc_setupNPC;
        } forEach (units _grp);    

 

whenever any of them die, if i go and pick up the weapon they were carrying (or at least try) my weapon vanishes and so does the AI weapon.... any ideas what could be going wrong? Note that this is server side.

 

Client log is showing the following errors:

 

 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!
 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!
 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!
 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!
 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!
 0:21:17 CWeaponSlotsManager::DeleteWeapon: wrong weaponID!

like 600 entries for trying to pick up weapon once.

Share this post


Link to post
Share on other sites

just attaching a few events, I have removed this for testing purposes and still remains the same.

 

Edit: Sorry, please forget this, I seemed to have corrected this, my player loadout seemed to be causing the issue, by changing addWeapon to addWeaponGlobal seems to have fixed all additional errors relating to npc's

Share this post


Link to post
Share on other sites
4 hours ago, PixeL_GaMMa said:

just attaching a few events, I have removed this for testing purposes and still remains the same.

 

Edit: Sorry, please forget this, I seemed to have corrected this, my player loadout seemed to be causing the issue, by changing addWeapon to addWeaponGlobal seems to have fixed all additional errors relating to npc's

I thought that command was broken.

Quote

This command is broken when used on dedicated server

Quote

If you do not remove weapon first, using this command from dedicated server will duplicate weapon.

I never needed to use this, in MP.

Share this post


Link to post
Share on other sites

Well, i'm using it on dedicated server (on server side mod/script) and it fixed all my problems... unfortunately, it seems a lot of the others such as addItem, addWeapon, and especially addPrimaryWeapontem are all broken for global use when used on a player, but fine used on "local" npcs, so i've just encapsulated them in functions for easier use.

to be exact all of them work on dedicated for npcs.

addItem - works globally, by putting items into inventory, but then unable to use them without first dropping and picking them back up - perfect example are grenades.
addWeapon - adds the weapon to player but vanishes when taking a weapon from an npc

addMagazines - This one seems to be the exception, seems to work fine either way

addPrimaryWeaponItem, addSecondary...., addHandgun.... etc does not work at all for a player.

I will begin putting together an "api_fixes.sqf" for include into missions for later use, will save me a lot of headaches)

 

basically now instead of using the global functions, i've just put together a few functions like:

 

PX_fnc_addPrimaryWeaponItem = {
    params ["_unit", "_item"];
    
    if (isPlayer _unit) then {
        [[_unit, _item],"addPrimaryWeaponItem"] call BIS_fnc_MP;
    } else {
        _unit addPrimaryWeaponItem _item;
    };
};

 

but for example, the following would work:

 

PX_fnc_addWeapon = {
    params ["_unit", "_item"];
    
    if (isPlayer _unit) then {
        _unit addWeaponGlobal _item;
    } else {
        _unit addWeapon _item;
    };
};

 

But instead i opted to use mp function instead

 

PX_fnc_addWeapon = {
    params ["_unit", "_item"];
    
    if (isPlayer _unit) then {
        [[_unit, _item],"addWeapon"] call BIS_fnc_MP;
    } else {
        _unit addWeapon _item;
    };
};


 

Share this post


Link to post
Share on other sites

No need to do that. You can just do something like:

[player, "classname"] remoteExec ["addPrimaryWeaponItem", 0, false];
// Remember to change targets, etc... Just ^^ dummy information

https://community.bistudio.com/wiki/remoteExec

Quote

But instead i opted to use mp function instead

Why BIS_fnc_MP over remoteExec?

Share this post


Link to post
Share on other sites
1 hour ago, HazJ said:

Why BIS_fnc_MP over remoteExec?

 

Old habits are a hard thing to kill...

...even with a chainsaw.

 

Cheers

  • Haha 1

Share this post


Link to post
Share on other sites

I usually do use remoteExec, but in this case it felt more natural using call, keeps it more readable imo, since i develop in assembly a lot, i'm more used to pushing params before calling a function.

 

push param1

push param2

call func

 

etc

Share this post


Link to post
Share on other sites

It's about the format of parameters not the actual macro/function itself :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

×