Poll

Just Curious: Do you think vehicles should have sounds?

Yes
I really don't give a stuff
No
HELL YES! I hate driving in an epic TDM with bullets flying, I gun the vehicle and... And... *Vehicle silently goes faster*. Gay.
NO! I hate it when people strive to make better more realistic vehicles in a game where it's supposed to be simple!

Author Topic: Engine Sounds: Not Playing! Help?  (Read 2067 times)

The engine sounds will not play in-game. There are NO syntax errors. It executes fine. Its not the audio files because I tried ones that do work in-game on other vehicles. Whats wrong here? Can anyone help out?
Helpers: Hum17 is my vehicle name. It's a custom Humvee for me. (I like 17). Idle.wav and Driving.wav are just the engine sounds (They aren't the problem). The rest, if you know even a little in scripting you should understand pretty well.

Code: [Select]
// ============================================================
// Project            :  Blockland Projects
// File               :  ..\Add-Ons\Vehicle_Hum17\engine.cs
// Copyright          :  
// Author             :  CJ
// Created on         :  Friday, October 26, 2012 3:40 PM
//
// Editor             :  TorqueDev v. 1.2.3430.42233
//
// Description        :  
//                    :  
//                    :  
// ============================================================

datablock AudioProfile(Hum17Throttle1Sound)
{
  filename = "./driving.wav";
  description = AudioClosest3d;
  preload = true;
};

datablock AudioProfile(Hum17IdleSound)
{
  filename = "./idle.wav";
  description = AudioClosest3d;
  preload = true;
};

function Hum17SpeedCheck(%this, %obj)
{


if(!isObject(%obj))
return;

%vehicle = %obj;
%slot = 0; //Play the sound in the driver's spot
%speed = vectorLen(%obj.getVelocity());

if(%speed < 0) //Keeps throwing random negative numbers when train is at dead stop
   %speed = 0;

if(%speed < 10)
   %vehicle.playAudio(%slot, Hum17idleSound);

else if(%speed < 30)
   %vehicle.playAudio(%slot, Hum17throttle1Sound);




   

schedule(500,0,"Hum17SpeedCheck",%this,%obj);
}
« Last Edit: October 28, 2012, 01:23:08 PM by CJrocks17 »

ALSO: PLEASE NOTE: NO syntax errors! Nothing in console except Exec("add-ons/vehicle_Hum17/engine.cs");
Then there is a runtime error.

That's all.

that is way too much whitespace.

does all the crap you have in there exist? have you defined all the sounds properly?

I thought it had to be .ogg's not .wav''s

that is way too much whitespace.

does all the crap you have in there exist? have you defined all the sounds properly?

I thought it had to be .ogg's not .wav''s

... No sir, sounds are .wav in add-ons. .ogg is for music.

Too much whitespace do to format conversion in copy/paste. I use a Torque script program to script. Also, it keeps organization. I hate idiots that cram stuff into a script so no one can read it.

Anyways, yes, everything is defined correctly I believe. I'll double check.

Oh my god. The driving.wav is 19 MB lol. Maybe that's why? LOL :P

If that's not why and I get it fixed, that will be a loving hell of a download for ya! :D


Ok. Bump. It's a new problem. Didn't feel like adding more spam to the forums so I'll use this one. Same stuff anyway.

Edit: ALSO: There are 3 .cs files:
Server.cs (Executes Hum17.cs and Engine.cs)
Hum17.cs
Engine.cs (This is what has a problem in it.)

Maybe it is BECAUSE it's in a separate .cs?
« Last Edit: October 28, 2012, 01:27:21 PM by CJrocks17 »

What initially calls Hum17SpeedCheck for a given vehicle?

What initially calls Hum17SpeedCheck for a given vehicle?
Oh. Dammit. I don't believe anything does :P
Any idea on how I should approach this? How should I call it?
I guess I was assuming you didn't need to call it... I have not idea why.
Ok, I'm going to be back on later I'll check the status of this topic.

Thanks a lot!

Oh. Dammit. I don't believe anything does :P
Any idea on how I should approach this? How should I call it?
I guess I was assuming you didn't need to call it... I have not idea why.
Ok, I'm going to be back on later I'll check the status of this topic.

Thanks a lot!
Hint: Check Stunt Plane's code, specifically the contrail part.
In the main Vehicle_StuntPlane.cs

Code: [Select]
function Hum17vehicle::onadd(%this,%obj)
{
Hum17SpeedCheck(%this, %obj);
}

That would solve all this right?

Code: [Select]
function Hum17vehicle::onadd(%this,%obj)
{
Hum17SpeedCheck(%this, %obj);
}

That would solve all this right?
Try it.
A main part of scripting is testing it a lot to make sure there aren't any bugs or problems with it no matter what you do.

AHA! I fixed it :D :D :D

Code: [Select]
function gc_Hum17Vehicle::onadd(%this,%obj)
{
Hum17SpeedCheck(%this, %obj);
parent::onadd(%this,%obj);
%obj.playThread(0,"spin");
Hum17SpeedCheck(%this, %obj);
%obj.setWheelTire(0, Hum17tire);
%obj.setWheelTire(1, Hum17tire);
%obj.setWheelTire(2, Hum17tire);
%obj.setWheelTire(3, Hum17tire);
}

Fixed! :D But now I have a different "problem":

Code: [Select]
function Hum17SpeedCheck(%this, %obj)
{


if(!isObject(%obj))
return;

%vehicle = %obj;
%slot = 0; //Play the sound in the driver's spot
%speed = vectorLen(%obj.getVelocity());

if(%speed < 0)
    %speed = 0;

if(%speed < 10)
    %vehicle.playAudio(%slot, Hum17idleSound);

else if(%speed < 30)
    %vehicle.playAudio(%slot, Hum17throttle1Sound);




   

schedule(500,0,"Hum17SpeedCheck",%this,%obj);
}

How do I make it play NO sound at all when it's not moving? What values and or inequalities do I put in?

Bump:

If I haven't clarified, I just need help on making the vehicle NOT make any sound when it is at a stand still.

Is that possible?

In that speedcheck code you're checking if the speed is less than 0, then setting it to 0.
Afterwards you check if it's less than 10, if it is you play that sound.
After that.. you check if it's less than 30, if it is you play that sound.

So to make it play no sound you just have to alter around and change some stuff in your ifs