Jump to content
dlegion

createVehicle dedicated server problem

Recommended Posts

hi guys !
i've found an awesome script to enable dual primary weapons, that works really good, but has a little problem i noticed only after hours of play.
here the script:

Spoiler

if (!hasInterface) exitWith {};
waitUntil {time > 0};
waitUntil {!isNull player};
waitUntil {(!(isNull (findDisplay 46)))};

aa_fnc_spw =
{
weapHolder = "Weapon_Empty" createVehicle getPosATL player;
    weapHolder attachTo [player,[-0.1,-0.18,0.12],"pelvis"];
    weapHolder setVariable ["AA_Holster",true,true];
    weapHolder enableSimulation false;
    
    backWeaponAction = player addAction ["Take weapon back",{
    player action ["TakeWeapon", weapHolder, ((weaponCargo weapHolder) select 0)];
    if (primaryWeapon player != "") then {
    waitUntil {(count (magazinesAmmoCargo weapHolder) != 0)};
    {player addMagazine [_x select 0, _x select 1];} forEach (magazinesAmmoCargo weapHolder);
    clearMagazineCargoGlobal weapHolder;
    clearItemCargoGlobal weapHolder;
    clearBackpackCargoGlobal weapHolder;
    };
    },[],1,false,false,"",'(vehicle player == player) && (count (weaponCargo weapHolder) != 0) && (_this == player)'];
player addAction ["Put weapon on back",{
    player action ["PutWeapon", weapHolder, primaryWeapon player];
    waitUntil {(count (magazinesAmmoCargo weapHolder) != 0)};
    {player addMagazine [_x select 0, _x select 1];} forEach (magazinesAmmoCargo weapHolder);
    clearMagazineCargoGlobal weapHolder;
    clearItemCargoGlobal weapHolder;
    clearBackpackCargoGlobal weapHolder;
    },[],1,false,false,"",'(vehicle player == player) && (count (weaponCargo weapHolder) == 0) && (player hasWeapon (primaryWeapon player)) && (_this == player)'];    
};

uiSleep 1;                                   // D added

[] call aa_fnc_spw;

addMissionEventHandler ["EachFrame",{weapHolder setVectorDirAndUp [(player selectionPosition "spine3") vectorFromTo (player selectionPosition "rfemur"),[-0.1,-0.5,1]];}];
player addEventHandler ["AnimDone", {if (count (weaponCargo weapHolder) > 0) then {player setUserActionText [backWeaponAction, (getText (configfile >> "CfgWeapons" >> ((weaponCargo weapHolder) select 0) >> "displayName"))];}];
//player addEventHandler ["GetInMan", {if (!isNil "weapHolder") then {detach weapHolder; weapHolder setPos [0,0,0]}}];
//player addEventHandler ["GetOutMan", {if (!isNil "weapHolder") then {weapHolder attachTo [player,[-0.1,-0.18,0.12],"pelvis"];}}];
//player addEventHandler ["Respawn",{player call aa_fnc_spw;}];

 


...at start it works perfectly, i can die & respawn, go on vehicles or on foot, do everything and it works perfectly.
BUT.....after maybe 20 minutes i noticed my "weapon on back"  was gone, and script bugged (doesnt asked me to put my weapon on back, as usually.
from that day, it happened many other times, in fact i never noticed when the weapon disappear exactly, i just notice it only when i try to switch to my back weapon after many play time.
i've tracked down the problem standing still with a "weapon on back" for a long time, and seems it disappear at some point, removing the weapon model and the actions to "take weapon back" or "put weapon on back".
i'm pretty sure the problem is the loop that stop working, or maybe something to do with game auto-cleaner removing unused objects.

any idea?
thanks !

Share this post


Link to post
Share on other sites

Sorry, never mind.

 

Actually maybe check out Patriot821's comment on the wiki. He mentions running this in a non-scheduled environment, which may be the problem here.

Share this post


Link to post
Share on other sites

thanks bro, will check now!

after many test, seems it happen just on dedicated server....in SP it keep working properly after 1 hour !
on dedicated seems to happen between 10 to 15 minutes.
EDIT2- it happens exactly at 12 minutes. precisely.


EDIT --- your link send me to a page, but it says i've not the permission ! dunno!

Share this post


Link to post
Share on other sites

i'm hunting down the problem....and i discovered that using "createVehicleLocal"  instead of "createVehicle"  make it work longer than 12 minutes (i'm at 30minutes and still works).
the problem is that other people on server probably will not see the weapon i'm carrying on back, and thats not very good.
any ideas how fix this ?
thanks !!

Share this post


Link to post
Share on other sites

after many tests its now 100% clear that has something to do with createVehicle being global, and somehow ignored by the server after 12 minutes.
being it local (with createVehicleLocal) still works after 4 hours....now i just need help with the code to make sure other players see the other weapon carried on back !
thanks !!

Share this post


Link to post
Share on other sites

tested with a friend, confirmed that he cannot see my weapon on back.
need an idea about how fix this :)
 

Share this post


Link to post
Share on other sites

Is your server running a clean up script that deletes weapon holders regulary?

Share this post


Link to post
Share on other sites

No, i checked default cleanup system but its disabled, i use a Xeno Dominination edited by me, dunno if he integrated a cleanup somehow.

Good idea...i create a missionwith just that script to check this !

Thanks !

Share this post


Link to post
Share on other sites

First check confirm your theory !!! (Will conduct more tests later anyway, just to be 100% sure )

You are right man, nice shot, really thanks !!

Now...is there a way to exclude this weaponHolder from being deleted (by a mysterious Xeno script )?

Share this post


Link to post
Share on other sites

ok confirmed, i even found the point of cleaunp!

 

Spoiler


while {true} do {
    sleep (30 + random 15);                                                   // D was 300 + 150   TIME TO CLEANUP
    // TODO How to improve this? Means how to improve cleanup? AllmissionObjects is not the fastest engine command...
    private _allmisobjs = allMissionObjects "groundWeaponHolder";
    sleep 2;
//    private _helperx = allMissionObjects "WeaponHolder";                      // D original
    private _helperx = allMissionObjects "WeaponHolder_single_limited_weapon_F";  
    if !(_helperx isEqualTo []) then {
        _allmisobjs append _helperx;
    };
    sleep 2;
    //_helperx = allMissionObjects "WeaponHolderSimulated";
    _helperx = entities "WeaponHolderSimulated";
    if !(_helperx isEqualTo []) then {
        _allmisobjs append _helperx;
    };
    sleep 2;
    _helperx = allMissionObjects "WeaponHolder_Single_F";
    if !(_helperx isEqualTo []) then {
        _allmisobjs append _helperx;
    };
    sleep 2;
    _helperx = allMissionObjects "Chemlight_green";
    if !(_helperx isEqualTo []) then {
        _allmisobjs append _helperx;
    };


now... how edit it so the "weapon_empty" of the script does not get included?
thanks !!
 

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

×