|
|
|
|
Would you like to get all the new info from
PSX-Scene in your email each day?
Want to learn more about the team keeping you up to date with the latest scene news?
Read about them now! Check out our Developer bios, too! | ||
|
|
Hey guys,
I have today different styles of speedometers. I figure why not have a speedometer you can see from all the way back on the couch. lol They are about the size of mini map. Better Screenshots also included in Download.
Download SCO's/ Source
Credits to skorpo for his speedometer.
Heres the Source.
Code:#include <natives.h> #include <common.h> #include <consts.h> #include <types.h> #include <strings.h> void SkorproTextAndInt(float x1, float y1, int red1, int green1, int blue1, int num, float x2, float y2, int red2, int green2, int blue2) { // TEXT SET_TEXT_FONT(1); // TEXTFONT_LED SET_TEXT_BACKGROUND(0); SET_TEXT_SCALE(0.88, 1.08); SET_TEXT_COLOUR(red1, green1, blue1, 255); SET_TEXT_EDGE(1, 0, 0, 0, 0); SET_TEXT_RIGHT_JUSTIFY(0); SET_TEXT_DROPSHADOW(0, 255, 255, 255, 255); DISPLAY_TEXT_WITH_LITERAL_STRING(x1, y1, "STRING", "MPH"); // NUM SET_TEXT_FONT(1); // TEXTFONT_LED SET_TEXT_BACKGROUND(0); SET_TEXT_SCALE(1.76, 2.16); SET_TEXT_COLOUR(red2, green2, blue2, 255); SET_TEXT_EDGE(1, 0, 0, 0, 0); SET_TEXT_RIGHT_JUSTIFY(0); SET_TEXT_DROPSHADOW(0, 255, 255, 255, 255); DISPLAY_TEXT_WITH_NUMBER(x2, y2, "NUMBER", num); } void funnycar(void) { Car veh_speed; float fSpeed; int iSpeed; bool rep_speed = 0; if (IS_CHAR_IN_ANY_CAR(GetPlayerPed())) { rep_speed = 1; } else { rep_speed = 0; } if (rep_speed == 1) // LOOP start { if (!IS_CHAR_IN_ANY_CAR(GetPlayerPed())) { rep_speed = 0; // LOOP end } GET_CAR_CHAR_IS_USING(GetPlayerPed(), &veh_speed); GET_CAR_SPEED(veh_speed, &fSpeed); fSpeed = fSpeed * 2.94; // Speed multiplier iSpeed = (int) fSpeed; // float to int SkorproTextAndInt(0.4, 0.865, 0, 255, 0, iSpeed, 0.17, 0.8, 255, 0, 0); } } void main(void){ THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME(); while(true) { funnycar(); WAIT(0); } }
You sir, have just earned yourself a mod folder on my Desktop
But this is great, I'll add this to something soon.![]()
I couldn't find anything really apart from the sound files themselves, I found two similar sounds to being in the heart.
I take it you can add sounds somehow?
For the car wash SCO, I found this (L349):
It seems there are two types if of audio. Audio or audio bank (A collection of sounds associated). So, this audio bank contains all the noises associated with the car wash unlike the normal audio file.Code:REQUEST_AMBIENT_AUDIO_BANK( "SCRIPT_AMBIENT/CAR_WASH" );
So, with this you would do something like:
Is that correct? Press X to play a sound?Code:void soundtest(void){ if(IS_BUTTON_JUST_PRESSED(0,X){ REQUEST_AMBIENT_AUDIO_BANK("SCRIPT_AMBIENT/CAR_WASH"); PLAY_AUDIO_EVENT("SCRIPT_AMBIENT/CAR_WASH"); Print("Sound Test 1: Car Wash"); } }
No, I think theres more to it.
I am looking at this car wash script, this is what I've discovered, and think how it works:
It seems a sound ID is always greater than -1Code:l_U267 = "CAR_WASH_BARRIER"; l_U268 = "CAR_WASH_SPRAY"; l_U269 = "CAR_WASH_BRUSH_MOTOR"; l_U270 = "CAR_WASH_BRUSHES"; l_U271 = "CAR_WASH_PAY"; REGISTER_SCRIPT_WITH_AUDIO( 0 ); // Register the script with audio. GET_SOUND_ID(); // Returns an ID? RELEASE_SOUND_ID(); // Releases an ID? Might be deallocation. REQUEST_AMBIENT_AUDIO_BANK( Audio bank file ( ie "SCRIPT_AMBIENT/CAR_WASH") ); // Load a audio bank. AMBIENT_AUDIO_BANK_NO_LONGER_NEEDED(); // Memory? UNREGISTER_SCRIPT_WITH_AUDIO(); // Unregister the script with audio. HAS_SOUND_FINISHED( Sound ID ); // Has sound finished playing? STOP_SOUND( Sound ID ); // Stop sound. PLAY_SOUND_FROM_POSITION( Sound ID, X, Y); // Play the sound? PLAY_SOUND_FROM_POSITION( Sound ID, Sound Name, ?); // Play the sound? The final parameter might be a vector (Could be a struct with fields X, Y, and Z?)
Once a sound is released, the variable that contained it is always assigned to -1
I will try and make a script out of this in a second.
EDIT:
Possible way to produce sound:
Still looking into this. Trying to work out the final parameter for PLAY_SOUND_FROM_POSITION(). I don't think its a vector, whatever it is it is heavily used for calculations. It might be the Z coordinate. Try leaving it as 0.Code:uint soundId = -1; // Sound IDs are greater than -1. The initial assignment is used as a test condition later. I see a lot of variables initialised without a data type. It is more than likely a integer (uint, int, etc) // The sounds that are inside this audio bank. Loaded later on in the script. const char* carWashBarrierSound = "CAR_WASH_BARRIER"; const char* carWashSpraySound = "CAR_WASH_SPRAY"; const char* carWashBrushMotorSound = "CAR_WASH_BRUSH_MOTOR"; const char* carWashBrushesSound = "CAR_WASH_BRUSHES"; const char* carWashPaySound = "CAR_WASH_PAY"; REGISTER_SCRIPT_WITH_AUDIO(0); // Not sure what this could possibly do, but it seems essential. It might be related to memory. // Load the audio bank into memory. if (REQUEST_AMBIENT_AUDIO_BANK( "SCRIPT_AMBIENT/CAR_WASH" )) { AMBIENT_AUDIO_BANK_NO_LONGER_NEEDED(); // Memory related. } // Get sound ID. This doesn't seem related to anything, so maybe this is simply a randomly generated ID for sounds? // If only one bank/audio file can be loaded at one time, then it could possibly be the ID of either that was loaded in memory (above). soundId = GET_AUDIO_ID(); // Fire when X button is pressed. if(IS_BUTTON_PRESSED(0, BUTTON_X)) { // If again my theory is right about only one audio item can be loaded into memory at one time, then this makes sense. // Pass in the ID of that audio item, then pass in the sound you want to play. PLAY_SOUND_FROM_POSITION(soundId, carWashBarrierSound, ?); // I don't know what this final parameter is. Cannot tell from the code. It might be a vector however. } // Once either sound has finished playing... // This native could be used to stop sound by negation, and then simply calling STOP_SOUND(soundId); if(HAS_SOUND_FINISHED(soundId)) { // Release the ID (Allocated above, and now deallocated). // Testing whether or not to release the ID could also be done by checking if the variable is greater than -1. RELEASE_SOUND_ID(soundId); } // Similar to the first native call. I think it's memory-related. UNREGISTER_SCRIPT_WITH_AUDIO();
EDIT 2:
Looking at natives.h, it shows that the final parameter for PLAY_SOUND_FROM_POSITION is the X coordinate, the Y and Z coordinates can be passed as the other two final parameters.
Here is the list of native definitions for the natives associated to producing sound:
Code:extern void REGISTER_SCRIPT_WITH_AUDIO(boolean reg); // Register script with audio. extern void UNREGISTER_SCRIPT_WITH_AUDIO(void); // Un-register script with audio. extern uint GET_SOUND_ID(void); // Generate a sound ID. Sound IDs are uints. extern void RELEASE_SOUND_ID(uint sound); // Release the sound ID. extern boolean HAS_SOUND_FINISHED(uint sound); // Checks whether or not sound from the audio asset has finished playing. extern void STOP_SOUND(uint sound); // Stop the sound. extern void PLAY_SOUND_FROM_POSITION(int sound_id, char *name, float x, float y, float z); // Play a sound from the loaded audio asset. extern boolean REQUEST_AMBIENT_AUDIO_BANK(char *name); // Load an audio bank. extern void AMBIENT_AUDIO_BANK_NO_LONGER_NEEDED(void); // Mark the audio bank as no longer needed.
Last edited by Raeralus; 01-05-2013 at 04:57 PM.
| « Previous Thread | Next Thread » |
| Tags for this Thread |