Jump to content

Recommended Posts

Hello, I need you to help me with my small simple script that doesn't work. It always shows error in line 12 and I have no idea why. It should work but it doesn't.
It's called in vehicle init by:

vehbomb = [this] execVM "scripts\iedTruck.sqf";

This is iedTruck.sqf:

if (!isServer) exitWith {};

_vehicle = _this select 0;

while {alive _vehicle} do
{
	sleep 1;
	if ({alive _x} count _vehicle < 1) then {
		if (west countSide (getPos _vehicle nearEntities 15) >0) then {
			"Bo_GBU12_LGB" createVehicle getPos _vehicle;
		};
	};
};



*EDIT* I'd like to ask someone to move this thread to Arma 3 Editing and scripting. Created it here by mistake, thank you!

Share this post


Link to post
Share on other sites

Thread moved

 

20 hours ago, HonzaVinCZ said:

shows error

What error?

 

20 hours ago, HonzaVinCZ said:

in line 12

Your snippet is only 13 lines. Line 12 is just a };. Don't see how a error might happen down there.

 

 

20 hours ago, HonzaVinCZ said:

{alive _x} count _vehicle

What is that? count doesn't take object as argument

https://community.bistudio.com/wiki/count

  • Like 2

Share this post


Link to post
Share on other sites
21 hours ago, Dedmen said:

Thread moved

 

What error?

 

Your snippet is only 13 lines. Line 12 is just a };. Don't see how a error might happen down there.

 

 

What is that? count doesn't take object as argument

https://community.bistudio.com/wiki/count

Hey! Thank you for answer. Basically whole game was broken and it showed error on that 12 line. There was in the error something like " };|#| " like something missing. I tried to edit it but even simple script that loops nothing didn't work. So I restarted game and then it finally worked as it should. I did small mistake in script anyway but my current script looks like this:
 

if (!isServer) exitWith {};

_vehicle = _this select 0;

while {alive _vehicle} do
{
	if ((player in _vehicle) and (west countSide (getPos _vehicle nearEntities 15) >0)) then 
	{
		"Bo_GBU12_LGB" createVehicle getPos _vehicle;
	};
	sleep 1;
};

I'd like to add hint on vehicle enter that shows only to that player who enters the vehicle. If possible only to east side, something like
hint "This is SVBIED vehicle".
But I don't know how to manage it to add it without repeating that message in that "while" condition. 

Share this post


Link to post
Share on other sites
8 minutes ago, HonzaVinCZ said:

I'd like to add hint on vehicle enter

You can use a eventhandler for that.

https://community.bistudio.com/wiki/addEventHandler

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

 

Just add the handler to the vehicle.

 

For your while condition just instead of sleep 1, wait till the player is not in the vehicle anymore.

like this:

waitUntil {!(player in _vehicle)};

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
53 minutes ago, Dedmen said:

You can use a eventhandler for that.

https://community.bistudio.com/wiki/addEventHandler

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

 

Just add the handler to the vehicle.

 

For your while condition just instead of sleep 1, wait till the player is not in the vehicle anymore.

like this:


waitUntil {!(player in _vehicle)};

 

 


I'm suprised how easy is that. I didn't realize I can use event handler. Thank you a lot! 
That's my script after edit:

if (!isServer) exitWith {};

_vehicle = _this select 0;

_vehicle addEventHandler ["GetIn", {hint "This is SVBIED vehicle"}];

while {alive _vehicle} do
{
	if ((player in _vehicle) and (west countSide (getPos _vehicle nearEntities 15) >0)) then 
	{
		"Bo_GBU12_LGB" createVehicle getPos _vehicle;
	};
	waitUntil {!(player in _vehicle)};
};

 

Share this post


Link to post
Share on other sites

question/suggestion:

did someone try to add a killed event handler to a vehicle and did it work?

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

×