Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

PixeL_GaMMa

Member
  • Content Count

    43
  • Joined

  • Last visited

  • Medals

Everything posted by PixeL_GaMMa

  1. PixeL_GaMMa

    AnL - Simple Arma 3 Server Tool

    As the title implies, I decided to put together a tool for me and my friends. I have many plans for improvements. But for now it is a basic and simple tool that gets the job done. It is designed to be simple and quick to use without any over complexity. A couple of screenshots: I want to share it with the community and will happily note any suggestions and requests. If you're interested in trying out a new tool, you can get it from https://colinstewart.pw/project/anl-13. Please bare in mind that this is the first initial version. It can be run from any directory, it does not have to placed inside of your Arma 3 installation directory. -Colin
  2. Back again with another function, Not sure if there are other string replacement routines, but I've quickly put this one together. Source // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private _return = ""; private _len = count _find; private _pos = _str find _find; while {(_pos != -1) && (count _str > 0)} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _find; }; _return + _str; }; Example: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplace; // Output: Arma is awesome, I love Arma! -Colin
  3. Can you show the sql statement you are passing? Or is this from first initialization of the library? Have you also placed the libmariadb files into Arma 3 directory? (required by the addon initialization process)
  4. BIS_fnc_spawnGroup returns a group ..... _grp = ...... call BIS_fnc_spawnGroup ; { .... } forEach (units _grp);
  5. Hi there, is it possible to grab the current vehicle seed of a randomized vehicle and load up that vehicle again? e.g. If i create a pickup truck and it randomizes it without 1 of the doors, is it possible to grab the state of that vehicle and re-load it at a later time? I already have persistence for vehicles, but it only stores damage level and class of the vehicle, but I would also like to store the current state/randomized version of that vehicle. -Colin
  6. PixeL_GaMMa

    vehicle randomization data

    After a short break away from screen, another look and I see my mistake, I forgot to add additional select 0 to all hit points array. { _veh setHitPointDamage [_x, (_hitPoints select _forEachIndex)]; } forEach ((getAllHitPointsDamage _veh) select 0) select 0; In-fact a better way would be { _veh setHitIndex [_forEachIndex, _x, false]; } forEach (_this select 5); Now it looks like damage is working, but a tire that is blown is back when re-loaded, I would have assumed the animation would correct this but it still does not work. :/ getting into the vehicle shows the wheels are damaged, but the physical model/animation for damage is not updated. OK, a bit re-ordering, and it seems to be working: // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir (_this select 2); _veh setFuel (_this select 3); _veh setMass (_this select 4); private _textures = (_this select 6); private _phaseData = (_this select 7); { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); { _veh setHitIndex [_forEachIndex, _x, false]; } forEach (_this select 5); _veh; };
  7. PixeL_GaMMa

    vehicle randomization data

    Yes, it is executed directly on server as it is created (see function above)
  8. PixeL_GaMMa

    vehicle randomization data

    I've just updated my game mode to use the new functions, but it seems setHitPointDamage doesn't work globally, any idea what the problem could be?
  9. PixeL_GaMMa

    vehicle randomization data

    Excellent idea, we could also add per hit point damage // // PX_fnc_getVehicleState :: Get vehicles current state - Note: this does not save inventory // Author: Colin J.D. Stewart // Usage: _stateblock = _vehicle call PX_fnc_getVehicleState; // PX_fnc_getVehicleState = { [ typeOf _this, getPosATL _this, getDir _this, fuel _this, getMass _this, (getAllHitPointsDamage _this) select 2, getObjectTextures _this, animationnames _this apply {_this animationPhase _x} // thanks Grumpy Old Man here for help ]; }; // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir (_this select 2); _veh setFuel (_this select 3); _veh setMass (_this select 4); private _hitPoints = (_this select 5); { _veh setHitPointDamage [_x, _hitPoints select _forEachIndex]; } forEach (getAllHitPointsDamage _veh) select 0; private _textures = (_this select 6); private _phaseData = (_this select 7); { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); _veh; };
  10. PixeL_GaMMa

    vehicle randomization data

    OK just put these together, not tested since my game mode doesn't use them directly like this, but they should work Source // // PX_fnc_getVehicleState :: Get vehicles current state - Note: this does not save inventory // Author: Colin J.D. Stewart // Usage: _stateblock = _vehicle call PX_fnc_getVehicleState; // PX_fnc_getVehicleState = { [ typeOf _this, getPosATL _this, getDir _this, fuel _this, getMass _this, damage _this, getObjectTextures _this, animationnames _this apply {_this animationPhase _x} // thanks Grumpy Old Man here for help ]; }; // // PX_fnc_createVehicle :: Creates a vehicle from state array block via PX_fnc_getVehicleState // Author: Colin J.D. Stewart // Usage: _stateblock spawn PX_fnc_createVehicle; // PX_fnc_createVehicle = { private _veh = createVehicle [_this select 0, _this select 1, [], 0, "FORM"]; _veh enableSimulationGlobal true; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir _this select 2; _veh setFuel _this select 3; _veh setMass _this select 4; _veh setDamage _this select 5; private _textures = _this select 6; private _phaseData = _this select 7; { _veh setObjectTextureGlobal [_forEachIndex, _x]; } forEach _textures; { _veh animate [_x, (_phaseData select _forEachIndex)]; } forEach (animationNames _veh); _veh; }; There are probably many improvements could be made here, but it's a start :) Best Regards, Colin
  11. PixeL_GaMMa

    vehicle randomization data

    Yep, but when the vehicle is saved (persistently) I can just do a getMass _veh; save this and when the vehicle is loaded, apply the animation data and then setMass ... etc Edit: Implemented and tested, along with getObjectTextures, it all works perfectly, thanks again for help, I will post the functions soon :)
  12. PixeL_GaMMa

    vehicle randomization data

    Yep, ideally it would be a single seed for a vehicle, how i do it in some of my procedural projects is have a seed that can be re-used. When the vehicle is generated, it is generated using a specific random seed/number, then if that seed is used again it would be generated in the exact same way, in which case it would be as simple as saving a single number and re-using it when calling createVehicle, that would have been perfect. Your code actually may be ideal, I can also just store a total of the mass rather than iterate the missing pieces. I assume the centre of mass also changes depending on this? Thanks for your help :) p.s. I already wrote a setCargoLoadout and getCargoLoadout which is ideal for vehicles and cargo boxes, I will release it once I make some improvements probably. :)
  13. _this addEventHandler ["ContainerClosed", { .... etc As the title.... is it possible to get this event to fire server side? or will it only fire on the client?
  14. Yep I'm thinking about using InventoryClosed which can then remote call server side function (assuming, it is the correct type of container) ... probably this will be fine. Thanks again.
  15. The problem with this is containers are dynamic and can be 100s, so to add event handler to all containers on all clients would be too much, I will try to come up with an alternative method. Thanks for help.
  16. ok thanks will do some tests.
  17. Will this still work if the event is assigned from the server? (wiki says it is global)
  18. I want to fire a server only function when a container is closed (specifically in this case a vehicle), without relying/trusting the client to call the function remotely....
  19. PixeL_GaMMa

    quick stringReplace

    yep, check third param of BIS_fnc_splitString
  20. PixeL_GaMMa

    quick stringReplace

    Awesome, thanks, I think it is good enough.... I did experiment with split string and join, it can be done but it does not perform very well. But i will add it here anyway. PX_fnc_splitReplace = { params["_str", "_find", "_replace"]; private _result = ([" "+_str+" ", _find, true] call BIS_fnc_splitString) joinString _replace; _result select [1, (count _result)-2]; }; The reason for the spaces is because bis splitstring will remove the found words if they are at the start or end of the string.
  21. PixeL_GaMMa

    quick stringReplace

    Yep, I considered writing a plugin in Ziron (assembly), but the main issue being that this could only be used server-side, unless users are willing to install a client side plugin (most people, especially new-comers are oblivious how to do that) -so the only alternative is to write optimised sqf :)
  22. PixeL_GaMMa

    quick stringReplace

    Grumpy Old Man: Loops will always be better than recursive calls in the long run, and your function does not replace multiple keys :P MuzzleFlash: I would be interested to see these added to your variation of tests :) // // PX_fnc_stringReplaceEx :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx", "Arma"] call PX_fnc_stringReplaceEx; // PX_fnc_stringReplaceEx = { params["_str", "_find", "_replace"]; private _pos = _str find _find; if (_pos == -1) exitWith {_str}; private _return = ""; private _len = count _find; while {_pos != -1} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _find; }; _return + _str; }; // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx" || [], "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private["_return", "_len", "_pos"]; if (!(_find isEqualType [])) then { _find = [_find]; }; { _pos = _str find _x; if (_pos != -1) then { _return = ""; _len = count _x; while {_pos != -1} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _x; }; _str = _return + _str; }; } forEach _find; _str; };
  23. PixeL_GaMMa

    quick stringReplace

    another could be multi-line listbox tooltips, replacing <br /> to \n for it to work :) _hint = [getText(configFile >> "CfgMagazines" >> _class >> "descriptionShort"), ["<br />", "<br/>"], "\n"] call PX_fnc_stringReplace; >
  24. PixeL_GaMMa

    quick stringReplace

    A quick update that I required today for replacing multiple strings with value: // // PX_fnc_stringReplace :: Replace substrings // Author: Colin J.D. Stewart // Usage: ["xxx is awesome, I love xxx!", "xxx" || [], "Arma"] call PX_fnc_stringReplace; // PX_fnc_stringReplace = { params["_str", "_find", "_replace"]; private["_return", "_len", "_pos"]; if (!(_find isEqualType [])) then { _find = [_find]; }; { _return = ""; _len = count _x; _pos = _str find _x; while {(_pos != -1) && (count _str > 0)} do { _return = _return + (_str select [0, _pos]) + _replace; _str = (_str select [_pos+_len]); _pos = _str find _x; }; _str = _return + _str; } forEach _find; _str; }; This will allow: ["abc<br>def<br />ghi<br/>jkl!", ["<br>", "<br/>", "<br />"], "\n"] call PX_fnc_stringReplace; In the scenario above, there are better ways to accomplish this, but this is the lazy and easy way :)
  25. So I noticed there was no lnbSetTooltip and upon using lbSetTooltip it seems it takes columns into consideration too, this can be quite confusing at times and easy to forget. If anyone else has this problem, I've made a tiny function to relieve the stress and add the missing lnbSetTooltip // // API missing function lnbSetTooltip for usage with ListNBox // Author: Colin J.D. Stewart. // usage: [ctrl, index, colcount, "text"] call lnbSetTooltip; // lnbSetTooltip = { params["_ctrl", "_index", "_cols", "_text"]; _ctrl lbSetTooltip [_index + ((_cols-1)*_index), _text]; }; Params: _ctrl = the ListNBox control _index = the index of the row via addRow _cols = how many columns your listnBox has declared. _text = the obvious, the text you want for the tooltip [_row, 5, 3, "My tooltip"] call lnbSetTooltip; Result: You could optimise this by changing this into a preprocessed macro instead. Or maybe I am missing something? I was unable to find any other lnb functions though. -Colin
×