Jump to content
Sign in to follow this  
McArcher

strange behaviour

Recommended Posts

another problem...

I cannot take anything from crate!

double click or drag don't do anything and .rpt has following:

Magazine 30Rnd_545x39_AK (30 ammo left) not found

Magazine 30Rnd_545x39_AK (30 ammo left) not found

Magazine 30Rnd_545x39_AK (30 ammo left) not found

Magazine 30Rnd_545x39_AK (30 ammo left) not found

Magazine 30Rnd_545x39_AK (30 ammo left) not found

Edited by McArcher

Share this post


Link to post
Share on other sites

crate was created by client's script, by one of playable units. after this crate is placed, it is reachable, but after you reconnect to game (with this or other playable unit), its contents are unavailable, though crate is full of ammo and guns) .Why ?

Share this post


Link to post
Share on other sites

Try getting the server to run the script? Im not that great with all this locality stuff...

Share this post


Link to post
Share on other sites

Hi McArcher,

please try to fill the dynamically created crate within setVehicleInit, e.g.

_crate setVehicleInit "this addWeaponCargo ['whatever',4711]; this addWeaponCargo ..."; processInitCommands;

Share this post


Link to post
Share on other sites

Hi, Bon.

Actually I was doing this and everything seemed to be ok, but I have done something with my code and now it doesn't work, though I didn't modify crates' scripts:

that's the script that creates and fiils a crate: (but it is on client's side and this is maybe wrong)

// mca_deploy_ammunitionRU.sqf

// version 1.1c

if (not isServer) then

{

private ["_target", "_left", "_caller", "_crate", "_cratePos", "_initStr", "_angle"];

_target = _this select 0;

_caller = _this select 1;

if ( ( (side _caller) == east) and ( player == _caller) ) then

{

_left = _target getVariable "deploymentsLeft";

player groupChat format ["Examining Barracks building...", _left];//dbg////////////

if (_left > 0) then

{

// проверим, можно ли выгрузить Ñщик.

private ["_lastDeploy"];

_lastDeploy = _target getVariable "LastDeploy";

if ((time - _lastDeploy) < mcti_barracks_deployPause) exitWith { hint format["You must wait %1 seconds before next deployment.", (mcti_barracks_deployPause - (time - _lastDeploy))]; };

if (not(alive _obj)) exitWith { hint "The building is destroyed. It cannot be used anymore."; };

// запиÑÑŒ о текущей доÑтаваемой палатке

_target setVariable ["LastDeploy", time, TRUE];

// placing the crate

_angle = random (2 * pi);

_cratePos = [(position _target select 0) + 15 * cos (deg _angle), (position _target select 1) + 15 * sin (deg _angle)];

_crate = "RUVehicleBox" createVehicle _cratePos;

// adding crate to array

mcti_crates_RU = mcti_crates_RU + [_crate];

publicVariable "mcti_crates_RU";

// init

_initStr = " private [""_i""];clearMagazineCargo this; clearWeaponCargo this; _i = 0; { if (_x > 0) then { _crate addWeaponCargo [ mcti_weapons_pattern select _i, _x] }; _i = _i + 1; } forEach mcti_RUweapons_defaultNumbers; _i = 0; { if (_x > 0) then { _crate addMagazineCargo [ mcti_magazines_pattern select _i, _x] }; _i = _i + 1; } forEach mcti_RUmagazines_defaultNumbers; ";

_crate SetVehicleInit _initStr;

ProcessInitCommands;

// EH

_crate addEventHandler ["killed", { [_this, east] execVM "mca_onCrateDestroyed.sqf";}] ;

// reporting

_target setVariable ["deploymentsLeft", (_left - 1), TRUE]; // -1 crate left inside

_left = _target getVariable "deploymentsLeft";

hint format ["You have taken 1 crate of ammuniton out of barracks.\n%1 crates left in the building.", _left];

}

else // _left <= 0

{

hint format ["Sorry, no ammuniton left in this building.\nSearch in previosly taken crates nearby or build new barracks."];

};

}; //side

};

it didn't work for JIP and I added script that is run for JIP'ed players:

// mca_crate_init_JIP.sqf

// version 1.1c

if (not isServer) then

{

waitUntil {time > 1};

player groupChat "Initializing crates...";

private ["_i", "_crate"];

_n = 0;

{

clearMagazineCargo _x;

clearWeaponCargo _x;

_crate = _x;

_i = 0;

{

if (_x > 0) then { _crate addWeaponCargo [ mcti_weapons_pattern select _i, _x]; };

_i = _i + 1;

} forEach mcti_RUweapons_defaultNumbers;

_i = 0;

{

if (_x > 0) then { _crate addMagazineCargo [ mcti_magazines_pattern select _i, _x] };

_i = _i + 1;

} forEach mcti_RUmagazines_defaultNumbers;

} forEach mcti_crates_RU;

{

clearMagazineCargo _x;

clearWeaponCargo _x;

_crate = _x;

_i = 0;

{

if (_x > 0) then { _crate addWeaponCargo [ mcti_weapons_pattern select _i, _x]; };

_i = _i + 1;

} forEach mcti_USweapons_defaultNumbers;

_i = 0;

{

if (_x > 0) then { _crate addMagazineCargo [ mcti_magazines_pattern select _i, _x] };

_i = _i + 1;

} forEach mcti_USmagazines_defaultNumbers;

} forEach mcti_crates_US;

};

I wanted to make this script store crates' inventory in array and init JIP'ed (and other players) with up-to-date info about contents (it should be changed, but that time i understood that we didn't have functions to get the contents of vehicles and made this script only initialize crates with default numbers of weapons for JIPped players.. JIP players see contents, but cannot take it now :)

I hope Andy455 is right, and this is server/client issue..

---------- Post added at 21:34 ---------- Previous post was at 21:32 ----------

omg, I see "kiled" not "killed" EH for a crate... maybe it is a reason? :)

---------- Post added at 21:48 ---------- Previous post was at 21:34 ----------

well, "killed" EH didn't help :)

---------- Post added at 21:57 ---------- Previous post was at 21:49 ----------

Try getting the server to run the script? Im not that great with all this locality stuff...
It will be very complicated task... to run server's script from client's script (it will create a crate) and then from that server's run a client's again , to set "killed" EH (it is for client only , i guess?)... Edited by McArcher

Share this post


Link to post
Share on other sites

Hi McArcher,

clearWeaponCargo [color="Green"]this[/color]

but

[color="Red"]_crate[/color] addWeaponCargo [ mcti_weapons_pattern select _i, _x]

Share this post


Link to post
Share on other sites

yes.... maybe this was a mistake that didn't let it work, but I have already done server's script for creating crates...i found this mistake only when wrote server's script.... i found it too late, but big thanks :) now it works :)

---------- Post added at 23:25 ---------- Previous post was at 23:24 ----------

maybe it could even work without server's script, dunno )) but it's done:)

---------- Post added at 23:37 ---------- Previous post was at 23:25 ----------

nevertheless, thanx very much for your efforts!

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  

×