Jump to content

BomboBombom

Member
  • Content Count

    38
  • Joined

  • Last visited

  • Medals

Everything posted by BomboBombom

  1. * req. = require. Hello there to everyone, I'm fairly new to the scripting but have been attempting to do quite a few things over the night using script that I found searching both here and in other areas. I've managed to make a few things work but almost nothing as I want it to work. I've got; - Weapon crates with all available weapons, these are supposed to recharge every 5 minutes. I do believe they do, in either case there are 30 of each weapon so I do not mind. - Vehicles that respawn, but they respawn if you drive them out of their original location and leave the vehicle for x-seconds. I only want respawns if all passangers die or the vehicle is completely destroyed. - Units that patrol around their spawned areas. They work fine for their purpose but they won't respawn as the script maker says they should. I've lowered the "safe-range" as well as the respawn timer to 5 sec to try it out. (after a closer look I partly figured how to spawn them units, however the script bugs out somewhere and some of the spawns stop working eventually and still random model/pistol etc remains) # Trying to get vehicles to respawn as explained above, not simply since there is no longer anyone in them. Unmanned vehicles could respawn 120 sec if the driver is x-meters from it, thus assuming it is no longer loved and respawns back home to start a new life. # Trying to get unit groups to respawn about 45 sec after all members have been taken out. Would like single unit respawn script, but this could be annoying. However their purpose is simply to be resistance as you are being chased by an chopper. # A wishful thought. If and when I got units to work I wanted to make it so that units would randomly spawn within a certain range of where a player is currently located, also only at houses of any sort in groups of 1 to #whateveriplease units. Equiped with a set inventory or from an array at random pick. Atm all units are only allowed 1911s as I do not want them wearing heavy duty AKMs. # About mission # The mission I'm trying to poke is a mission where 2 or more people spawn far up on the Chernarus-map and one spawns on an airfield with gun-mounted choppers which he will use to attempt to chase down the players. The players at the top of the map need to get to either of the biggest towns on the map without dieing. They are allowed to fire at the chopper, but only have a limited choice of light weapons. On their way down they will run into pistol armed resistance attempting to slow them down or even kill them, but stopping in towns can be rewarding as there can be gun-mounted pickups or new weapons and ammo. # What I've done, used and tested so far # *ammo crates script link (not allowed) - Works fairly well, not as initially explained but eventually. * house patrol script (link not allowed) - These worked right of the bat pretty much. Not really "patrolling" that much, but moving around well enough for their purpose. * Simple-Vehicle-Respawn-Script - The script is explained in the post. I've not found a better alternative, probably missed it. * kronzky homepage - Patrol. Respawn script.. Not sure where it is. * Other than that I'm using the description.ext for basic respawns, the only problem with that is that it re-equips respawned npcs with too heavy artillery. Want to be bare and use the crates to equip myself. (except the crates will be cleared and filled with light weapons once map works as it should) * Funny how while writing this respawn started working.. After some tweaks quite good. But the random function doesn't work. - Sorry for not posting code. Not sure if it is ok posting the sources to the creators sqf-files. However kronzky did have a vehicle spawner, but one for manned spawns. Not unmanned. I've used -showScriptErrors or w/e it is and it doesn't report errors. Additionally with the latest beta patch all explosives, exploding or not, crashes the entire client for me. Fired from choppers or any other vehicle crashes me. :| Cheers. (starting to pass out, will post)
  2. //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private [_house,_spots,_chance]; _house=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=[]; _guns=[]; _rchance=0; _cpos=[]; _veh=; while (_count <= _spots) do { _cpos=_house buildingPos _count; _veh=(_cpos nearObjects ["WeaponHolder",1]); if (!isNil _veh) then { deleteVehicle _veh }; if ((random 100) <= _chance) then exitWith{}; _wph="WeaponHolder" createvehicle _cpos; _rchance=random 100; _gunADD=[_rchance] call RESIDENTIAL_GUNS; _wph addWeaponCargo [_gunADD select 0,1]; _wph addAmmoCargo [_gunAdd select 1,3]; _count=_count + 1; sleep 0.01; }; I keep editing this script but keep getting told that I am missing a ; in it. I've looked through it and can't see where. Could this be related to the other functions executed? If so, I'll post those too. Sorry, wrong section. I didn't see.
  3. BomboBombom

    Function script problems

    @Tonic-_-: Thank you. I found a way to solve the issue. - Quickest way to determine loot tables?: SWITCH _table=_building getVariable "TABLE"; switch (_table) do { case "MIL": { _spots=_building getVariable "SPOTS"; while { _count < _spots } do { the loot table code/function }; }; case "RES": { blablabla.. }; }; - Case would compare swifly due to that it only searches for the compareable string? IF _table=_building getVariable "TABLE"; _spots=_building getVariable "SPOTS"; if (_table=="RES") then { while {_count<_spots} do { that code again }; }; if (_table=="MIL") then { other code stuff.. }; - If may be slower due to that it will compare all cases? Dynamic call. _table=_building getVariable "TABLE"; _spots=_building getVariable "SPOTS"; [_building,_table,_spots] call fnc_lootSpawn; - fnc_lootSpawn would contain either the case or if version of the table spawn script and be preprocessed. # Optimization ideas - setVariable ["SPOTARRAY",(all lootspots variable)]; And then use forEach _SPOTARRAY; to go through the locations after initiation. Even higher optimization in the future could be using preprocessed locations. - Preprocess spots. - Reduce spots used. - Full custom spots preprocess list. (A lot of work) - Avoiding overuse of script for spawning objects. Right now the script uses quite a lot of script to spawn one weaponholder. Would enjoy lowering that. ? Any way to generate a preprocessed location list or function script by using DIAG_LOG(or w/e it was called)? Cheers.
  4. BomboBombom

    Function script problems

    I don't understand why setPos doesn't care about the height that the object is at. When I try using the chicken method for determining floor height it still puts the weaponHolder on the ground. Even after I do setPos after createvehicle. -_-; +++ Solved. /* */ sleep 2; titleText ["View the map to see the markers and types of buildings found.","plain down"]; fnc_getbuildType = compile preprocessFile "fnc_getBuildType.sqf"; sleep 1; //finds buildings closeby _builds = nearestObjects [player,["Building"],500]; _id = 0; _idees = []; for "_i" from 0 to ((count _builds)-1) do { _build = _builds select _i; if (format["%1",_build buildingPos 0]!="[0,0,0]") then { _type = typeOf _build; hint format["Building: %1 Type: %2 Loot: 0",_type,_build]; _count=0; while { format["%1",_build buildingpos _count]!="[0,0,0]" } do { hint format["Building: %1 Type: %2 Loot: %3",_type,_build,(_count+1)]; _gpos=_build buildingPos _count; _cock="Hen" createVehicle _gpos; _cock setPosATL _gpos; _gpos=getPosATL _cock; deleteVehicle _cock; _wph="WeaponHolder" createVehicle _gpos; _wph addWeaponCargo ["M16A2",5]; _wph addMagazineCargo ["30Rnd_556x45_Stanag",10]; _wph setPosATL [_gpos select 0,_gpos select 1,1]; _wph setPosATL [getPos _wph select 0,getPos _wph select 1,(getPosATL _wph select 2)-(getPos _wph select 2)]; _ris=getPosATL _wph select 2; while {_ris<_gpos select 2} do { _ris=_ris+0.01; _wph setPosATL [_gpos select 0,_gpos select 1,_ris-0.005];}; _count=_count+1; }; _typ = [_build] call fnc_getbuildType; _idees set [count _idees,_typ]; hint format ["Type: %1",_typ]; _mrkr = format ["mkr_%1_%2", diag_ticktime,_i]; _m = createMarkerLocal [_mrkr, position _build]; _m setMarkerShape "ICON"; _m setMarkerColorLocal "colorORANGE"; _m setMarkerTypeLocal "mil_dot"; _m setMarkerSizeLocal [1, 1]; //_m setMarkerAlphaLocal 0.2; _m setMarkerTextLocal format ["%1 Name: %2",_typ,_type]; }; sleep 0.01; }; - This is currently experimental. The _ris part will be removed eventually. - Part 2 of tests initiated. Part 2 Will be moving this to a later stage, right now I'm going to rewrite spawn list and such - Adding custom loot location to buildings lacking. @ Figure out how to position objects according to a structures facing angle thus placing objects correctly no matter what direction a structure is facing. # Current buildings lacking buildingPos locations that I require: - Land_A_MunicipalOffice : Has about 6 positions preset. None on roof. - Land_A_Hospital : Has 0 positions preset. None inside, nor on the roof.
  5. BomboBombom

    Function script problems

    I've edited the script provided Twirly, experimenting with how to do a good item spawn system trying to get the weaponholder positioning working properly. I decided to try and move one position up a bit as it was ending up on the staircase and the weaponholder wouldn't angle itself. removed ** updated in next post ** I'm experimenting with loot positions. The code works for one building, but if I angle the building it fails. I'll go back to solving the original positions rather than custom ones. Tomorrow I will continue and keep on track. ;p Thanks again and have a good night/day/afternoon/evening, cheers~
  6. BomboBombom

    Function script problems

    @Shuko: Thanks, I may implement the suggested if needed. Twirly's post seem to contain what is needed. @Twirly: Fantastic Twirly, I am testing the demo mission to see how it works. Thanks :)
  7. BomboBombom

    Function script problems

    Trying to read typeOf string value and determine building type by "Land_Ind_" in "Land_Ind_Mlyn_02" for example. Then _house setVariable ["Type","IND"]; for industrial buildings. Can not figure out what commands reads a string and I've been looking through comref and searched google some for a method, but found nothing. I do remember seeing some sort of method using forEach, where it would go through each letter of a string. ---------- Post added at 19:14 ---------- Previous post was at 19:07 ---------- Shuko: I use Squint, even after fixing various problems in my old script it didn't work. Couldn't figure why it stopped working. Probably some tweak that messed it up. I gave up and am rewriting it all.
  8. BomboBombom

    Function script problems

    thank you twirly. That will probably save me quite some time.
  9. BomboBombom

    Function script problems

    Well, oddly enough it remains outputting nothing. using function or sqf, neither one. I wish I knew what broke everything. Unable to find why no matter what _output will never transfer out of the function and into the value. It did work, for a brief period of time. I completely removed the "NIL" as it wont be used in either case. ## Will be attempting to rewrite the whole script and use dynamic search of structures and the locations in the structures. Can't contemplate functions well atm. Current code, for those who are curious: Trigger loop; Trigger 1. Condition: true On act. conditiontime=time; Trigger 2. Condition: conditiontime<time hint format["%1 , %2",conditiontime,time]; if ( format["%1",oo] == "any" ) then { objects=[];oo=thistrigger nearObjects ["building",triggerarea thistrigger select 0]; { if !(format["%1",_x buildingPos 0]=="[0,0,0]") then {objects=objects+[_x]; }; }forEach oo; oo=[]; {if (["MAKELOOT",getPos _x] call fnc_InMarker) then { oo=oo+[_x]; }; }forEach objects;}; if (format["%1",houses]=="any") then { {houses=houses+([_x,houses] call fn_Loota select 1); }forEach oo; } else { {null=[_x] call fnc_Loota;}forEach houses; }; conditiontime=time+(25*1); Trigger 2 is missing a few things. I'll change it and run the "oo" building array through the function instead later. fnc_Loots private ["_building","_loots","_dummy","_spot"]; _building=_this select 0; _loots=[]; _count=0; _dummy=""; _spot=[]; while {format["%1",_house buildingPos _count]!="[0,0,0]} do { _spot=_house buildingPos _count; _dummy="Hen" createVehicle [_spot select 0,_spot select 1,(_spot select 2)+5; sleep 0.5; _spot=getPos _dummy; deleteVehicle _dummy; _loots=_loots+_spot; _count=_count+1; }; _loots fnc_Loota private ["_house","_houses","_search","_locations","_out"]; _house=_this select 0; _houses=_this select 1; _search=typeOf _house; _locations=[]; _out=[]; if !(_search in _hosues) then { _locations=[_house] call fn_Loots; }; _house setVariable ["SPAWNS",_locations]; _out=[_house,_search]; _out The goal with the code is to get an array of the loot locations in all buildings. The original ones do not work like they should. WeaponHolder's in bars end up under ground even when raised above slightly and perfectly placed in other buildings. Spawning these hen's and letting them fall will allow for an location "on" the floor. A lot of tweaks and changes will be needed, but eventually I hope to be able to post a good array of values. One day... Good night (21:52 pm, 15/10/2012)
  10. BomboBombom

    Function script problems

    the if(format["%1",_input]=="any") then (_output=[0,"NIL",0];}; is for all buildings I do not have listed, so it is sort of an "else" oh wait... I see my problem there. It should be ["%1",_output]=="any" ,, ~facepalm~ Oh lord, the little things I miss. Thanks :p
  11. BomboBombom

    Function script problems

    a call inside of a call can not return a value? I'm asking because inside of the called call, the value output is working but outside it isn't returning anything. _type=[_data] call fn_getLootData; I call it as this. It calls getLootData. //fn_getLootData private["_input","_output"]; _input=_this select 0; _output=[]; //RESIDENTIALS if (_input=="Land_HouseV_1I4") then {_output=[3,"RES",40];}; if (_input=="Land_kulna") then {_output=[2,"RES",40];}; if (_input=="Land_hut06") then {_output=[2,"RES",40];}; if (_input=="Land_Hlidac_budka") then {_output=[3,"RES",40];}; if (_input=="Land_HouseV2_02_Interier") then {_output=[8,"RES",40];}; if (_input=="Land_A_Pub_01") then {_output=[20,"RES",40];}; if (_input=="Land_Shed_wooden") then {_output=[2,"RES",40];}; if (_input=="Land_HouseBlock_A1_1") then {_output=[2,"RES",40];}; if (_input=="Land_HouseV_1I1") then {_output=[1,"RES",40];}; if (_input=="Land_A_MunicipalOffice") then {_output=[14,"RES",40];}; if (_input=="Land_ruin_01") then {_output=[4,"RES",40];}; if (_input=="Land_HouseV2_04_interier") then {_output=[7,"RES",40];}; if (_input=="Land_HouseV2_01A") then {_output=[2,"RES",40];}; if (_input=="Land_psi_bouda") then {_output=[1,"RES",40];}; if (_input=="Land_KBud") then {_output=[1,"RES",40];}; if (_input=="Land_A_Castle_Bergfrit") then {_output=[12,"RES",40];}; if (_input=="Land_A_Castle_Stairs_A") then {_output=[3,"RES",40];}; if (_input=="Land_A_Castle_Gate") then {_output=[5,"RES",40];}; if (_input=="Land_sara_domek_zluty") then {_output=[9,"RES",40];}; //Churches, residential. if (_input=="Land_Church_01") then {_output=[1,"RES",40];}; if (_input=="Land_Church_03") then {_output=[12,"RES",40];}; //OFFICE if (_input=="Land_HouseB_Tenement") then {_output=[5,"OFF",40];}; if (_input=="Land_Panelak") then {_output=[13,"OFF",40];}; if (_input=="Land_Panelak2") then {_output=[12,"OFF",40];}; if (_input=="Land_rail_station_big") then {_output=[9,"OFF",40];}; if (_input=="Land_A_Office01") then {_output=[31,"OFF",40];}; if (_input=="Land_A_Office02") then {_output=[2,"OFF",40];}; //INDUSTRIAL if (_input=="Land_Ind_Workshop01_01") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Garage01") then {_output=[4,"IND",30];}; if (_input=="Land_Ind_Workshop01_02") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Workshop01_04") then {_output=[7,"IND",30];}; if (_input=="Land_Ind_Workshop01_L") then {_output=[7,"IND",30];}; if (_input=="Land_Hangar_2") then {_output=[7,"IND",30];}; if (_input=="Land_A_FuelStation_Build") then {_output=[4,"IND",30];}; if (_input=="Land_Shed_Ind02") then {_output=[5,"IND",30];}; if (_input=="Land_Misc_PowerStation") then {_output=[2,"IND",30];}; if (_input=="Land_Shed_W01") then {_output=[1,"IND",30];}; if (_input=="Land_Tovarna2") then {_output=[23,"IND",30];}; if (_input=="Land_Ind_Vysypka") then {_output=[9,"IND",30];}; if (_input=="Land_A_houseWIP") then {_output=[29,"IND",30];}; if (_input=="Land_A_TVTower_Base") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Ao") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Bo") then {_output=[3,"IND",30];}; if (_input=="Land_Nav_Boathouse") then {_output=[9,"IND",30];}; if (_input=="Land_wagon_box") then {_output=[3,"IND",30];}; if (_input=="Land_Rail_House_01") then {_output=[3,"IND",30];}; //FARM if (_input=="Land_stodola_old_open") then {_output=[12,"FRM",30];}; if (_input=="Land_Farm_Cowshed_a") then {_output=[7,"FRM",30];}; if (_input=="Land_stodola_open") then {_output=[4,"FRM",30];}; if (_input=="Land_Barn_W_01") then {_output=[6,"FRM",30];}; if (_input=="Land_Barn_W_02") then {_output=[6,"FRM",30];}; //SUPERMARKET if (_input=="Land_Rail_House_01") then {_output=[24,"SPM",30];}; if (_input=="Land_Rail_House_01") then {_output=[23,"SPM",30];}; //HOSPITAL if (_input=="Land_A_Hospital") then {_output=[12,"HOS",90];}; if (_input=="USMC_WarfareBFieldhHospital") then {_output=[5,"HOS",40];}; //MILITARY if (_input=="Land_Mil_Guardhouse") then {_output=[2,"MIL",30];}; if (_input=="Land_a_stationhouse") then {_output=[10,"MIL",30];}; if (_input=="Land_Mil_ControlTower") then {_output=[6,"MIL",40];}; if (_input=="Land_SS_hangar") then {_output=[3,"MIL",40];}; if (_input=="Land_Mil_House") then {_output=[3,"MIL",40];}; if (_input=="Land_Misc_deerstand") then {_output=[2,"MIL",50];}; if (_input=="Camp") then {_output=[2,"MIL",40];}; if (_input=="CampEast") then {_output=[2,"MIL",40];}; if (_input=="CampEast_EP1") then {_output=[3,"MIL",40];}; //BARRACK if (_input=="Land_Mil_Barracks_i") then {_output=[12,"BRK",40];}; if (format["%1",_input]=="any") then {_output=[0,"NIL",0];}; _output
  12. BomboBombom

    Function script problems

    I'm starting to grow one hell of a headache. :p So.. it started working but I do not know why it started working. It worked for a while.. it stopped working again.. I do not know why it stopped working again. I have a function called, inside of the function it can create the output, but outside of the function it can't. //FN_MAKELOOT private["_house"]; _house=_this select 0; _type=[]; _lootData=""; _data=typeOf _house; //Mega scary exploding town. START //sleep ((random 30) + (random 30) + (random 30) + (random 30) + (random 30) + (random 30) + (random 30) + 10); //b="Bo_GBU12_LGB" createVehicle (_house buildingPos (random 1)); //sleep 0.1; //deleteVehicle b; //Mega scary eploding town. END if !(format["%1",_house getVariable "Lootable"] == "<null>") then { _type=_house getVariable "Data"; } ELSE { //Set: Lootable _type=[_data] call fn_getLootData; }; if !(format["%1",_type]=="any") then { hint format["OUTPUT WORKED! %1",_type]; }; //Not <_< if (format["%1",_type]=="any") exitWith{}; switch (_type select 1) do { //RESIDENTIALS case "RES": { null=[_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case "OFF": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case "IND": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case "FRM": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case "HOS": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case "MIL": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case "BRK": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case "CHC": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; //fn_getLootData private["_input"]; _input=_this select 0; //_output=""; //RESIDENTIALS if (_input=="Land_HouseV_1I4") then {_output=[3,"RES",40];}; if (_input=="Land_kulna") then {_output=[2,"RES",40];}; if (_input=="Land_hut06") then {_output=[2,"RES",40];}; if (_input=="Land_Hlidac_budka") then {_output=[3,"RES",40];}; if (_input=="Land_HouseV2_02_Interier") then {_output=[8,"RES",40];}; if (_input=="Land_A_Pub_01") then {_output=[20,"RES",40];}; if (_input=="Land_Shed_wooden") then {_output=[2,"RES",40];}; if (_input=="Land_HouseBlock_A1_1") then {_output=[2,"RES",40];}; if (_input=="Land_HouseV_1I1") then {_output=[1,"RES",40];}; if (_input=="Land_A_MunicipalOffice") then {_output=[14,"RES",40];}; if (_input=="Land_ruin_01") then {_output=[4,"RES",40];}; if (_input=="Land_HouseV2_04_interier") then {_output=[7,"RES",40];}; if (_input=="Land_HouseV2_01A") then {_output=[2,"RES",40];}; if (_input=="Land_psi_bouda") then {_output=[1,"RES",40];}; if (_input=="Land_KBud") then {_output=[1,"RES",40];}; if (_input=="Land_A_Castle_Bergfrit") then {_output=[12,"RES",40];}; if (_input=="Land_A_Castle_Stairs_A") then {_output=[3,"RES",40];}; if (_input=="Land_A_Castle_Gate") then {_output=[5,"RES",40];}; if (_input=="Land_sara_domek_zluty") then {_output=[9,"RES",40];}; //Churches, residential. if (_input=="Land_Church_01") then {_output=[1,"RES",40];}; if (_input=="Land_Church_03") then {_output=[12,"RES",40];}; //OFFICE if (_input=="Land_HouseB_Tenement") then {_output=[5,"OFF",40];}; if (_input=="Land_Panelak") then {_output=[13,"OFF",40];}; if (_input=="Land_Panelak2") then {_output=[12,"OFF",40];}; if (_input=="Land_rail_station_big") then {_output=[9,"OFF",40];}; if (_input=="Land_A_Office01") then {_output=[31,"OFF",40];}; if (_input=="Land_A_Office02") then {_output=[2,"OFF",40];}; //INDUSTRIAL if (_input=="Land_Ind_Workshop01_01") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Garage01") then {_output=[4,"IND",30];}; if (_input=="Land_Ind_Workshop01_02") then {_output=[3,"IND",30];}; if (_input=="Land_Ind_Workshop01_04") then {_output=[7,"IND",30];}; if (_input=="Land_Ind_Workshop01_L") then {_output=[7,"IND",30];}; if (_input=="Land_Hangar_2") then {_output=[7,"IND",30];}; if (_input=="Land_A_FuelStation_Build") then {_output=[4,"IND",30];}; if (_input=="Land_Shed_Ind02") then {_output=[5,"IND",30];}; if (_input=="Land_Misc_PowerStation") then {_output=[2,"IND",30];}; if (_input=="Land_Shed_W01") then {_output=[1,"IND",30];}; if (_input=="Land_Tovarna2") then {_output=[23,"IND",30];}; if (_input=="Land_Ind_Vysypka") then {_output=[9,"IND",30];}; if (_input=="Land_A_houseWIP") then {_output=[29,"IND",30];}; if (_input=="Land_A_TVTower_Base") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Ao") then {_output=[3,"IND",30];}; if (_input=="Land_Misc_Cargo1Bo") then {_output=[3,"IND",30];}; if (_input=="Land_Nav_Boathouse") then {_output=[9,"IND",30];}; if (_input=="Land_wagon_box") then {_output=[3,"IND",30];}; if (_input=="Land_Rail_House_01") then {_output=[3,"IND",30];}; //FARM if (_input=="Land_stodola_old_open") then {_output=[12,"FRM",30];}; if (_input=="Land_Farm_Cowshed_a") then {_output=[7,"FRM",30];}; if (_input=="Land_stodola_open") then {_output=[4,"FRM",30];}; if (_input=="Land_Barn_W_01") then {_output=[6,"FRM",30];}; if (_input=="Land_Barn_W_02") then {_output=[6,"FRM",30];}; //SUPERMARKET if (_input=="Land_Rail_House_01") then {_output=[24,"SPM",30];}; if (_input=="Land_Rail_House_01") then {_output=[23,"SPM",30];}; //HOSPITAL if (_input=="Land_A_Hospital") then {_output=[12,"HOS",90];}; if (_input=="USMC_WarfareBFieldhHospital") then {_output=[5,"HOS",40];}; //MILITARY if (_input=="Land_Mil_Guardhouse") then {_output=[2,"MIL",30];}; if (_input=="Land_a_stationhouse") then {_output=[10,"MIL",30];}; if (_input=="Land_Mil_ControlTower") then {_output=[6,"MIL",40];}; if (_input=="Land_SS_hangar") then {_output=[3,"MIL",40];}; if (_input=="Land_Mil_House") then {_output=[3,"MIL",40];}; if (_input=="Land_Misc_deerstand") then {_output=[2,"MIL",50];}; if (_input=="Camp") then {_output=[2,"MIL",40];}; if (_input=="CampEast") then {_output=[2,"MIL",40];}; if (_input=="CampEast_EP1") then {_output=[3,"MIL",40];}; //BARRACK if (_input=="Land_Mil_Barracks_i") then {_output=[12,"BRK",40];}; if (format["%1",_input]=="any") then {_output=[0,"NIL",0];}; //hint format["IN FUNCTION %1",_output]; _output //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private ["_resident","_spots","_chance"]; _resident=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=""; _rchance=0; _cpos=[]; _veh=""; _gunADD=[]; _rnd=0; _npos=[]; //Putguns while {_count < _spots} do { _cpos=_resident buildingPos _count; _rchance=random 100; sleep 0.01; _veh=([_cpos select 0,_cpos select 1,(_cpos select 2)-0.6] nearObjects ["WeaponHolder",1]) select 0; //hint format["%1",_veh]; if (format["%1",_veh] != "<null>") then { clearMagazineCargo _veh; clearWeaponCargo _veh; _wph=_veh; } else { _wph="WeaponHolder" createVehicle _cpos; _wph setPosATL [_cpos select 0,_cpos select 1,(_cpos select 2)-0.6]; }; if ((random 100) < _chance) then { hint "Fail to make one gun!"; } else { //GUNS while { format["%1",_gunADD select 0]=="<null>" } do { if (_rchance < 25) exitWith{ _gunADD = [["M1014","8Rnd_B_Beneli_74Slug"],["LeeEnfield","10x_303"]]; _rnd=(count _gunADD)-1;_gunADD=_gunADD select (random _rnd); }; if (_rchance < 45) exitWith{ _gunADD = [["Colt1911","7Rnd_45ACP_1911"],["revolver_EP1","6Rnd_45ACP"]]; _rnd=(count _gunADD)-1;_gunADD=_gunADD select (random _rnd); }; if (_rchance < 60) exitWith{ _gunADD = ["Makarov","8Rnd_9x18_Makarov"]; }; _rchance=random 100; }; if (format["%1",_gunADD select 0]=="<null>") exitWith{}; //hint format["GUNS %1 , %2",_rnd,_gunADD select 0]; _wph addWeaponCargoGlobal [_gunADD select 0,1]; _wph addMagazineCargoGlobal [_gunAdd select 1,(random 2)+3]; sleep 0.01; }; _wph=""; _veh=""; _gunADD=[]; _count=_count + 1; }; Squint would have saved me quite a few hours if I had it earlier. Wish it tested functions etc without having to start arma up ;p Spent about 12 hours today so far on this script. - Can not call functions in functions? - Why do functions not return the generated output sometimes? - Does all ["_private"] values have to be unique? - I need to regenerate my functionality with a loooooong break. Have a good one! :-)
  13. BomboBombom

    Function script problems

    BlackMamb : Thought BIS functions were in there by default. So, this would explain this problem. lol. Oh the head pains, the head pains! Shuko: Long ago loaded it up. Thought either something was wrong or I couldn't stand the interface. The reason I don't remember. It shall replace notepad. Notepad++ plugin is not working on Win7 64. Note: Heard of some method to put item spawns by using objects that can fall for about half a second, delete them and use their relative positions for positions. Also, I'm rewriting the entire positioning method and using setVariable as well as getVariable to get spawn points. Wish it was possible to write text files that I could then use as preprocessfiles instead of having to init all buildings, or building types.
  14. Hello there, I've been trying to make a script that will log player kills into the server logs. I've attempted to make a script that logs killer, victim, player id, location of both victim and killer at the time of the event, the direction they are facing and what weapon was used to kill with. Should reactivate to be able to log again on all respawning that is a player controlled unit and preferably for all vehicles too. http://forums.bistudio.com/showthread.php?139111-Player-Killed-By-Death-Message-to-Logs I get the trigger to trigger, but it will not return the correct player name or id of killer or who was killed and neither does it seem to put the info into the log file, which I can not find. Trigger: - Triggers to anyone with condition true. { diag_log FORMAT ["Player: %1 UID: %2",_x,getPlayerUID _x]; _x addMPEventHandler ["MPKILLED",{ null = [_x] execVM "killed.sqf"}]; hint FORMAT ["%1 (%2)",_x,getPlayerUID _x]; } forEach units group player; killed.sqf private ["_victim","_killer"]; diag_log FORMAT ["%1 PID(%2) was killed by %3 PID(%4)",_killer,getPlayerUID _killer,_victim,getPlayerUID _victim]; hint FORMAT ["%1 PID(%2) was killed by %3 PID(%4)",_killer,getPlayerUID _killer,_victim,getPlayerUID _victim]; - It triggers on player death, but not AI kills with or without KILLER or MPKILLED event. All help appreciated :-) - Bomb.
  15. BomboBombom

    Function script problems

    1. None of the BIS_fnc_# seem to work for me. I've tried executing several scripts different examples for overlay effect text and attempted using one to detect if objects were inside of a trigger area. 2. It seems switches can NOT be executed inside of a condition tree. Trying to do so will NOT return any error message from -showScriptError, thus hard to identify. 3. Code ... well doesn't work well at all. Switch isn't working at all. My function returns null or any even if it is given correct input data. 4. Cut wrist :p I am quite a bit frustrated. Over 20 hours of trying to repair code that returned no errors. Script progress: 1 * Select all buildings within an radius. Works. 2 * Filter out buildings with buildpos 0 as "[0,0,0]" Works. 3 * Check what buildings are inside of "loot" marker. Works. 4 * setVariable "Lootable" to 1 to all buildings that are. Works. 5 * Get number of loot positions from switch function. Not working Script plan: Every 10 minutes script goes through all buildings that have been marked as lootable after initiating script phrase. Each spot found has a chance to have loot depending on the building type, each weapon spawn has a chance set to it too. 40% chance to spawn a weapon at spot A. 80% chance to spawn pistol in spot A, 60% chance to spawn shotgun in spot A, 40% chance to spawn automatic rifle in spot A. Weapon holders are used, these get removed every 10 minutes and new ones are created. Will change this to clear their cargo instead, but for now I only need stuff to work. -_-; Cheers. * Located error after industrial spawn list. Missing a ", no script error prompt about it. :| Works now, but can't see any more. So must afk for a bit :p In either case, there are new errors but they are not too horrible. Error example 1 : Guns are in floor in some buildings, and not in others. <.<
  16. BomboBombom

    Function script problems

    Trigger (reacts in trigger area and uses marker to make sure objects are not outside of spawn area): objects=[];oo=thistrigger nearObjects ["building",triggerarea thistrigger select 0]; { if !(format["%1",_x buildingPos 0]=="[0,0,0]") then {objects=objects+[_x]}; }forEach oo; {if (["MAKELOOT",getPos _x] call fnc_InMarker) then { [_x] execVM "FN\fn_MakeLoot.sqf"; }; }forEach objects; t=count objects;hint format["Total Objects%1%2","\n",t]; //FN_MAKELOOT private["_house"]; _house=_this select 0; _type=[]; _data=""; //hint format["%1%2","\n",_house]; _data=typeOf _house; if !(format["%1",_house getVariable "Lootable"] == "<null>") then { if !(_house getVariable "Lootable"==1) exitWith{}; hint "2 Lootable"; _type=_house getVariable "Data"; } ELSE { if (format["%1",_house buildingPos 0]=="[0,0,0]") exitWith{_house setVariable ["Lootable",0];}; //Set: Lootable _house setVariable ["Lootable",1]; _house setVariable ["Data",[_type select 0,_type select 1,_type select 2]]; hint "3 Balls!"; switch (_data) do { //RESIDENTIALS case "Land_HouseV_1I4": { _type = [3,"RES",40]; }; case "Land_kulna": { _type = [2,"RES",40]; }; case "Land_hut06": { _type = [2,"RES",40]; }; case "Land_Hlidac_budka": { _type = [3,"RES",40]; }; case "Land_HouseV2_02_Interier": { _type = [8,"RES",40]; }; case "Land_A_Pub_01": { _type = [20,"RES",40]; }; case "Land_Shed_wooden": { _type = [2,"RES",40]; }; case "Land_HouseBlock_A1_1": { _type = [2,"RES",40]; }; case "Land_HouseV_1I1": { _type = [1,"RES",40]; }; case "Land_A_MunicipalOffice": { _type = [14,"RES",40]; }; case "Land_ruin_01": { _type = [4,"RES",40]; }; case "Land_HouseV2_04_interier": { _type = [7,"RES",40]; }; case "Land_HouseV2_01A": { _type = [2,"RES",40]; }; case "Land_psi_bouda": { _type = [1,"RES",40]; }; case "Land_KBud": { _type = [1,"RES",40]; }; case "Land_A_Castle_Bergfrit": { _type = [12,"RES",40]; }; case "Land_A_Castle_Stairs_A": { _type = [3,"RES",40]; }; case "Land_A_Castle_Gate": { _type = [5,"RES",40]; }; case "Land_sara_domek_zluty": { _type = [9,"RES",40]; }; //OFFICE case "Land_HouseB_Tenement": { _type = [5,"OFF",40]; }; case "Land_Panelak": { _type = [13,"OFF",40]; }; case "Land_Panelak2": { _type = [12,"OFF",40]; }; case "Land_rail_station_big": { _type = [9,"OFF",40]; }; case "Land_A_Office01": { _type = [31,"OFF",40]; }; case "Land_A_Office02": { _type = [2,"OFF",40]; }; //INDUSTRIAL case "Land_Ind_Workshop01_01": { _type = [3,"IND",30]; }; case "Land_Ind_Garage01": { _type = [4,"IND",30]; }; case "Land_Ind_Workshop01_02": { _type = [3,"IND",30]; }; case "Land_Ind_Workshop01_04": { _type = [7,"IND",30]; }; case "Land_Ind_Workshop01_L": { _type = [7,"IND",30]; }; case "Land_Hangar_2": { _type = [7,"IND",30]; }; case "Land_A_FuelStation_Build": { _type = [4,"IND",30]; }; case "Land_Shed_Ind02": { _type = [5,"IND",30]; }; case "Land_Misc_PowerStation": { _type = [2,"IND",30]; }; case "Land_Shed_W01": { _type = [1,"IND",30]; }; case "Land_Tovarna2": { _type = [23,"IND",30]; }; case "Land_Ind_Vysypka": { _type = [9,"IND",30]; }; case "Land_A_houseWIP": { _type = [29,"IND",30]; }; case "Land_A_TVTower_Base": { _type = [3,"IND",30]; }; case "Land_Misc_Cargo1Ao": { _type = [3,"IND",30]; }; case "Land_Misc_Cargo1Bo": { _type = [3,"IND",30]; }; case "Land_Nav_Boathouse": { _type = [9,"IND",30]; }; case "Land_wagon_box": { _type = [3,"IND",30]; }; case "Land_Rail_House_01": { _type = [3,"IND",30]; }; //FARM case "Land_stodola_old_open": { _type = [12,FRM",30]; }; case "and_Farm_Cowshed_a": { _type = [7,"FRM",30]; }; case "Land_stodola_open": { _type = [4,"FRM",30]; }; case "Land_Barn_W_01": { _type = [6,"FRM",30]; }; case "Land_Barn_W_02": { _type = [6,"FRM",30]; }; //SUPERMARKET case "Land_Rail_House_01": { _type = [24,"SPM",30]; }; case "Land_Rail_House_01": { _type = [23,"SPM",30]; }; //HOSPITAL case "Land_A_Hospital": { _type = [12,"HOS",90]; }; case "USMC_WarfareBFieldhHospital": { _type = [5,"HOS",40]; }; //MILITARY case "Land_a_stationhouse": { _type = [10,"MIL",30]; }; case "Land_Mil_ControlTower": { _type = [6,"MIL",40]; }; case "Land_SS_hangar": { _type = [3,"MIL",40]; }; case "Land_Mil_House": { _type = [3,"MIL",40]; }; case "Land_Misc_deerstand": { _type = [2,"MIL",50]; }; case "Camp": { _type = [2,"MIL",40]; }; case "CampEast": { _type = [2,"MIL",40]; }; case "CampEast_EP1": { _type = [3,"MIL",40]; }; //BARRACKS case "Land_Mil_Barracks_i": { _type = [12,"BRK",40]; }; //CHURCH case "Land_Church_01": { _type = [1,"CHC",40]; }; case "Land_Church_03": { _type = [12,"CHC",40]; }; default { _type = [0,"NIL",0]; }; }; }; hint format["%1",_type]; switch (_type select 1) do { //RESIDENTIALS case "RES": { hint "Executing residential gun spawn function."; [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case "OFF": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case "IND": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case "FRM": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case "HOS": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case "MIL": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case "BRK": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case "CHC": { // [_house,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; Good night. Starting to pass out, this still doesn't seem to go much further. I've done tons of testing on individual parts of the code and worked out how to use various functions in the script, but together they refuse to work. Like when I pick a building out of an array the script things it is still an array when trying to call the object. etc etc. :| Do not understand why functions no longer run at all pretty much. I assume my func init-file contains errors ;p ~gone for today~
  17. BomboBombom

    Function script problems

    I'm tweaking script a lot. May rewrite it :| Found a few errrors that I have fixed. These errors were not announced by showscripterror prefix.
  18. BomboBombom

    Function script problems

    So, I must use sleep functions or the code wont work? code reports no errors ingame, yet it doesn't execute more than half of the code ... >,> The only part of this code I get executed is hint "Executing makeloot function"; The rest doesn't even bother running. Why I don't know. FN_MAKELOOT //FN_MAKELOOT private ["_building"]; _building = _this; _type=[]; _data=""; //Yeah those are revers :p hint "Executing makeloot function"; if !(_building getVariable "Lootable") exitWith{}; if !(format["%1",_building getVariable "Lootable"] == "<null>") then { if !(_building getVariable "Lootable") exitWith{}; if (_buidling getVariable "Lootable") then { _type = _building getVariable "Data"; }; } else { hint "Else!"; //Set: Not Lootable if (format["%1",_building buildingPos 0]=="[0,0,0]") exitWith{_building setVariable ["Lootable",false];}; //Get building data _data=typeOf _building; switch (_data) do { //RESIDENTIALS case ("Land_HouseV_1I4"): { _type = [3,"RES",40]; }; case ("Land_kulna"): { _type = [2,"RES",40]; }; case ("Land_hut06"): { _type = [2,"RES",40]; }; case ("Land_Hlidac_budka"): { _type = [3,"RES",40]; }; case ("Land_HouseV2_02_Interier"): { _type = [8,"RES",40]; }; case ("Land_A_Pub_01"): { _type = [20,"RES",40]; }; case ("Land_Shed_wooden"): { _type = [2,"RES",40]; }; case ("Land_HouseBlock_A1_1"): { _type = [2,"RES",40]; }; case ("Land_HouseV_1I1"): { _type = [1,"RES",40]; }; case ("Land_A_MunicipalOffice"): { _type = [14,"RES",40]; }; case ("Land_ruin_01"): { _type = [4,"RES",40]; }; case ("Land_HouseV2_04_interier"): { _type = [7,"RES",40]; }; case ("Land_HouseV2_01A"): { _type = [2,"RES",40]; }; case ("Land_psi_bouda"): { _type = [1,"RES",40]; }; case ("Land_KBud"): { _type = [1,"RES",40]; }; case ("Land_A_Castle_Bergfrit"): { _type = [12,"RES",40]; }; case ("Land_A_Castle_Stairs_A"): { _type = [3,"RES",40]; }; case ("Land_A_Castle_Gate"): { _type = [5,"RES",40]; }; case ("Land_sara_domek_zluty"): { _type = [9,"RES",40]; }; //OFFICE case ("Land_HouseB_Tenement"): { _type = [5,"OFF",40]; }; case ("Land_Panelak"): { _type = [13,"OFF",40]; }; case ("Land_Panelak2"): { _type = [12,"OFF",40]; }; case ("Land_rail_station_big"): { _type = [9,"OFF",40]; }; case ("Land_A_Office01"): { _type = [31,"OFF",40]; }; case ("Land_A_Office02"): { _type = [2,"OFF",40]; }; //INDUSTRIAL case ("Land_Ind_Workshop01_01"): { _type = [3,"IND",30]; }; case ("Land_Ind_Garage01"): { _type = [4,"IND",30]; }; case ("Land_Ind_Workshop01_02"): { _type = [3,"IND",30]; }; case ("Land_Ind_Workshop01_04"): { _type = [7,"IND",30]; }; case ("Land_Ind_Workshop01_L"): { _type = [7,"IND",30]; }; case ("Land_Hangar_2"): { _type = [7,"IND",30]; }; case ("Land_A_FuelStation_Build"): { _type = [4,"IND",30]; }; case ("Land_Shed_Ind02"): { _type = [5,"IND",30]; }; case ("Land_Misc_PowerStation"): { _type = [2,"IND",30]; }; case ("Land_Shed_W01"): { _type = [1,"IND",30]; }; case ("Land_Tovarna2"): { _type = [23,"IND",30]; }; case ("Land_Ind_Vysypka"): { _type = [9,"IND",30]; }; case ("Land_A_BuildingWIP"): { _type = [29,"IND",30]; }; case ("Land_A_TVTower_Base"): { _type = [3,"IND",30]; }; case ("Land_Misc_Cargo1Ao"): { _type = [3,"IND",30]; }; case ("Land_Misc_Cargo1Bo"): { _type = [3,"IND",30]; }; case ("Land_Nav_Boathouse"): { _type = [9,"IND",30]; }; case ("Land_wagon_box"): { _type = [3,"IND",30]; }; case ("Land_Rail_House_01"): { _type = [3,"IND",30]; }; //FARM case ("Land_stodola_old_open"): { _type = [12,FRM",30]; }; case ("and_Farm_Cowshed_a"): { _type = [7,"FRM",30]; }; case ("Land_stodola_open"): { _type = [4,"FRM",30]; }; case ("Land_Barn_W_01"): { _type = [6,"FRM",30]; }; case ("Land_Barn_W_02"): { _type = [6,"FRM",30]; }; //SUPERMARKET case ("Land_Rail_House_01"): { _type = [24,"SPM",30]; }; case ("Land_Rail_House_01"): { _type = [23,"SPM",30]; }; //HOSPITAL case ("Land_A_Hospital"): { _type = [12,"HOS",90]; }; case ("USMC_WarfareBFieldhHospital"): { _type = [5,"HOS",40]; }; //MILITARY case ("Land_a_stationhouse"): { _type = [10,"MIL",30]; }; case ("Land_Mil_ControlTower"): { _type = [6,"MIL",40]; }; case ("Land_SS_hangar"): { _type = [3,"MIL",40]; }; case ("Land_Mil_House"): { _type = [3,"MIL",40]; }; case ("Land_Misc_deerstand"): { _type = [2,"MIL",50]; }; case ("Camp"): { _type = [2,"MIL",40]; }; case ("CampEast"): { _type = [2,"MIL",40]; }; case ("CampEast_EP1"): { _type = [3,"MIL",40]; }; //BARRACKS case ("Land_Mil_Barracks_i"): { _type = [12,"BRK",40]; }; //CHURCH case ("Land_Church_01"): { _type = [1,"CHC",40]; }; case ("Land_Church_03"): { _type = [12,"CHC",40]; }; default { _type = [0,"NIL",0]; }; }; //Set: Lootable _building setVariable ["Lootable",true]; _building setVariable ["Data",_type]; }; hint "Switch function run"; switch (_type select 1) do { //RESIDENTIALS case ("RES"): { hint "Executing residential gun spawn function."; [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnRESIDENTIAL.sqf"; }; ////*OFFICE // case ("OFF"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*INDUSTRIAL // case ("IND"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnINDUSTRIAL.sqf"; // }; ////*FARM // case ("FRM"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnFARM.sqf"; // }; ////*HOSPITAL // case ("HOS"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnOFFICE.sqf"; // }; ////*MILITARY // case ("MIL"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnMILITARY.sqf"; // }; ////*BARRACK // case ("BRK"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnBARRACKS.sqf"; // }; ////*CHURCH // case ("CHC"): { // [_building,_type select 0,_type select 2] execVM "FN\fn_lootSpawnCHURCH.sqf"; // }; default {}; }; hint format["Lootable: %1%2Loot Spots: %3%2Type array data:%2%4",_building getVariable "Lootable","\n",_building GetVariable "Data" select 0,format["%1",_building GetVariable "Data"]]; FN\fn_lootSpawnRESIDENTIAL.sqf //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private ["_house","_spots","_chance"]; _house=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=""; _rchance=0; _cpos=[]; _veh=""; _gunADD=[]; //Putguns while {_count < _spots} do { _cpos=_house buildingPos _count; _veh=(_cpos nearObjects ["WeaponHolder",1]) select 0; if (format["%1",_veh] != "<null>") then { deleteVehicle _veh}; if ((random 100) < _chance) exitWith{}; _wph="WeaponHolder" createvehicle _cpos; _rchance=random 100; //GUNS while { format["%1",_gunADD]=="[]" } do { if (_rchance < 40) exitWith{ _gunADD = [["M1014","8Rnd_B_Beneli_74Slug"],["LeeEnfield","10x_303"]] call BIS_fnc_selectRandom; }; if (_rchance < 50) exitWith{ _gunADD = [["Colt1911","7Rnd_45ACP_1911"],["revolver_EP1","6Rnd_45ACP"]] call BIS_fnc_selectRandom; }; if (_rchance < 80) exitWith{ _gunADD = ["Makarov","8Rnd_9x18_Makarov"]; }; }; _wph addWeaponCargo [_gunADD select 0,1]; _wph addMagazineCargo [_gunAdd select 1,3]; _count=_count + 1; }; Error fixes.
  19. BomboBombom

    Function script problems

    Thanks kylania. I've tested BIS_fnc_inTrigger, but it didn't work. Had to use a inMarker function from here (Thanks: twirly) Right now I'm finding out that you can not call functions inside of other functions :| So I am putting the functions together into one. D: [argumentArray] call function; won't work inside another function, but; [argumentArray] execVM "function.sqf"; ,does. ~saddest face ever seen~ This will drop performance a lot. Updating code on page soon. Rewriting some stuff first.
  20. BomboBombom

    Function script problems

    how to select all objects inside a none-round trigger space? All examples I find use nearestObject-functions, meaning it has to be a circle space because it uses radius. This will not suffice! ;p
  21. BomboBombom

    Function script problems

    Thanks for both. I'm completely confused. Spent over 20 hours on scripting. (Not this alone, been making bridge floater script and so forth. The bridge script never started working which also confuses the hell out of me. Can't see errors due to like 5 errors stacked on each other ;p). fn_lootSpawnResidential - Highly modded due to problems persisting. //RESIDENTIAL loot spawn function. //fn_lootSpawnRESIDENTIAL private ["_house","_spots","_chance"]; _house=_this select 0; _spots=_this select 1; _chance=_this select 2; _count=0; _wph=[]; _guns=[]; _rchance=0; _cpos=[]; _veh=""; hint "Started residential spawn"; while {_count < _spots} do { _cpos=_house buildingPos _count; _veh=_cpos nearObjects ["WeaponHolder",1]; if (format["%1",_veh select 0] != "<null>") then { deleteVehicle _veh; }; if (random 100 < _chance) exitWith{}; _wpn="WeaponHolder" createVehicle _cpos; _wpn setPosATL _cpos; _rchance=random 100; _gunADD=_rchance call RESIDENTIAL_GUNS; _wpn addWeaponCargo [_gunADD select 0,1]; _wpn addMagazineCargo [_gunADD select 1,3]; hint format["A weapon was added at %1",mapGridPosition _wpn]; _count=_count+1; }; RESIDENTIAL_GUNS - This function will be tweaked. Update 10/10/2012 //RESIDENTIAL GUNS LIST private["_chance"]; _chance = _this select 0; _ret=""; while { _ret=="" } do { //This chance script isn't great. //But... if (_chance < 40) exitWith{ _ret = [["M1014","8Rnd_B_Beneli_74Slug"],["LeeEnfield","10x_303"]] call BIS_fnc_selectRandom; }; if (_chance < 50) exitWith{ _ret = [["Colt1911","7Rnd_45ACP_1911"],["revolver_EP1","6Rnd_45ACP"]] call BIS_fnc_selectRandom; }; if (_chance < 60) exitWith{ _ret = ["Makarov","8Rnd_9x18_Makarov"]; }; }; _ret FN_Building_typeNloot - Lists buildings and classes them with "Types" as well as lists the amount of avail spawn positions inside. //FN_BUILDING_TYPENLOOT private ["_building"]; _building=typeOf _this select 0; switch (_building) do { //RESIDENTIALS case ("Land_HouseV_1I4"): { _ret = [3,"RES",40]; }; case ("Land_kulna"): { _ret = [2,"RES",40]; }; case ("Land_hut06"): { _ret = [2,"RES",40]; }; case ("Land_Hlidac_budka"): { _ret = [3,"RES",40]; }; case ("Land_HouseV2_02_Interier"): { _ret = [8,"RES",40]; }; case ("Land_A_Pub_01"): { _ret = [20,"RES",40]; }; case ("Land_Shed_wooden"): { _ret = [2,"RES",40]; }; case ("Land_HouseBlock_A1_1"): { _ret = [2,"RES",40]; }; case ("Land_HouseV_1I1"): { _ret = [1,"RES",40]; }; case ("Land_A_MunicipalOffice"): { _ret = [14,"RES",40]; }; case ("Land_ruin_01"): { _ret = [4,"RES",40]; }; case ("Land_HouseV2_04_interier"): { _ret = [7,"RES",40]; }; case ("Land_HouseV2_01A"): { _ret = [2,"RES",40]; }; case ("Land_psi_bouda"): { _ret = [1,"RES",40]; }; case ("Land_KBud"): { _ret = [1,"RES",40]; }; case ("Land_A_Castle_Bergfrit"): { _ret = [12,"RES",40]; }; case ("Land_A_Castle_Stairs_A"): { _ret = [3,"RES",40]; }; case ("Land_A_Castle_Gate"): { _ret = [5,"RES",40]; }; case ("Land_sara_domek_zluty"): { _ret = [9,"RES",40]; }; //OFFICE case ("Land_HouseB_Tenement"): { _ret = [5,"OFF",40]; }; case ("Land_Panelak"): { _ret = [13,"OFF",40]; }; case ("Land_Panelak2"): { _ret = [12,"OFF",40]; }; case ("Land_rail_station_big"): { _ret = [9,"OFF",40]; }; case ("Land_A_Office01"): { _ret = [31,"OFF",40]; }; case ("Land_A_Office02"): { _ret = [2,"OFF",40]; }; //INDUSTRIAL case ("Land_Ind_Workshop01_01"): { _ret = [3,"IND",30]; }; case ("Land_Ind_Garage01"): { _ret = [4,"IND",30]; }; case ("Land_Ind_Workshop01_02"): { _ret = [3,"IND",30]; }; case ("Land_Ind_Workshop01_04"): { _ret = [7,"IND",30]; }; case ("Land_Ind_Workshop01_L"): { _ret = [7,"IND",30]; }; case ("Land_Hangar_2"): { _ret = [7,"IND",30]; }; case ("Land_A_FuelStation_Build"): { _ret = [4,"IND",30]; }; case ("Land_Shed_Ind02"): { _ret = [5,"IND",30]; }; case ("Land_Misc_PowerStation"): { _ret = [2,"IND",30]; }; case ("Land_Shed_W01"): { _ret = [1,"IND",30]; }; case ("Land_Tovarna2"): { _ret = [23,"IND",30]; }; case ("Land_Ind_Vysypka"): { _ret = [9,"IND",30]; }; case ("Land_A_BuildingWIP"): { _ret = [29,"IND",30]; }; case ("Land_A_TVTower_Base"): { _ret = [3,"IND",30]; }; case ("Land_Misc_Cargo1Ao"): { _ret = [3,"IND",30]; }; case ("Land_Misc_Cargo1Bo"): { _ret = [3,"IND",30]; }; case ("Land_Nav_Boathouse"): { _ret = [9,"IND",30]; }; case ("Land_wagon_box"): { _ret = [3,"IND",30]; }; case ("Land_Rail_House_01"): { _ret = [3,"IND",30]; }; //FARM case ("Land_stodola_old_open"): { _ret = [12,FRM",30]; }; case ("and_Farm_Cowshed_a"): { _ret = [7,"FRM",30]; }; case ("Land_stodola_open"): { _ret = [4,"FRM",30]; }; case ("Land_Barn_W_01"): { _ret = [6,"FRM",30]; }; case ("Land_Barn_W_02"): { _ret = [6,"FRM",30]; }; //SUPERMARKET case ("Land_Rail_House_01"): { _ret = [24,"SPM",30]; }; case ("Land_Rail_House_01"): { _ret = [23,"SPM",30]; }; //HOSPITAL case ("Land_A_Hospital"): { _ret = [12,"HOS",90]; }; case ("USMC_WarfareBFieldhHospital"): { _ret = [5,"HOS",40]; }; //MILITARY case ("Land_a_stationhouse"): { _ret = [10,"MIL",30]; }; case ("Land_Mil_ControlTower"): { _ret = [6,"MIL",40]; }; case ("Land_SS_hangar"): { _ret = [3,"MIL",40]; }; case ("Land_Mil_House"): { _ret = [3,"MIL",40]; }; case ("Land_Misc_deerstand"): { _ret = [2,"MIL",50]; }; case ("Camp"): { _ret = [2,"MIL",40]; }; case ("CampEast"): { _ret = [2,"MIL",40]; }; case ("CampEast_EP1"): { _ret = [3,"MIL",40]; }; //BARRACKS case ("Land_Mil_Barracks_i"): { _ret = [12,"BRK",40]; }; //CHURCH case ("Land_Church_01"): { _ret = [1,"CHC",40]; }; case ("Land_Church_03"): { _ret = [12,"CHC",40]; }; default { _ret = [0,"NIL",0]; }; }; _ret fn_MakeLoot - This isn't fully working due to lack of functions, cutting it down for testing. //FN_MAKELOOT private ["_building"]; _building = _this select 0; _type = ""; _type = _building call fn_Building_typeNloot; if ((_type select 1) == "NIL") exitWith{}; //Place loot according to building. switch (_type select 1) do { //RESIDENTIALS case ("RES"): { [_building,_type select 0,_type select 2] call fn_lootSpawnRESIDENTIAL; }; ////*OFFICE // case ("OFF"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnOFFICE; // }; ////*INDUSTRIAL // case ("IND"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnINDUSTRIAL; // }; ////*FARM // case ("FRM"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnFARM; // }; ////*HOSPITAL // case ("HOS"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnOFFICE; // }; ////*MILITARY // case ("MIL"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnMILITARY; // }; ////*BARRACK // case ("BRK"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnBARRACKS; // }; ////*CHURCH // case ("CHC"): { // [_building,_type select 0,_type select 2] call fn_lootSpawnCHURCH; // }; //ELSE default {}; }; Trigger covering the area you want spawn in with a 10 min repeat timer if (format ["%1", building buildingPos 1] == "[0,0,0]" ) exitWith{}; building call fn_makeloot; <- No clue how to make the trigger select the building. This in a trigger doesn't select self?
  22. Sorry running an op, haven't been able to reply. Want to say thanks and I'll read this through and reply asap. :-) Ok done. @twirly: Thank you too! ~reading that one too~ Excuse my not seeing that post. :s @BlackMamb: I've got a script for the finding who killed who, I was moding it to test the get and setVariable functions. The reason why I needed to learn the setVariable and getVariable is because I wanted to try and make a script that detects who killed who using a handgrenade and also to prevent it from logging a pistol in case of long range snipers switch weapon before their bullets hit the target. Thus I want to set "fired" value on the person shooting or throwing and then for the grenade try and determine that it was the grenade by the damage done and determining the sniper shot by the fired value. I've got no clue how I will make all of this work yet, but I'm working on it as well as I can and all the help has been of great use. :-) Original code for when players shoot each other is something like bellow. func_Killed = { private ["_die","_kil"]; if (!isPlayer (_this select 0)) exitWith{}; // _die = name (_this select 0); // _kil = name (_this select 1); hint format ["%1 killed %2",name (_this select 1),name (_this select 0)]; _this removeMPEventHandler ["Killed",0]; }; - The above is just an example, the removempeventhandler is an attempt to optimize, not sure if the index is always 0. the "//"-lines are what I previously used in the code. - I use a script for event "Fired" that saves gun and ammo used (ammo for throwing weapons). Not yet worked out how everything works so got some time till I can script all I want. Cheers~
  23. I've been trying to use setVariable and getVariable to save variables on units, I've not figured out how to return the values or how to turn them into arrays. I checked someones script out and adapted the script according to see if it would work. But even with changes row 6 has errors. The first time I had it set differently but it returned nothing at all. func_TrackDie = { private ["_die","_kil"]; _die = vehicle (_this select 0); _kil = name (_this select 1); _dies = _dies setVariable["PN_Fired",_kil,"PN_Died",_die]; _text = text format ["%1 VS %2 - %3 - %4",_kil,_die,_dies getVariable "PN_Fired",_dies getVariable "PN_Died"]; _text = text format ["%1 - %2",_text,_dies getVariable ["PN_Fired","PN_Died"] select 0]; _text = text format ["%1 - %2",_text,_dies getVariable ["PN_Fired","PN_Died"] select 1]; hint _text; }; I've executed this function on a tractor. Need arrays on units to get gun and what ammo or w/e I need to store on them. Can't make it work ~ cheers.
  24. I'm trying to learn still and have been been trying to get this to work for a long time. I always check wiki for help. Doesn't explain enough imo. 1. The client kept telling me that I needed to add a ] to the code. New errors came along eventually and I kept poking until I got no errors. 2. The wiki gives too little info for me to be able to use them. Doesn't give enough examples to explain how to use it in different ways. Example for get "_aVariable = _myTruck getVariable "myVariable"" and set "_myTruck setVariable ["myVariable", 123, true];" are basic use examples. The three _text variables are there to build a line to print at the end. Do not know why \n isn't working. For the code : func_TrackDie = { private ["_die","_kil"]; _die = vehicle (_this select 0); _kil = name (_this select 1); _dies = _dies setVariable["PN_Fired",_kil,"PN_Died",_die]; _text = text format ["%1 VS %2 - %3 - %4",_kil,_die,_dies getVariable "PN_Fired",_dies getVariable "PN_Died"]; _text = text format ["%1 - %2",_text,_dies getVariable ["PN_Fired","PN_Died"] select 0]; _text = text format ["%1 - %2",_text,_dies getVariable ["PN_Fired","PN_Died"] select 1]; hint _text; }; The script is called when the tractor is killed. It is supposed to print the killer, victim and then the array variable. Now to explain each line; _die = this select 0; (works instead of the vehicle one, it was a simple experiment to see if I got different info) _kil = name (this select 1); returns the name of the unit killing the tractor. _dies = _dies setVariable["PN_Fired",_kil,"PN_Died",_die]; sets PN_Fired to _kil and PN_Died sets the dieing tractor. As you explained it seems I've done it wrong. I assume it needs to be "PN_Fired",_kil,true,"PN_Died",_die,true instead. the _text lines are for building a line of text, supposed to have line breaks in it for each line though. I was testing retrieving my variable and trying various methods and tried to get various variables out. hint _text; prints the _text value once it is made. I want to create an array rather than split values. Cheers~~
  25. waitUntil {isDedicated or !isNull player}; //waitUntil {!isNull player}; if (isServer) then { TAG_LOG_FUNC = { //Player victim and murder person _victim = _this select 0; _killer = _this select 1; //Grid location of them perky persons _vicGRD = mapGridPosition (getPos (_this select 0)); _kilGRD = mapGridPosition (getPos (_this select 1)); //get gun _gun = weaponState _killer; if (_gun select 0 == "Throw") then { _gun = _gun select 3 } else { _gun = _gun select 0 }; //print or log data diag_log text format ["%1 PLAYER KILL EVENT == VICTIM %2 (%3) at grid %4. KILLER: %5 (%6) at grid %7 GUN: %8 ",round time,name _victim, getPlayerUID _victim,_vicGRD,name _killer,if (isPlayer _killer) then { getPlayerUID _killer } else { text format ["Other(%2)",typeOf _killer] },_kilGRD,_gun]; _victim removeMPEventHandler ["Killed", 0]; }; "TAG_MPKilledLog" addPublicVariableEventHandler { _var = _this select 1; _var call TAG_LOG_FUNC; }; }; if (local player) then { player addEventHandler ["Killed", { if (isServer) then { _this call TAG_LOG_FUNC; } else { TAG_MPKilledLog = _this; publicVariableServer "TAG_MPKilledLog"; } }]; }; - Tested with HINT using waitUntil {!isNull Player}; and "Killed" handler. MPKilled untested. Needs a test. - Known problems (need a fix) : a. If someone kills a person with a grenade and it is their last grenade or they switch weapon fast after throwing it. It will return the new weapon and not the grenade in the kill log. I'm not sure how to get the grenade kill event. b. Doesn't return the correct values for "other" death source. Not looked into. Will attempt to fix. Thanks for all the help! :-)) Would not be this far without it. Cheers Partial code from a file Is _unit setVariable["PN_Fired",[_gun,_throw]] then _gun = _killer getVariable ""PN_Fired""; _gun = if (_gun select 0 == "Throw") then { text format ["%1(%2)",_gun select 1,_gun select 0] } else { _gun select 0 }; ; correct? - Simply wondering if setVariable can be used as such.
×