

samatra
Member-
Content Count
652 -
Joined
-
Last visited
-
Medals
-
Medals
-
Everything posted by samatra
-
how to attach a script to a weaponholder
samatra replied to twisted's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Here is how I would do it. This will need a script thread for each weapon holder though, might hit the performance but not sure how much. (somePos is obviously an example) _veh = createVehicle ["WeaponHolder", somePos, [], 0, "CAN_COLLIDE"]; _veh addWeaponCargoGlobal ["M16A2", 1]; _veh spawn { while{alive _this} do { sleep 300; _close = false; { if((_this distance _x) < 300) then {_close = true;}; } forEach playableUnits; if(!_close) then { deleteVehicle _this; }; }; }; This will check if there are any players nearby weapon holder each 300 seconds. So practically it might take 10-20 minutes for weapon holder to delete. I would recommend you have such checks for entire building instead of each weapon holder in building and if there is no players, then delete all weapon holders for this building. -
Getting player's side while you are dead
samatra replied to samatra's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Thanks, this is exactly what I needed. -
Getting player's side while you are dead
samatra posted a topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Hello. Is there a way to get player's side while you are dead? Obviously your corpse is civilian (when checked in onKilled), maybe there is some global variable with lobby-selected player side or something? Thank you. -
Advanced Help Needed (Tire and Fuel Randomization)
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Yes, either before or after fuel\tyres code. -
Advanced Help Needed (Tire and Fuel Randomization)
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I'm not much of a mod user to tell if something spawns jerry cans, but either way you can delete all fuel cans with {deleteVehicle _x;} forEach nearestObjects [getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["Fuel_can"], 10000]; -
Getting player's side while you are dead
samatra replied to samatra's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Well, setVariable seems to be an okay solution. Was wondering about lobby-selected values though. Thanks. -
Spawning a Vehicle on Event
samatra replied to UltimateBawb's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Add menu item to player player addAction ["Do spawn", "do_spawn.sqf"]; do_spawn.sqf _vehicle = createVehicle ["SUV_TK_CIV_EP1", getPos player, [], 10, "CAN_COLLIDE"]; Simple at that. If you want to use player's init line in editor to add action menu item, then you have to use: if(local this) then {this addAction ["Do spawn", "do_spawn.sqf"];}; -
Advanced Help Needed (Tire and Fuel Randomization)
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Did you place fuel cans in your mission? Or maybe some other script\mod spawning them? As for random stuff inside cars, expanding my original script: _vehicles = nearestObjects [getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["Car"], 10000]; _hitpoints = ["HitLFWheel", "HitRFWheel", "HitLF2Wheel", "HitRF2Wheel", "HitLMWheel", "HitRMWheel", "HitLBWheel", "HitRBWheel", "HitFWheel", "HitBWheel"]; _weapons = [ ["M16A2", "30Rnd_556x45_Stanag", 4], ["AKS_74_U", "30Rnd_545x39_AK", 5], ["Colt1911", "7Rnd_45ACP_1911", 7], ["Makarov", "8Rnd_9x18_Makarov", 7] ]; { _veh = _x; _veh setFuel (random 0.2); clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; if(random 10 < 3) then { _weapon = _weapons select floor(random(count _weapons)); _veh addWeaponCargoGlobal [_weapon select 0, 1]; _veh addMagazineCargoGlobal [_weapon select 1, round(random(_weapon select 2))]; }; { _damage = random 1; if(random 10 < 5) then { _damage = 1; }; _veh setHit [getText(configFile >> "cfgVehicles" >> (typeOf _veh) >> "HitPoints" >> (_x) >> "name"), _damage]; } forEach _hitpoints; } forEach _vehicles; (With proper tabs: http://pastie.org/pastes/4648527/text) The addition is _weapons array which consists of arrays of possible weapons. First value for sub-array is weapon name, second value is magazine name, third value is max amount of ammo for this weapon. Now along with setting fuel and tyres, script clears default inventory of vehicles and with change of 30% (Code: if(random 10 < 3)) adds random weapon and random amount of magazines for the weapon (random from 0 to 3rd array value, so it might be no ammo at all). As for config browser, you probably wanted this: http://browser.six-projects.net/cfg_weapons/tree?version=58 When adding new weapons into _weapons, double check commas after sub-arrays, last sub-array shouldn't have comma after it. -
Advanced Help Needed (Tire and Fuel Randomization)
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Joining clients are not server and therefore will not run the code. init.sqf doesn't executes on all machines when one client joins, only on client that joins. -
Advanced Help Needed (Tire and Fuel Randomization)
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Wrote some quick code for you: _vehicles = nearestObjects [getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["Car"], 10000]; _hitpoints = ["HitLFWheel", "HitRFWheel", "HitLF2Wheel", "HitRF2Wheel", "HitLMWheel", "HitRMWheel", "HitLBWheel", "HitRBWheel", "HitFWheel", "HitBWheel"]; { _veh = _x; _veh setFuel (random 0.2); { _damage = random 1; if(random 10 < 5) then { _damage = 1; }; _veh setHit [getText(configFile >> "cfgVehicles" >> (typeOf _veh) >> "HitPoints" >> (_x) >> "name"), _damage]; } forEach _hitpoints; } forEach _vehicles; This will go through all cars on entire map, set them random amount of fuel (Code: _veh setFuel (random 0.2); which is random between 0% and 20% fuel), then go through all possible wheels and set wheel damage to either 1 (completely broken) or random 1 (random damage of wheel) with 50% chance (Code: if(random 10 < 5)) Place this code in init.sqf of your mission, make sure to wrap it in if(isServer) then { //Code here }; To make sure it runs only once per game on mission init. -
Where do I put the .sqf files?
samatra replied to UltimateBawb's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Into mission directory. If its your own custom mission, then it should be in my documents/arma 2 other profiles/etc... Also read this: http://community.bistudio.com/wiki/Event_Scripts -
How to edit built in Scenarios and other Missions
samatra replied to halex1316's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
To unpack missions you need http://community.bistudio.com/wiki/BI_Tools_2 just look in your game's folder for .pbo and unpack one with cpbo. DLC pbo's are unpackable btw. -
Need Help with scripting! Loop+timer
samatra replied to chatterbox360's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
for "_i" from 0 to 10 do { sleep 300; saveGame; }; sleep 300; endMission "END1" ; Loops 11 times, then sleeps 300 additional seconds and ends the mission. -
Animations y u no work?
samatra replied to Horner's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
I think you might need help of http://community.bistudio.com/wiki/Multiplayer_framework player switchMove "adthpercmstpslowwrfldnon_4"; [nil,player,rSwitchMove, "adthpercmstpslowwrfldnon_4"] call RE; Something like this (didn't actually test it, just a guess) -
Message on joining game
samatra replied to TriGGa's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Unpack the mission, search through all files for piece of text that already shows, when you find it, just replace with something that you want. -
Scripting a Menu / Basic Help
samatra replied to UltimateBawb's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Read about dialog control here: http://resources.bisimulations.com/wiki/Dialog_Control Its pretty complicated and will be difficult at first (debugging is a pain too since game crashes to desktop in case of error in dialogs) but overall it is pretty flexible. Also look around the net for examples and sample scenarios with example dialogs. About scripting outside of init boxes: http://community.bistudio.com/wiki/Event_Scripts Easiest way is to create init.sqf in your mission directory and this script will be automatically called each time new player loads your mission (selects role in lobby and continues). If you want something to execute once, say on mission start, use http://community.bistudio.com/wiki/isServer inside init.sqf to check if initialization is done for server player\machine which is always called once per game. -
waitUntil with sleep or just sleep?
samatra replied to GuideZ's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Some script scopes don't allow use of sleep and will throw errors. If this is the case, then just wrap your code into spawn and it will work. -
backpack pick up able in sp can't believe picked up in mp
samatra replied to twisted's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Not every unit type can pick up backpack, make sure you use compatible one. -
Not sure what you trying to do but setting vehicle\unit variable works like this: _gen setVariable ["ns_aii_l_status", 1, true]; // true for sending this new value to all players in game
-
Select & Give Player Random Weapon, Mags & Items Script. Need Help please!
samatra replied to ShinShin's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Instead of storing weapons and mags in separate arrays, better store them like this weaponList = [ ["Weapon1", "Mag1"], ["Weapon2", "Mag2"] ]; For selecting random value from array go with: _weapon = weaponList select floor(random(count weaponList)); And with switch() you can go with //This should be here since we will initialize _weapon in switch() scope instead of main scope //where _weapon will be used, otherwise _weapon will be "invisible" outside of switch() private ["_weapon"]; weaponListRifles = [ ["Weapon1", "Mag1"], ["Weapon2", "Mag2"] ]; weaponListSnipers = [ ["Weapon3", "Mag3"], ["Weapon4", "Mag4"] ]; switch(round(random 1)) do { //Selects either 0 or 1 case 0: { _weapon = weaponListRifles select floor(random(count weaponListRifles)); }; case 1: { _weapon = weaponListSnipers select floor(random(count weaponListSnipers)); }; } // Give weapon here player addWeapon (_weapon select 0); // Give 4 mags (_i will be 0, 1, 2, 3 which is 4 times in total) for "_i" from 0 to 3 do { player addMagazine (_weapon select 1); }; Didn't test the code but that's the basic idea. -
rGlobalChat with Multiplayer Network
samatra posted a topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Hello. Can't get hang of it, i'm checking through all vehicle crew and want to display something into their global chat. { [nil, _x, "loc", rGlobalChat, "Some message"] call RE; } forEach (crew someVehicleVar); And it doesn't work. Help please? -
rGlobalChat with Multiplayer Network
samatra replied to samatra's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Oh its not really a "vehicle" there, just replaced actual variable with it here on forums. If I swap _x and nil, then everyone sees global chat message instead of just people inside -
[req] Alternative respawn method, default spawn gear change?, vehicle respawn, etc
samatra replied to BomboBombom's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Wow, that's a long thread. Its hard to understand right away what this thread is about, release, question, tutorial of some kind? You better create some sort of table of contents or index or better yet ask right away what you want to do. -
Spawn in flight as a pilot - then Respawn in flight as pilot.
samatra replied to tuxu's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
Then you need this: http://community.bistudio.com/wiki/addEventHandler http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#Respawn You will need to set up Respawn event handler on units and when it triggers, just move them into pilot (as well as create new plane if you need to) -
Spawn in flight as a pilot - then Respawn in flight as pilot.
samatra replied to tuxu's topic in ARMA 2 & OA : MISSIONS - Editing & Scripting
You need to add event handler for respawning of each unit. Check this out: http://community.bistudio.com/wiki/addMPEventHandler http://community.bistudio.com/wiki/moveInDriver