greetings,
i hope this is ok here....
this is a continuous WiP
also, i would like to extend an invitation for any and all to add small scripts that you have found useful to help build this into a library of scripts... ya know.. for us noob toilet cleaners...
ArmA - Scripting General
-------------------------------------------------------------------
(counting loops)
http://www.ofpec.com/forum/index.php?topic=31460.0how does one count the times a loop has been fired off? and when it has looped 12x.. it moves on?
timeskip used as example
sqs format
; start the time acc
_x=0
#loop
~.04
_x = _x +1
skiptime .0625
? _x >= 195 : goto "next"
goto "loop"
#next
;script continues from here
2 sqf formats:
_x = 0;
while {_x < 12 } do
{
//do whatever you think is necessary but don't forget the following line
_x = _x + 1;
};
or
for [{_x= 0},{_x <12},{_x = _x + 1}] do
{
//again do whatever you like...and nothing more:D
};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(keeping track of player)
http://www.ofpec.com/forum/index.php?topic=31602.0this script is used to know if the player has entered or exited a vehicle. the typeOf vehicle is placed in a hint.
[] spawn
{
private["_unit", "_veh"];
while {true} do
{
while {(alive player)} do
{
_unit = player;
if (vehicle _unit != _unit) then
{
_veh = vehicle player;
hint format ["greetings... you're in a %1.", typeOf _veh];
waitUntil {vehicle player == player};
hint format ["greetings... you just dismounted from a %1.", typeOf _veh];
};
Sleep 1;
};
};
};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(basics of teleport and onMapSingleClick)
http://www.ofpec.com/forum/index.php?topic=31544.0if i am in one spot, and i want to hit 'M' and click on the map to teleport to another area.. how would i?
add an addaction;
player addAction ["gotoA","scripts\tele.sqf"];
the onMapSingleClick command goes inside the action script "tele.sqf" and a title text asking for map click.
// tele.sqf
titleText["Select Map Position", "PLAIN"];
onMapSingleClick "vehicle player setPos _pos; onMapSingleClick '';true;";
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Selecting a random target)
http://www.ofpec.com/forum/index.php?topic=31500.0if you want a simulated madman in a city killing randoms closest to him or something similar...
madman.sqs
? !(local server): exit
_shooter = _this select 0
_shooter addMagazine "8Rnd_9x18_Makarov"
_shooter addWeapon "Makarov"
#killingSpree
_targetList = nearestObjects [_shooter, ["man"], 150]
_target = _targetList select 1
_shooter doTarget _target
_shooter doFire _target
~1
? !(alive _target): _target = nil
~1
goto "killingSpree"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(basics of para-drop)
http://www.ofpec.com/forum/index.php?topic=31222.0looking for a simple script for placing a parachute on vehicles
drop_car.sqf
// drop_car.sqf
// [position_desired]execVM"drop_car.sqf"
// Example:
// [[getPos player select 0,getPos player select 1, 100]] execVM "drop_car.sqf"
_pos = _this select 0;
_myvehicle = "UAZ" createVehicle _pos;
_myvehicle setPos _pos;
// Change dist between chute and car at will
_dist = -2;
_mychute = "ParachuteWest" createVehicle getPos _myvehicle;
_mychute setPos getPos _myvehicle;
while {(getPos _myvehicle select 2) > 0} do
{
_myvehicle setPos (_mychute modelToWorld [0,0,_dist]);
_myvehicle SetVectorUp (vectorUp _mychute);
sleep 0.01;
};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(basic score script)
http://www.ofpec.com/forum/index.php?topic=29657.0I'm trying to make my own ranking system and I want ArmA to automatically give anyone who is a West Pilot points so they can fly immediately.
init.sqf
_unit = player;
if (player isKindOf "SoldierWPilot") then
{
if (score _unit < rank1) exitWith
{
player addscore 1000;
hint "Pilot points awarded";
};
};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(add horizontal velocity... turbo)
http://www.ofpec.com/forum/index.php?topic=31627.0Suppose I want to add turbo to a flying aircraft with the SetVelocity command...
add an addaction;
player addAction ["faster","scripts\turbo.sqf"];
turbo.sqf
// velocity is in m/s
_vel = 30;
_dir = 180;
while {true} do
{
_vehicle setDir _dir;
_vehicle setVelocity [sin(_dir)*_vel, cos(_dir)*_vel, 0];
Sleep 0.005;
};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(instant calvary)
how to i create some guys and a couple of manned vehicles when needed?
init.sqf
vehicle player addAction ["calvary","scripts\calvary.sqs"];
calvary.sqs
if (!isServer) exitWith{};
veh1 = createVehicle ["M1Abrams", position player, [], 15, "NONE"];
~0.1
"SoldierWAT"createUnit [position veh1,group player,"this moveindriver veh1"];
"SoldierWAT"createUnit [position veh1,group player,"this moveingunner veh1"];
veh3 = createVehicle ["vulcan", position player, [], 15, "NONE"];
~0.1
"SoldierWAT"createUnit [position veh3,group player,"this moveindriver veh3"];
"SoldierWAT"createUnit [position veh3,group player,"this moveingunner veh3"];
"SoldierWSaboteurMarksman"createUnit [position player,group player];
"SoldierWMedic"createUnit [position player,group player];
"SoldierWMG"createUnit [position player,group player];
"SoldierWAT"createUnit [position player,group player];
"SoldierWAT"createUnit [position player,group player];
"SoldierWSaboteurMarksman"createUnit [position player,group player];
"SoldierWMedic"createUnit [position player,group player];
"SoldierWMG"createUnit [position player,group player];
"SoldierWAT"createUnit [position player,group player];
"SoldierWAT"createUnit [position player,group player];
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ArmA - Scripting Advanced
-------------------------------------------------------------------
ArmA - Scripting Multiplayer
-------------------------------------------------------------------
(setting time on a dedicated server for JiP)
http://www.ofpec.com/forum/index.php?topic=31490.0how do i set the global time after the time has been altered by script for all JiP's?
init.sqf
// init.sqf
wantsinfo = objNull;
currentdate = 0;
currentovercast = -1;
currentfog = -1;
if (isServer) then
{
currentovercast = random 0.5;
0 setOverCast currentovercast;
[] spawn
{
while {true} do
{
waitUntil {!isNull wantsinfo};
wantsinfo = objNull;
currentdate = daytime;
publicVariable "currentdate";
currentovercast = overcast;
publicVariable "currentovercast";
currentfog = fog;
publicVariable "currentfog";
};
};
}
else
{
waitUntil {alive player};
wantsinfo = player;
publicVariable "wantsinfo";
waitUntil {currentdate > 0};
skipTime (currentdate - daytime);
waitUntil {currentovercast != -1};
0 setOverCast currentovercast;
Sleep 1;
waitUntil {currentfog != -1};
0 setFog currentfog;
};
-------------------------------------------------------------------