Jump to content
Sign in to follow this  
Messiah

setobjecttexture in MP

Recommended Posts

ok, the basic gist of what's going on is that i havea vehicle that has a deployable camnet script. Essentially there's a dummy anim in the vehicle that allows a useraction to be associated with it - the anim is triggered via the useraction, as is a script.

this script then ejected all the members of the vehicle, locked the vehicle and 'deployed' (setobjecttextured) the camnet.

all well and good in SP, but in MP it just doesnt work due to the notrious setobjecttexture buggery that goes on. Now i always assumed that anims were a global oocurance in MP, so that on being animated, every client should techinically run this script, no? Apparently not, seeing as in MP no one else gets booted out the vehicle, and the camnet only appears for the client who activated the anim.

shit happens...

so i thought how about going along the lines of eventhandlers, something i deffinatly know gets globally activated. My initial thoughts and scripting were around the getout eventhandler, basically checking if people had been booted from the vehicle, then checking the animationphase of the vehicle and if all the conditions were met, deploying the net.

unfortunatly, my first problem is getting everyone to eject in MP, seeing as it refused to work earlier.

so the options i have left (as i see it) are to only let the net be depoyed when every one's out of the vehicle (something that i think would be wise in the long run anyway) but the problem of making textures appear are still going to cause grief

or

somehow working the animphase (but i heard that checking these in MP also fail to work) or a globalvariable into a script to be activated everytime the anim is activated, aned checked beside a script that made the texture appear?

help confused_o.gif

Share this post


Link to post
Share on other sites

here's the script that makes the net show - works fine in SP

Quote[/b] ]

_vehicle = _this select 0

_type = typeof _vehicle

?(_type == "UKF_WMIK") : goto "wmik"

?(_type == "UKF_WMIKDES") : goto "wmikdes"

?(_type == "UKF_WMIKG") : goto "wmik"

?(_type == "UKF_WMIKGDES") : goto "wmikdes"

?(_type == "UKF_WMIKM") : goto "wmikm"

?(_type == "UKF_WMIKMDES") : goto "wmikmdes"

#wmik

_occupants = crew _vehicle

{unassignVehicle _x} forEach _occupants

(_occupants) allowGetIn false

{_x action ["eject", _vehicle]} forEach _occupants

_vehicle lock true

_vehicle setobjecttexture [23, ""]

_vehicle setobjecttexture [24, ""]

_vehicle setobjecttexture [25, ""]

_vehicle setobjecttexture [26, "\ukf_wmik\lcamnet.pac"]

exit

#wmikdes

_occupants = crew _vehicle

{unassignVehicle _x} forEach _occupants

(_occupants) allowGetIn false

{_x action ["eject", _vehicle]} forEach _occupants

_vehicle lock true

_vehicle setobjecttexture [27, ""]

_vehicle setobjecttexture [28, ""]

_vehicle setobjecttexture [29, ""]

_vehicle setobjecttexture [30, "\ukf_wmik\ldcamnet.pac"]

exit

#wmikm

_occupants = [_vehicle] call ukf_crew_mcar

{unassignVehicle _x} forEach _occupants

(_occupants) allowGetIn false

{_x action ["eject", _vehicle]} forEach _occupants

_vehicle lock true

_vehicle setobjecttexture [23, ""]

_vehicle setobjecttexture [24, ""]

_vehicle setobjecttexture [25, ""]

_vehicle setobjecttexture [26, "\ukf_wmik\lcamnet.pac"]

exit

#wmikmdes

_occupants = [_vehicle] call ukf_crew_mcar

{unassignVehicle _x} forEach _occupants

(_occupants) allowGetIn false

{_x action ["eject", _vehicle]} forEach _occupants

_vehicle lock true

_vehicle setobjecttexture [27, ""]

_vehicle setobjecttexture [28, ""]

_vehicle setobjecttexture [29, ""]

_vehicle setobjecttexture [30, "\ukf_wmik\ldcamnet.pac"]

exit

goodnight.gif

Share this post


Link to post
Share on other sites

ignore me for now... i think i may have solved it - i.e. done something else wrong whistle.gif

Share this post


Link to post
Share on other sites
Guest RKSL-Rock
ignore me for now... i think i may have solved it - i.e. done something else wrong  whistle.gif

Do you mind me asking how you got it to work in MP? I've got alot of setobjecttexture work int he Harrier and I'd like to make it more MP friendly if possible.

Share this post


Link to post
Share on other sites

well, im yet to try it in MP, waiting for our dedicated server admin to wake up and come on msn... then i'll be able to tell you more (i hope)

whistle.gif

Share this post


Link to post
Share on other sites

I think I've heard that animationphase doesn't work at all on a dedicated server (Well, it will always return '0'wink_o.gif. Or maybe it won't work on any client in MP when using a dedicated server. Or something. Basically, it won't work in MP.

As far as setobjecttexture, that might have to be done locally on every client in order for them to see it.

So, basically it looks like you will have to somehow broadcast the fact that the nets are being deployed. If player A deploys the nets, he will have to broadcast that fact to players B,C,D, etc. How exactly to broadcast this could get kinda tricky, especially if you have more than one active at a time. One way to do it:

Have ONE 'monitor' script running on every client's machine. No matter how many PUKF vehicles are placed on the map, make sure only ONE script gets run per client. This script looks exactly like the one you already have, only at the very top it has this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#top

@PUKF_camnet_deploy == PUKF_camnet_deploy

_vehicle = PUKF_camnet_deploy

_type = typeof _vehicle

PUKF_camnet_deploy = nil

?(_type == "UKF_WMIK") : goto "wmik"

....

You also need 'goto' statements that loop back to the beginning of this script (after deploying the nets).

Then, you have this in the 'action' script that is run by the player deploying the net (via useraction or scripted action):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">PUKF_camnet_deploy = _this select 0

publicvariable "PUKF_camnet_deploy"

That should run fine, although problems could arise if two vehicle's nets are deployed at almost the same time. If you want a totally rock-solid solution, then I'd use the CoC's Network Services, which could be used to solve this problem VERY easily (super easy).

Share this post


Link to post
Share on other sites
Quote[/b] ]I think I've heard that animationphase doesn't work at all on a dedicated server

Yeah it won't return the phase if called from the dedicated server, still works ok client side just not server side.

For every vehicle thats in a mission you can just run a looping script on each client, that checks for the presence of a speacial ammo type "UKF_StoredNet" or something. When then ammo is removed from the vehicle you can assume the cammo net has been deployed, or you to be safe side you can swap it for another magazine "UKF_DeployedNet"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This select 0

_CamStored="UKF_StoredNet" In (Magazines _Vehicle)

#L

~1

_CurrAmmo=Magazines _Vehicle

If _CamStored Then {If ("UKF_DepeloyedNet" In _CurrAmmo) Then {_CamStored=False; goto "DeployNet"}} Else {If ("UKF_StoredNet" In _CurrAmmo) Then {_CamStored=True; goto "StoreNet"}}

If (Alive _Vehicle) Then {goto "L"}

Exit

#DeployNet

.....Code goes here.....

goto "L"

#StoreNet

.....Code goes here.....

goto "L"

For your user action conditions:

Deploy Cammo

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">condition="""UKF_StoredNet"" In (Magazines This)";

Store Cammo

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">condition="""UKF_DeployedNet"" In (Magazines This)";

Either way will work and there are a couple more ways of doing it. But this way lets OFP handle the networking stuff using the Add and Remove ammo commands. Plus it does not matter how many jeeps you have running in game.

Although it's probably slightly quicker to check a global boolean in a loop, than it is to check a vehicles ammo.

Share this post


Link to post
Share on other sites

sounds like a good method. Killswitch is having a looking into getting it working, but i shall pass this on

cheers mate thumbs-up.gif

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
Sign in to follow this  

×