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

Linker Split

Member
  • Content Count

    902
  • Joined

  • Last visited

  • Medals

Everything posted by Linker Split

  1. Hello guys, I'm having a problem with a function which should return me an array of objects with they damage, but it's not working properly. The function I've written is: EPfn_saveInventory = { private["_array"]; _array = [] + _this; { if ((typeName _x) == "ARRAY") then { _item = _x select _forEachIndex; _type = typeOf _item; _dam = damage _item; _newArr = [_type,_dam]; _x set [_forEachIndex,_newArr]; } else { diag_log "THIS IS NOT AN ARRAY"; }; }forEach _array; _array }; It's called like this: _items = _items call EPfn_saveInventory; Where _items is an ARRAY of object a player got in his inventory. So I should fill the array of a tent with the objects that I put inside it. I must say that the line where the function is called, is a loop too.
  2. Hi guys! I'm creating a script that should save objects and their properties into an array dinamically (looping every 5 seconds) that must be used into another script. Basically, arguments are: _obj = a tent; _items = an empty array to be filled with objects; _arrItems: all the items the tent is already carrying; _nmbr = a number used to save and pick the correct tent from a function (which is out of interest here); _numToCheck = as above; _uniID = as above. The following two function are compiled within the init.sqf. I've made a function EPfn_saveInventory which must loop and check for new objects inside the tent: EPfn_saveInventory = { private["_obj","_items","_arrItems","_count","_i"]; _obj = _this select 0; _items = _this select 1; _arrItems = items _obj; _count = count _arrItems; _i = 0; if (_count == 0) exitWith {diag_log "NO OBJECTS INTO THE ARRITEMS"}; while {_i < _count} do { //private["_i"]; diag_log format["EPfn_saveInventory COUNT IS %1, _I is %2, ITEMS ARE %3",_count,_i,_arrItems]; _item = (_arrItems select _i); _type = typeOf _item; _Dam = damage _item; _qty = quantity _item; _newArr = [_type ,_Dam,_qty]; _items set [_i,_newArr]; sleep 1; _i = _i+1; }; diag_log format["EPfn_saveInventory ITEMS ARE %1",_items]; }; Passed arguments _obj, _items are from a function that (get looped by another script) which is EPfn_saveTentData. This function get looped because it must sve all the data of the tents. EPfn_saveTentData = { private ["_obj","_nmbr","_numToCheck","_uniID"]; _obj = _this select 0; _nmbr = _this select 1; _numToCheck = _this select 2; _uniID = _this select 3; _dam = damage _obj; _dir = direction _obj; _items = []; [b][color="#FF0000"][_obj,_items] spawn EPfn_saveInventory;[/color][/b] _type = typeOf _obj; _xPos = (getPosASL _obj) select 0; _yPos = (getPosASL _obj) select 1; _zPos = (getPosASL _obj) select 2; _globo = _obj getVariable ["globalID",[]]; _stringToPass = format["%1,%2,%3,%4,%5,%6,%7,%8,%9,%10",_uniID,_type,_nmbr,_numToCheck,_xPos,_yPos,_zPos,_dir,_dam,_items]; profileNameSpace setVariable [format["TENTOBJ%1",_nmbr],_stringToPass]; saveProfileNameSpace; }; All the data of the tents are saved (position, damage, type, ID etc.) but I can't get the objects that a player puts inside the tent. Indeed, the _stringToPass (which get saved like this: [TentMedium_Pitched,16,31,4708,10091.2,338.881,0,0,[]] in the profileNameSpace) has an empty [] at the end while there should be something like ["M16A2",0,0]. It doesn't see what is passed via EPfn_saveInventory (which instead gives me the correct data, I checked via diag_log). What am I doing wrong? #EDIT I show you the RPT: First line of EPfn_saveInventory is executed (correct) Second line of EPfn_saveInventory is executed (correct) which means that the code inside is correct Third line of EPfn_saveTentData is executed but not correct: _items is still empty [] Fourth line of EPfn_saveTentData is executed but not correct, cause last object of the big array should contain ["Consumable_Chemlight_Blue",0.769509,0]
  3. Linker Split

    Move to nearest Shore

    I assume _this select 0 is the chopper right? If so, you need to change the first line of you script: _chop = (_this select 0); _xpos = (getPosASL _chop select 0); _ypos = (getPosASL _chop select 1); if (surfaceIsWater [_xPos, _yPos]) then { YOUR CODE HERE };
  4. Linker Split

    Problem with spawn command

    Ok, I got it working. I modifed the function to be like this: EPfn_saveInventory = { private["_obj","_items","_arrItems","_count","_i"]; _obj = _this select 0; _items = []; _arrItems = items _obj; _count = count _arrItems; if (_count == 0) then { _items =[]; diag_log "NO OBJECTS INTO THE ARRITEMS"; } else { diag_log "THERE ARE OBJECTS INTO THE ARRITEMS"; for "_i" from 0 to (_count -1) do { _item = (_arrItems select _i); _type = typeOf _item; _Dam = damage _item; _qty = quantity _item; _newArr = [_type,_Dam,_qty]; _items set [_i,_newArr]; }; diag_log format["EPfn_saveInventory ITEMS ARE %1",_items]; }; _items }; And it's called with this line: _items = [_obj] call EPfn_saveInventory; . Now what I don't get is why is it saving string like this? [[color="#FF0000"]""[/color]Headtorch_Grey[color="#FF0000"]""[/color],0.428685,0],[[color="#FF0000"]""[/color]Crafting_MetalWire[color="#FF0000"]""[/color],0.536768,0]
  5. Hello all again what basically I'm asking, is if is there a way to spawn a player (not a unit) that got a unique UID, into the server, via script? I have some function (DBLoadPlayer, DBSavePlayer, DBServerSaveplayer and so on) that are called when a client is connecting to the game. Could I call these function directly from a script?
  6. thank you guys worked like a charm :)
  7. Hello again, I've created a script called GlobalPos.sqf in which there are all the positions I need in array format like this: _GlobalPOS = [ [3232,455,21], [576,65,80], [1232,1425,33], [4232,5455,90], [11232,8455,67] ]; Now If I want to call this array from another script, should I add something to GlobalPos.sqf?
  8. Guys, I did this: in the init.sqf I wrote down ChernogorskPOS = call compile preProcessFileLineNumbers (DZ_DIR_P + "ChernogorskPOS.sqf"); ChernogorskDIR = call compile preProcessFileLineNumbers (DZ_DIR_P + "ChernogorskDIR.sqf"); Then in a script (car.sqf) called from init.sqf, I wrote: _content1 = (call ChernogorskPOS select 4); _content2 = (call ChernogorskDIR select 21); diag_log format["GLOBALSPAWNINGSYSTEM: CONTENT IS %1, %2",_content1,_content2]; It returns me any, any even if I change to _content1 = (ChernogorskPOS select 4); _content2 = (ChernogorskDIR select 21); why? any suggestions? BTW the mission gets loaded correctly btw #EDIT btw, the sqf the variables are attached to are like this: [ [numbers,numbers,numbers]; [numbers,numbers,numbers]; [numbers,numbers,numbers]; [numbers,numbers,numbers]; [numbers,numbers,numbers]; [numbers,numbers,numbers]; [numbers,numbers,numbers]; ];
  9. Because it's not a single array, and an array contains about 200 position arrays inside, without considering the directional arrays saved, along with other info... it's a global spawn system for cars that goes with the persistent database :D I'm a bit inexperienced when coming to MP scripting (about declaring public variables, about trying to take rid of Hackers etc...)
  10. Ok Guys so basically the name of the variable should be declared into the init.sqf to be automatically public, and then in the sqf there should be only the array. Ok testing!
  11. Guys assuming my public Variable is ChernogorskPOS, once in another script should I call the content of this variable like this? _content1 = ChernogorskPOS select 0;
  12. Ok. So 'm removing the underscore. Should I make it public with publicVariableServer/client also? This file basically is used to spawn cars in random points selected from the array #EDIT also, I'm adding in the init.sqf this line: [] execVM "globalPos.sqf" is it right? Or should I compile it?
  13. If I understand it right, you are trying to spawn a player in an MP environment with given id, UID and name, but you don't know how to do this?
  14. Hello everybody. I'm making an MP mission for my friends. Basically, I have some cars, and they spawn randomly in the map. What I want to do is that even after restarting the server, we could find the cars in the place where we left them. So I thought to create a script that loops every 2 minutes that: 1) in the first moment it's running, creates a "spawn_memory.txt" file; 2) checks whatever the .txt has something written inside it, if so, load the data; 3) checks for cars if they are destroyed or not, then spawn the cars; 4) every 2 minutes wipes and re-writes in this .txt file some info about the cars (like position, status, fuel etc.); I know that points 2 and 3 are quite easy to make, the difficult part is to find a solution to 1 and 4. Anybody got something? Much appreciated Linker Split
  15. Linker Split

    Export text via script to a .txt file

    it looks like this: EP_fn_saveData = { private ["_car","_nmbr"]; diag_log "EP_fn_saveData.sqf is about to be executed"; _car = _this select 0; _nmbr = _this select 1; //Start saving position if (_nmbr == 1) exitWith { _xPos1 = ((getPosASL _car) select 0); // X COORDINATES _yPos1 = ((getPosASL _car) select 1); // Y COORDINATES _zPos1 = ((getPosASL _car) select 2); // HEIGHT COORDINATES _typeOf = typeOf _car; _d = direction _car // SAVING ALL VARIABLES profileNameSpace setVariable [format["xPos%1",_nmbr],_xPos1]; profileNameSpace setVariable [format["yPos%1",_nmbr],_yPos1]; profileNameSpace setVariable [format["zPos%1",_nmbr],_zPos1]; profileNameSpace setVariable [format["typeCar%1",_nmbr],_typeOf]; profileNameSpace setVariable [format["dirCar%1",_nmbr],_d]; saveProfileNameSpace; diag_log "EP_fn_saveData.sqf has finished executing"; }; }; ----------------------------------------------------- SOLVED: changed the code to: ----------------------------------------------------- EP_fn_saveData = { private ["_car","_nmbr"]; diag_log "EP_fn_saveData.sqf start loading"; _car = _this select 0; _nmbr = _this select 1; _typeOf = typeOf _car; _d = direction _car; profileNameSpace setVariable [format["xPos%1",_nmbr],((getPosASL _car) select 0)]; profileNameSpace setVariable [format["yPos%1",_nmbr],((getPosASL _car) select 1)]; profileNameSpace setVariable [format["zPos%1",_nmbr],((getPosASL _car) select 2)]; profileNameSpace setVariable [format["typeCar%1",_nmbr],_typeOf]; profileNameSpace setVariable [format["dirCar%1",_nmbr],_d]; saveProfileNameSpace; diag_log "EP_fn_saveData.sqf has finished executing"; };
  16. Linker Split

    Export text via script to a .txt file

    in my mission init.sqf there's: call compile preprocessFileLineNumbers "DBSave\EP_fn_saveData.sqf"; //========CAR.SQF LOAD==========\\ [] execVM (DIR_S + "Car.sqf"); EP_fn_saveData.sqf is the function with the data inside of corse, while car.sqf is the script for spawning cars. Inside this script, there's a check for the type of car, then the line [_vehicle1,_nmr] spawn EP_fn_saveData; where _vehicle1 is the create vehicle, and _nmr has been defined equal to 1 (other cars got 2, 3, 4...etc). diag_log works till this line
  17. Linker Split

    Export text via script to a .txt file

    A friend of mine is creating a little program that reads the info from the .vars file, writes them into the SQL. After that, when server restarts, it takes the data from the SQL and writes them down into a SQF that will be used to check for variables :D
  18. Linker Split

    Export text via script to a .txt file

    Cool, thank you! also, I'm trying to compile a function which ahs the following syntax: name_func = { _car = _this select 0; if (condition) exitWith {code}; if (condition) exitWith {code}; if (condition) exitWith {code}; if (condition) exitWith {code}; }; I'm compiling using this code in my init.sqf: call compile preprocessFileLineNumbers "nameofsqf.sqf"; Then, in the car script, I've added: [vehicle] spawn name_func; but its not working, so I think I'm failing to compile the function
  19. Linker Split

    Export text via script to a .txt file

    Guys I think that we have figured out how to get the variables ingame back after restart. one script question: if I want to assign a value to a variable in SQF, but it's dinamically changing, can I use this syntax: format["_xPos%1",_nmr] = ((getPosASL _car) select 0); In this way I can save _xPos1, _xPos2,_xPos3 and so on....
  20. Linker Split

    Export text via script to a .txt file

    yeah you are right, I was just checking for diag_log :D Anyway... seems that it's all ok, also because as said I'm running on a server (and I connect to it via remote desktop btw) So I really don't know what the problem is... :(
  21. Linker Split

    Export text via script to a .txt file

    problem is that when writig variables via setVriable, they got written in my .vars file. After shuting down the server, the .vars is still there with all the variables written inside (correctly written btw). So when I restart the server, and use the getVariable, it simply returns "any", "null".... wtf ahahha I'm going to use the if (!isServer) exitWith {diag_log "IS NOT SERVER!!!!!"}; ---------- Post added at 21:04 ---------- Previous post was at 20:31 ---------- I've put: if (!isServer) exitWith {diag_log "SERVER IS NOT SERVER!!!!!!!!!"}; if (isDedicated) exitWith {diag_log "DEDICATED IS NOT SERVER!!!!!!!!!"}; it pops up: "DEDICATED IS NOT SERVER!!!!!!!!!" What it means?
  22. mmm problem is that I have no player... XD It's not a physical player playing wrom around the world, still I want to emulate this
  23. Linker Split

    Export text via script to a .txt file

    Since I'm scripting for a MOD that got a looooot of scripts, you are suggesting me to go and check for what? I don't see any commands that deletes everything from the .vars profile... basically you are saying that a .vars got erased and overwritten instead of adding variables to the file?
  24. Linker Split

    Export text via script to a .txt file

    mmm... I'm thinking about copyToClipboard and LoadFromClipboard commands along with parsetext etc...
  25. Linker Split

    Export text via script to a .txt file

    What about the first post I wrote about passing variable to a .txt file? is it too much coding?
×