Jump to content
Sign in to follow this  
eegore

setvelocity loop

Recommended Posts

This is to simulate sex in a car in the classic GTA method.

car setvelocity [0, 0, 2];

I am trying to make a loop of this but I get errors.

Trig Activ: Car = execVM "carhop.sqf"

~1;
loop;
car setvelocity [0, 0, 2];
~1;
car setvelocity [0, 0, 2];
~1;
goto loop;

Something like that right?

Share this post


Link to post
Share on other sites

Thats sqs format and your calling it with sqf format

you need something like this

while {alive car} do {
car setvelocity [0, 0, 2];
sleep 1;
};

and call like this

mycar = execvm "carhop.sqf"

never have the object and the call handle with the same name it will cause problems.

Share this post


Link to post
Share on other sites

Thanks.

I'm always screwing up the .sqf changes. Ive tried to get this to work so I can have a "turbo" on a vehicle:

_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 10; comment "Added speed";
_vehicle setVelocity [
(_vel select 0) + (sin _dir * _speed), 
(_vel select 1) + (cos _dir * _speed), 
(_vel select 2)
];

But I just don't know enough so I trial and error a bunch of methods. For instance I believe this is a script that I call once I set a variable somewhere that describes specifically what _vehicle is.

Share this post


Link to post
Share on other sites

It depends, if it's for a player then you need to call the script through a key press eventhandler

save as init.sqf

disableSerialization;
sleep 1;
player setvariable ["brake",0];
_display = (findDisplay 46);
_display displayAddEventHandler ["KeyDown","if ((_this select 1) == 17) then {execvm 'boost.sqf'};if ((_this select 1) == 31) then {player setvariable ['brake',1]} else {player setvariable ['brake',0]}"];

save as boost.sqf

_speedX = 20;
_max = 130;

quit_this = true;



if (vehicle player != player) then {
	_veh = vehicle player;
         //  if (!isOnRoad (position player)) then {_speedX = 0.6} else {_speedX = 0.4};; 
	if (speed _veh > 20 and speed _veh < _max and(player getvariable "brake" == 0)) then {

		_vel = velocity _veh;
		_dir = getdir _veh;
		//_veh setvelocity [(_vel select 0) + _speedX * (sin _dir),(_vel select 1) + _speedX * (cos _dir),(_vel select 2)];


		_veh setVelocity [(_vel select 0)+(sin _dir*_speedX),(_vel select 1)+ (cos _dir*_speedX),(_vel select 2)];

	};

};

if it's for AI it needs to be in a loop

null=[vehiclename] execvm "Turbo_AI.sqf";

save as Turbo_AI.sqf

_vehicle = _this select 0;

while {true} do {
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 0.2; comment "Added speed";
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+
(cos _dir*_speed),(_vel select 2)];
sleep 0.001;
};

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  

×