TKC-Community

Hacking and Art => Armed Assault 3 => Armed Assault 2 => Topic started by: rbneville on June 11, 2012, 02:54:59 am

Title: Get all players positions
Post by: rbneville on June 11, 2012, 02:54:59 am
Hey guys, I'm working on a code and need a little help. I need to be able to get the position of all other players on a server. Any advice on how to do this? I honestly have no clue where to start.

My code here makes a goat chase the local player (me) and after a set amount of time blows up.

This creates the goat and "explodes" it after a time.
Code: [Select]
_shelltype = "Sh_105_HE";
_veh = createVehicle ["Goat02_EP1" , position player, [], 0, "NONE"];
_move = _veh execVM "\Scripts\Move.sqf";
sleep 30;
terminate _spawn;
_pos = getpos player;
_shelltype createVehicle [_pos select 0, _pos select 1, (_pos select 2) +5]
deleteVehicle _veh;

This moves the goat with the player and also rotates the same as the player

Code: [Select]
while {1 == 1} do
{
_pos = getpos player;
_rot = getDir player;
_this setDir _rot;
_this setpos [_pos select 0, (_pos select 1) +2, (_pos select 2) +1]
};

All I need now is a way to get another players position.
Title: Re: Get all players positions
Post by: leebeasley on June 11, 2012, 02:58:05 am
Rofl, glorious script
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 03:01:17 am
Quote
nil = ["player setpos [getPos player select 0,getPos player select 1,(getPos player select 2)+10000];"]

Quote above is from the darky script that makes everyone move.

You could probably edit the map marker script instead of marking the map making a goat there instead.

Code: [Select]
hint "Adding Player Markers";

unitList = allUnits;
j = count unitList;
i = 0;
markPos = true;

while {markPos} do
{
unitList = allUnits;
j = count unitList;
i = 0;

for "i" from 0 to j do
{
unit = unitList select i;
pos = position unit;
};
sleep 0.5;
};
hint "Player Marking Stopping";

Right there than add your creation lines and if it works correctly everyone and yourself will have a goat chasing you around and blowing the fuck up.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 03:10:46 am
Most excellent zlake  :icon_devil
Thanks
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 03:13:37 am
You can even add a radius to the script. Make them spawn in random locations all over the map. When one gets close enough to a player. Like 400 yards. It will go all lee roy jakins on them.
Title: Re: Get all players positions
Post by: robin-580 on June 11, 2012, 03:39:50 am
can you give the complete script please? icant get it to work dammed
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 03:42:13 am
Just put it together. Everything here is put on a platter for you to put together. Just Gotta move a few things around than bam. It should work as intended.

I too would like to be lazy and just have it handed to me but I'm going to work on it too since its for the exp. To lvl up you know.
Title: Re: Get all players positions
Post by: robin-580 on June 11, 2012, 03:54:18 am
i understand (;
i put everything together but i only get  the hint adding player markers when activated nothing happens  :icon_confused2
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 03:56:24 am
I'm still working on it myself. It helps to have  -showScriptErrors when you launch arma 2
atm I got it just spawning on myself.
Title: Re: Get all players positions
Post by: robin-580 on June 11, 2012, 03:58:17 am
i see ca you please post it or pm me if you have it fully working its like 2 a clock midnight here and im lazy :icon_teehee
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 04:00:26 am
I think I did it, now off to the testing grounds.  :icon_devil
Its probably not the most efficient code as I used 3 different scripts. I will post if it works.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 04:11:49 am
I haven't laughed so hard in a long time, let alone at a list of people who died.  :icon_laugh

So here's how to do it.
Create a folder in your Arma 2 OA folder called Scripts. Then add the following scripts to the folder then just load Spawn.sqf

Spawn.sqf
Code: [Select]
_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_veh = createVehicle ["Goat02_EP1" , position player, [], 0, "NONE"];
_move = _veh execVM "\Scripts\Move.sqf";
sleep 30;
terminate _move;
_explode = _unit execVM "\Scripts\Explode.sqf";
sleep 0.5;
terminate _explode;

};
};

Move.sqf
Code: [Select]
hint "Evil Goat Attack Enabled";

_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_this setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];

};
};

Explode.sqf
Code: [Select]
_shelltype = "Sh_105_HE";
_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_shelltype createVehicle [_pos select 0, _pos select 1, (_pos select 2) +5];
};
};
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 04:19:19 am
Hmm that just kills everyone and brings a script error up on line 19 on the move.sqf gunna run it again for further testing.
Title: Re: Get all players positions
Post by: darkrounge on June 11, 2012, 04:22:47 am
I guess you were in the same server when you demolished everything + killed everyone  :icon_devil
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 04:26:02 am
maybe. I'm doing small script changes as I'm working on it. Trying to get around some small errors. What he posted should work. But there is no goat.


Code: [Select]
_this setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
You forgot the ; in the move sqf. That should fix it.
Title: Re: Get all players positions
Post by: leebeasley on June 11, 2012, 04:26:34 am
Hmm that just kills everyone and brings a script error up on line 19 on the move.sqf gunna run it again for further testing.

Hmm, I get the same result.
Quite comical to see everyone rage when they die though. Goats also seem to be invisible or the shell just hits without the goat.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 04:36:38 am
Hmm that just kills everyone and brings a script error up on line 19 on the move.sqf gunna run it again for further testing.

Hmm, I get the same result.
Quite comical to see everyone rage when they die though. Goats also seem to be invisible or the shell just hits without the goat.

Its something in the Spawn.sqf because I commented out both other scripts and still no goat. :/
Im quite stumped.
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 04:37:45 am
I should be getting it here in a few more retries. Did a little bit of editing found a few more errors and found something a little off.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 04:48:17 am
Updated the code. It works on my private server. Care to test it out?
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 04:49:16 am
Whats the info? I'm still getting errors on the move.sqf
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 04:51:14 am
Sorry forgot the ; again.
Title: Re: Get all players positions
Post by: leebeasley on June 11, 2012, 05:04:10 am
Still the same results, no goat, everyone dies.
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 05:05:56 am
Code: [Select]
hint "Evil Goat Attack Enabled";

_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_this setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
};
};


He an extra enter at line 18. Trying again. Move script.sqf is still poping out errors when I run it.

Im tripping balls. Line 18 still is poping up in debug.
Title: Re: Get all players positions
Post by: Coronel_Niel on June 11, 2012, 05:17:47 am
Code: [Select]
hint "Evil Goat Attack Enabled";

_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_this setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
};
};

what is _this equal to?

He an extra enter at line 18. Trying again. Move script.sqf is still poping out errors when I run it.

Im tripping balls. Line 18 still is poping up in debug.


Look at line 18:
Code: [Select]
_this setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
What is _this and _pos? Are these both what you what? Are you sure these are spawning on players and not null-entities (isPlayer)
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 05:41:13 am
Code: [Select]
hint "Evil Goat Attack Enabled";

_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_rot = getDir _unit;
_veh setDir _rot;
_veh setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
};
};
Spawns them but does not follow.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 05:46:03 am
Code: [Select]
hint "Evil Goat Attack Enabled";

_unitList = allUnits;
j = count _unitList;
i = 0;
_markPos = true;

while {_markPos} do
{
_unitList = allUnits;
j = count _unitList;
i = 0;

for "i" from 0 to j do
{
_unit = _unitList select i;
_pos = position _unit;
_rot = getDir _unit;
_veh setDir _rot;
_veh setpos [_pos select 0, (_pos select 1) -2, (_pos select 2) +1];
};
};
Spawns them but does not follow.
Replace _veh with _this.
Title: Re: Get all players positions
Post by: zlake on June 11, 2012, 05:49:52 am
lol it flashes and the game lags hardcore when its time for bombs. Like feezes for a good min.
Title: Re: Get all players positions
Post by: rbneville on June 11, 2012, 05:51:50 am
Thats because the Explode.sqf the code that spawns the bombs is in a loop. Simply add sleep or remove the loop.
Title: Re: Get all players positions
Post by: MrMedic on June 11, 2012, 01:11:18 pm
No one has posted it yet but there is a way to get all active player characters and not the playable ai units with the same names.

I will let the 'elite' people post it , im happy using it for myself.  :smile
Title: Re: Get all players positions
Post by: malak-14 on June 14, 2012, 08:22:47 pm
nobody have a little script for see player in map ??? if you dont want release in public you can PM me , i can give you a script for spawn weapon undetect for the moment !! :icon_devil :icon_devil
Title: Re: Get all players positions
Post by: Coronel_Niel on June 14, 2012, 08:35:36 pm
No one has posted it yet but there is a way to get all active playable characters and not the playable ai units with the same names.

I will let the 'elite' people post it , im happy using it for myself.  :smile

I just filtered through both sets of data to get all units with a client connected. But yeah, happy using it right now
Title: Re: Get all players positions
Post by: MrMedic on June 15, 2012, 12:45:23 am
(http://i21.photobucket.com/albums/b270/tonyK1/arma2oa2012-06-1420-36-03-49.jpg)
(http://i21.photobucket.com/albums/b270/tonyK1/arma2oa2012-06-1420-35-17-21.jpg)
(http://i21.photobucket.com/albums/b270/tonyK1/arma2oa2012-06-1420-34-52-76.jpg)
(http://i21.photobucket.com/albums/b270/tonyK1/arma2oa2012-06-1420-28-06-87.jpg)

me to .