Jump to content

Recommended Posts

Hi Everyone,

 

I am sorry if this was answered before, I searched using google and the forum search and didn't find a solution.

 

I am adding items to a box server-side (dedicated) when a player buys the items from the shop client side. The problem is the player cannot take anything out of the crate, unless first dragged to the ground.

 

The Box:
Init: 

this enableSimulation false; this allowDamage false; clearItemCargoGlobal this;

Server side:

_ item = an array of data from the config about the given data. dont worry too much about this. _item select 0 = the item class.

switch (_item select 7) do {
    case ("CfgWeapons"): {
        switch ((_item select 5)) do {
            case 1;
            case 2;
            case 4: {
                _crate addWeaponCargoGlobal [(_item select 0), 1];
            };

            default {
                _crate addItemCargoGlobal [(_item select 0), 1];
            };
        };
    };
    case "CfgVehicles": {
        _crate addBackpackCargoGlobal [(_item select 0), 1];
    };
    case "CfgGlasses": {
        _crate addItemCargoGlobal [(_item select 0), 1];
    };
    case "CfgMagazines": {
        _crate addMagazineCargoGlobal [(_item select 0), 1];
    };
};

Any idea why I would have the above mentioned issue?

 

 

Thanks!

Share this post


Link to post
Share on other sites

Probably this:

this enableSimulation false;

Plus wrap the other init box commands in:

if (isServer) then {// stuff};

Share this post


Link to post
Share on other sites

 

Probably this:

this enableSimulation false;

 

That is what I thought, but won't the box get thrown around if I enable it? eg if someone drops a nade next to it :D?

Share this post


Link to post
Share on other sites

Attach the box to a logic and it should disable physx

 

ah i see! didn't know that was a thing. So eg: 

_crate attachTo [_some_anchor_obj_with_simulation_disabled]

(with offsets etc if/as needed)?

Share this post


Link to post
Share on other sites

I'm perfectly OK with "If a player drops a grenade at base and blow up their weapons cache that's on them".  

 

If you were a gun shop owner and someone was buying a gun from you and instead dropped a grenade behind your counter would you say "No worries, I'll just superglue my shoes to the floor!" or would you stop selling to the person? :)

  • Like 3

Share this post


Link to post
Share on other sites

Yes that would probably be okay but don't get too strung up on disabling the simulation on everything.  Sometimes it's useful to do, but other times pointless and other times it has unwanted negative effects (as you have seen)

 

put down a game logic and call it something like "boxLogic1"

 

Then on your box, do this in the init field:

if (isServer) then {this attachTo [boxLogic1,[0,0,0]]; this allowDamage false; clearItemCargoGlobal this};

iirc, you shouldn't need to mess around with the offsets but maybe you will.

  • Like 1

Share this post


Link to post
Share on other sites

Yes that would probably be okay but don't get too strung up on disabling the simulation on everything.  Sometimes it's useful to do, but other times pointless and other times it has unwanted negative effects (as you have seen)

 

put down a game logic and call it something like "boxLogic1"

 

Then on your box, do this in the init field:

if (isServer) then {this attachTo [boxLogic1,[0,0,0]]; this allowDamage false; clearItemCargoGlobal this};

iirc, you shouldn't need to mess around with the offsets but maybe you will.

 

I see, alright makes sense. Much appreciated as always - thanks a bunch!

Share this post


Link to post
Share on other sites

I gave it a try, attaching both a logic and directly to the "house" it was placed in. The problem remained the same.

EDIT: doing more tests and will return in a moment.

 

EDIT: Ok, it seems like even without doing anything to the crates, and just leaving them as is, they still have the problem if I put something in them and try to take it out. Any thoughts?
 

Share this post


Link to post
Share on other sites

Hmm, not sure then - I tried a test mission earlier, just to test it was working and it was for me.

 

Are you sure you don't have any other scripts running in your mission that could be interfering?

 

If you can upload a copy of the mission, I can have a quick check through (if that helps).

Share this post


Link to post
Share on other sites

How about forcing locality?

[_crate, [(_item select 0), 1]] remoteExec ["addWeaponCargoGlobal", _buyerObject];

Share this post


Link to post
Share on other sites

Hmm, not sure then - I tried a test mission earlier, just to test it was working and it was for me.

 

Are you sure you don't have any other scripts running in your mission that could be interfering?

 

If you can upload a copy of the mission, I can have a quick check through (if that helps).

It's in the unstable branch now - appreciate the help:

https://github.com/mreliasen/supremacy-framework/tree/dev-unstable

 

Share this post


Link to post
Share on other sites

 

How about forcing locality?

[_crate, [(_item select 0), 1]] remoteExec ["addWeaponCargoGlobal", _buyerObject];

I did try adding it client-side once server confirmed the purchase but it was still having the same issue. 

Share this post


Link to post
Share on other sites

I just had a look through supremacy_server and also the mission file (supremacy.altis) but I couldn't see anything else that might be the culprit.  If I get a chance., I'll try and set up a test version.  Hope you can get it sorted in the meantime though   :)

 

edit: Have you tried in the editor on a blank/new mission (or only playing supremacy)?

  • Like 1

Share this post


Link to post
Share on other sites

I just had a look through supremacy_server and also the mission file (supremacy.altis) but I couldn't see anything else that might be the culprit.  If I get a chance., I'll try and set up a test version.  Hope you can get it sorted in the meantime though   :)

 

edit: Have you tried in the editor on a blank/new mission (or only playing supremacy)?

 

The map I am using right now is Tanoa. Hmm no I have not, I will give it a try tomorrow. 

 

I really appreciate the help man :)

 

EDIT: I have a theory of what it is, will run some tests and get back 

 

EDIT: OK I am pretty sure I found the problem. Looks like, despite having removed the code from the init of the crates, the custom attributes data for the crates where still in the map file. Removing made me able to loot them! Now I just need the implement the rest of the script, but I feel pretty confident its doable now.

Once again, much appreciated for helping out!

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

×