Jump to content
Sign in to follow this  
1para{god-father}

check player is x distance

Recommended Posts

have this working but now i also have playable OPFOR so need it Just for WEST , but cannot seem to get it to work for just West Players

While {{isPlayer _x} count nearestObjects [_TAG_sdv,["Man","LandVehicle","AIR"],300] == 0 } do {sleep 5};

Just West only

While {{isPlayer_ x AND side (_this select 1) == WEST } count nearestObjects [_TAG_sdv,["Man","LandVehicle","AIR"],300] == 0 } do {sleep 5};

Thanks

Share this post


Link to post
Share on other sites

Wouldn't this do the job?

if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_TAG_sdv,["Man","LandVehicle","AIR"],300] == 0 } do {sleep 5};
};

Share this post


Link to post
Share on other sites

Hmm OK any idea why this would not work on Dedi server ?

if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],1000] == 0 } do {sleep 5};

Hint "Got here";

};

Works fine in MP but not on dedi ?

Share this post


Link to post
Share on other sites
Hmm OK any idea why this would not work on Dedi server ?

if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],1000] == 0 } do {sleep 5};

Hint "Got here";

};

Works fine in MP but not on dedi ?

Could be a number of things.

Is the script local to the player?

Share this post


Link to post
Share on other sites
This script is run on server not local

if(not isServer) exitWith{};

xxx
x
x
x
x

Then the hint wont show up because it is local to the script

Share this post


Link to post
Share on other sites

sorry i just put that in there for ref as an example (bad example i know) , even if I change to side chat it does not fire on dedi nothing seem to work inside, but local it does ?

if(not isServer) exitWith{};
if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],1000] == 0 } do {sleep 5};

////what ever I run inside will not fire///

///example
_TAG_chopper = "O_MBT_02_arty_F" createVehicle getmarkerpos "Testmarker";
};

runs fine on MP - but dedi get no spawn?

Anyone have any ideas ?

Edited by 1PARA{God-Father}

Share this post


Link to post
Share on other sites

bump...

Sorry been trying all day to get this to work on dedi but still no Joy ... basically i need to wait until the any player is x distance to the _landrover1 then spawn in the OPFOR.

This all works fine in MP , but not on Dedi ? if i take out the Side check

if (side (_this select 1) == WEST) then {} 

it works but I need to check the side as i have playable Opfor.

Any idea where i am going wrong ?

if(not isServer) exitWith{};

private ["_randompos","_pos"];

_location = AO_locations call BIS_fnc_selectRandom;
_pos = (position _location);
_flatpos = [_pos , 0, 400, 10, 0, 0.25, 0] call BIS_fnc_findSafePos;  
_locationName = (text _location);
_cid = floor(random 10000);
_t = format["relive%1",_cid];
enemyDead = false; 
MainAO setPos _Pos ;
_markername = format["mrk_%1", _location];
_marker = createMarker [_markername, _flatPos];
_marker setmarkershape "ELLIPSE";
_marker setMarkerColor "ColorRed";
_marker setMarkerSize [190,190]; 
_marker setMarkerAlpha 0;

_landrover1 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
_landrover2 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
_landrover3 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
{_x setDir random 360; _x setDamage (random 0.9); _x lock true} foreach [_landrover1,_landrover2,_landrover3];


_grp = [_flatPos, WEST, (configfile >> "CfgGroups" >> "WEST" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam")] call BIS_fnc_spawnGroup;
{
_x setCaptive true;
_x allowDamage false;
_x addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]; // <- Hollywood mags yay
} foreach units _grp;

{_x setCaptive true; _x allowFleeing 0} foreach units _grp;


///////Take the next line out and it works on Dedi///

if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],1000] == 0 } do {sleep 5}; /// this works on dedi

_SpawnAUnits = 
[ 
	[ [ groupArrayFireTeam, _markername ], [ "PATROL_AROUND" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayW_APC, _markername, false ], [ "PATROL_URBAN" ] ],
	[ [ groupArrayW_APC, _markername, false ], [ "PATROL_URBAN" ] ]
];
[ _SpawnAUnits ] spawn T8U_fnc_Spawn;

}; /// 

Share this post


Link to post
Share on other sites
bump...

Sorry been trying all day to get this to work on dedi but still no Joy ... basically i need to wait until the any player is x distance to the _landrover1 then spawn in the OPFOR.

This all works fine in MP , but not on Dedi ? if i take out the Side check

if (side (_this select 1) == WEST) then {} 

it works but I need to check the side as i have playable Opfor.

Any idea where i am going wrong ?

if(not isServer) exitWith{};

private ["_randompos","_pos"];

_location = AO_locations call BIS_fnc_selectRandom;
_pos = (position _location);
_flatpos = [_pos , 0, 400, 10, 0, 0.25, 0] call BIS_fnc_findSafePos;  
_locationName = (text _location);
_cid = floor(random 10000);
_t = format["relive%1",_cid];
enemyDead = false; 
MainAO setPos _Pos ;
_markername = format["mrk_%1", _location];
_marker = createMarker [_markername, _flatPos];
_marker setmarkershape "ELLIPSE";
_marker setMarkerColor "ColorRed";
_marker setMarkerSize [190,190]; 
_marker setMarkerAlpha 0;

_landrover1 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
_landrover2 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
_landrover3 = "B_MRAP_01_F" createVehicle [(_flatPos select 0) + 10 - random 20,(_flatPos select 1) + 10 - random 20,0];
{_x setDir random 360; _x setDamage (random 0.9); _x lock true} foreach [_landrover1,_landrover2,_landrover3];


_grp = [_flatPos, WEST, (configfile >> "CfgGroups" >> "WEST" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam")] call BIS_fnc_spawnGroup;
{
_x setCaptive true;
_x allowDamage false;
_x addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}]; // <- Hollywood mags yay
} foreach units _grp;

{_x setCaptive true; _x allowFleeing 0} foreach units _grp;


///////Take the next line out and it works on Dedi///

if (side (_this select 1) == WEST) then {

While {{isPlayer _x} count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],1000] == 0 } do {sleep 5}; /// this works on dedi

_SpawnAUnits = 
[ 
	[ [ groupArrayFireTeam, _markername ], [ "PATROL_AROUND" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayFireTeam, _markername ], [ "PATROL" ] ],
	[ [ groupArrayW_APC, _markername, false ], [ "PATROL_URBAN" ] ],
	[ [ groupArrayW_APC, _markername, false ], [ "PATROL_URBAN" ] ]
];
[ _SpawnAUnits ] spawn T8U_fnc_Spawn;

}; /// 

What is being passed into the script as

(_this select 1)

Share this post


Link to post
Share on other sites

errr nothing i have been trying everything so tried that :)

I just need it to check that any Playable West is near before i spawn

i did try this :

While {{isPlayer _x AND side = WEST } count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],300] == 0 } do {sleep 5};

but still a no go :(

Edited by 1PARA{God-Father}

Share this post


Link to post
Share on other sites

your missing the _x and a = from the side check

While {{isPlayer _x AND side _x == WEST } count nearestObjects [_landrover1,["Man","LandVehicle","AIR"],300] == 0 } do {sleep 5};

Share this post


Link to post
Share on other sites

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh :j:

A whole day that took me

Thanks all working now :yay::yay:

Many thanks !!!!!!!!!!!!!!!!!!

Share this post


Link to post
Share on other sites

Hi there,

I'm glad your problem got solved. I'm afraid, my problem does not really belong here, but since I cannot open a new thread yet, I hoped my problem seems kinda similar.

I know the

nearestObjects

command works pretty fine for actually every object in the specified distance. Well, allmost - Actually seemingly everything except for ambient objects (trees, bushes, rocks, ground modeling ...).

All I'm trying to do is to get the distance to any tree in Altis. The following (simple as possible) code example hints every near object (including buildings) within 5 meters, except for what I want - the trees:

hint format["%1", nearestObjects[player, [], 5]];

Now, this must have worked in Arma 2 somehow since in DayZ Mod the player could interact with trees and the code for that ("player_chopWood.sqf") actually uses this:

{ /* some fancy code here */ } forEach nearestObjects [getPos player, [], 20];

So, any idea, what I'm doing wrong? I'd really appreciate some help!

Regards,

waltenberg

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×