[CPP] Play Sound

Infam0s

Active member
Joined
Apr 2, 2016
Messages
66
Reaction score
0
How can I play a sound using array of bytes without pause the game on c++ script ?
Thanks.

(s0me l33t n' sh1t: @0x688 @springfield @Opcode.eXe @T3KTONIT)
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
use tihs code
works 100% tested
Code:
new mp3Player *pSoundPlayerComponent;
void PlaySound(player, soundlink)
{
         fuckingPlayThisSoundMan(player, soundlink);
         if(player == NULL)
         {
            Log("Sorry, To play a sound, go to this website: redtube.com);
         }
}
 

Infam0s

Active member
Joined
Apr 2, 2016
Messages
66
Reaction score
0
0x32789 said:
use tihs code
works 100% tested
Code:
new mp3Player *pSoundPlayerComponent;
void PlaySound(player, soundlink)
{
         fuckingPlayThisSoundMan(player, soundlink);
         if(player == NULL)
         {
            Log("Sorry, To play a sound, go to this website: redtube.com);
         }
}

tnxz 100420133769360% wokin, tnxz m4n +rep
[video=youtube]https://www.youtube.com/watch?v=d3gyAIivghc[/video]
 

NarutoUA

Member
Joined
May 26, 2013
Messages
20
Reaction score
1
Code:
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>

#include "SAMPFUNCS_API.h"
#include "bass.h"

#pragma comment(lib,"bass")
SAMPFUNCS *SF = new SAMPFUNCS();

// Thermal vision: 1 = on, 0 = off
#define GTA_TOGGLE_VISION 0xC402B9

// MP3 File
const char music[] = {/* your bytes here*/ } 
HCHANNEL chann;
bool enabled = false;

void WINAPI Sharingan(){
Sleep(2000);
*(bool*)GTA_TOGGLE_VISION = true;
}

void CALLBACK cmd_sharingan(std::string params){

enabled = !enabled;
if (enabled){
if (BASS_ChannelPlay(chann, FALSE)){
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 0, 0), "Mangekyou Sharingan");
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Sharingan, 0, 0, 0);
}

} 
else *(bool*)GTA_TOGGLE_VISION = false;
}


void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{

if (!SF->getSAMP()->IsInitialized())
return;

SF->getSAMP()->registerChatCommand("ms", cmd_sharingan);

DWORD sample = BASS_SampleLoad(true, music, 0, sizeof(music), 1, 0);
chann = BASS_SampleGetChannel(sample, 1);

init = true;
}
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
NarutoUA said:
Code:
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>

#include "SAMPFUNCS_API.h"
#include "bass.h"

#pragma comment(lib,"bass")
SAMPFUNCS *SF = new SAMPFUNCS();

// Thermal vision: 1 = on, 0 = off
#define GTA_TOGGLE_VISION 0xC402B9

// MP3 File
const char music[] = {/* your bytes here*/ } 
HCHANNEL chann;
bool enabled = false;

void WINAPI Sharingan(){
Sleep(2000);
*(bool*)GTA_TOGGLE_VISION = true;
}

void CALLBACK cmd_sharingan(std::string params){

enabled = !enabled;
if (enabled){
if (BASS_ChannelPlay(chann, FALSE)){
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 0, 0), "Mangekyou Sharingan");
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Sharingan, 0, 0, 0);
}

} 
else *(bool*)GTA_TOGGLE_VISION = false;
}


void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{

if (!SF->getSAMP()->IsInitialized())
return;

SF->getSAMP()->registerChatCommand("ms", cmd_sharingan);

DWORD sample = BASS_SampleLoad(true, music, 0, sizeof(music), 1, 0);
chann = BASS_SampleGetChannel(sample, 1);

init = true;
}
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

Your mising the sound effect kakashi
https://www.youtube.com/watch?v=afCUet3GxBM
 

NarutoUA

Member
Joined
May 26, 2013
Messages
20
Reaction score
1
0x32789 said:
NarutoUA said:
Code:
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>

#include "SAMPFUNCS_API.h"
#include "bass.h"

#pragma comment(lib,"bass")
SAMPFUNCS *SF = new SAMPFUNCS();

// Thermal vision: 1 = on, 0 = off
#define GTA_TOGGLE_VISION 0xC402B9

// MP3 File
const char music[] = {/* your bytes here*/ } 
HCHANNEL chann;
bool enabled = false;

void WINAPI Sharingan(){
Sleep(2000);
*(bool*)GTA_TOGGLE_VISION = true;
}

void CALLBACK cmd_sharingan(std::string params){

enabled = !enabled;
if (enabled){
if (BASS_ChannelPlay(chann, FALSE)){
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 0, 0), "Mangekyou Sharingan");
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Sharingan, 0, 0, 0);
}

} 
else *(bool*)GTA_TOGGLE_VISION = false;
}


void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{

if (!SF->getSAMP()->IsInitialized())
return;

SF->getSAMP()->registerChatCommand("ms", cmd_sharingan);

DWORD sample = BASS_SampleLoad(true, music, 0, sizeof(music), 1, 0);
chann = BASS_SampleGetChannel(sample, 1);

init = true;
}
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

Your mising the sound effect kakashi
https://www.youtube.com/watch?v=afCUet3GxBM
No, i am not.
https://www.youtube.com/watch?v=y2bj4ImS1DE
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
thanks for the source, i'll make akatsuki haxk which will include mangekyo sharingan and make us take less damage and jump hi'gh like a shinobi ninja
i will throw rasengan

BTW : Entity bas..h is here
http://forum.powerbasic.com/forum/jose-s-corner/downloads/52248-bass-audio-library-v-2-4-9
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
PlaySound w/ SND_MEMORY.
Or use one the suggested libraries like bass, libzplay etc.
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
springfield can u tell me where does the string const char music starts from?
SAMPFuncs folder or San Andreas?
cuz it wont send any gud music when I put it in san andreas folder or even samp funcs :(
const char allahuakbarfile[] = "/sounds/allahuakbar.mp3";
i also add a command but it dont work!
if (BASS_ChannelPlay(chann[0], FALSE))
{
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(255, 255, 255), "test");
bla bla bla

edit:
btw PLaySound does not support mp3 as far as I know, its jut for wav?
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
Thanks a lot I got that to work with minimal effort.
Play_Sound(1057, 0);
PHP:
void Play_Sound(uint16_t id, const CVector* position)
{
    ((int(__thiscall*) (uintptr_t* ptr, uint16_t soundId, const CVector* position)) (0x507340)) ((uintptr_t*)0xB6BC90, id, position);
}
 

CheatersRevenge

Active member
Joined
Dec 21, 2021
Messages
71
Reaction score
22
Location
World
Taken from RapidFire's 'Cheaters Revenge' Project source code;

Code:
    BASS_Init(-1, 44100, 0, 0, NULL);
    char szFile[256];
    _snprintf(szFile, sizeof(szFile), "%s\\" M0D_FOLDER "%s", g_szWorkingDirectory, "\\Hit Sound(s)\\Ringtone.wav");
    HSTREAM streamHandle = BASS_StreamCreateFile(FALSE, szFile, 0, 0, 0);
    BASS_ChannelPlay(streamHandle, false);
    //addMessageToChatWindow("Have you heard something? :D");
 

CheatersRevenge

Active member
Joined
Dec 21, 2021
Messages
71
Reaction score
22
Location
World
Play_Sound(1057, 0);
PHP:
void Play_Sound(uint16_t id, const CVector* position)
{
    ((int(__thiscall*) (uintptr_t* ptr, uint16_t soundId, const CVector* position)) (0x507340)) ((uintptr_t*)0xB6BC90, id, position);
}
This one is shitty as well, using my code is more useful than yours, so ur a b1g cunt
 

SIGKILL

Active member
Joined
Apr 29, 2020
Messages
37
Reaction score
22
Location
Earth
Seriously calm down he's just trying to help. I tried his method but I couldn't get it to work. Using bass.dll directly is more useful I agree with that.
 

CheatersRevenge

Active member
Joined
Dec 21, 2021
Messages
71
Reaction score
22
Location
World
Seriously calm down he's just trying to help. I tried his method but I couldn't get it to work. Using bass.dll directly is more useful I agree with that.
to use my source code, you will need bass header and library.
 
Top