MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / bz_sendPlayCustomLocalSound

Function bz_sendPlayCustomLocalSound

src/bzfs/bzfsAPI.cpp:3567–3603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3565//-------------------------------------------------------------------------
3566
3567BZF_API bool bz_sendPlayCustomLocalSound(int playerID, const char* soundName,
3568 const float* pos) {
3569 if (playerID == BZ_SERVER || !soundName) {
3570 return false;
3571 }
3572
3573 NetMessage netMsg;
3574
3575 uint8_t bits = 0;
3576 if (pos != NULL) {
3577 bits |= SoundPosition;
3578 }
3579
3580 netMsg.packUInt8(LocalCustomSound); // sound type
3581 netMsg.packUInt8(bits);
3582 netMsg.packStdString(std::string(soundName));
3583 if (pos != NULL) {
3584 netMsg.packFVec3(fvec3(pos[0], pos[1], pos[2]));
3585 }
3586
3587 if (playerID == BZ_ALLUSERS) {
3588 for (int i = 0; i < curMaxPlayers; i++) {
3589 GameKeeper::Player* p = GameKeeper::Player::getPlayerByIndex(i);
3590 if (p && p->caps.canPlayRemoteSounds) {
3591 netMsg.send(p->netHandler, MsgCustomSound);
3592 }
3593 }
3594 }
3595 else {
3596 GameKeeper::Player* player = GameKeeper::Player::getPlayerByIndex(playerID);
3597 if (player && player->caps.canPlayRemoteSounds) {
3598 netMsg.send(player->netHandler, MsgCustomSound);
3599 }
3600 }
3601
3602 return true;
3603}
3604
3605// custom pluginHandler
3606BZF_API bool bz_registerCustomPluginHandler(const char* extension, bz_APIPluginHandler* handler) {

Callers 12

PlaySoundFunction · 0.85
KillTeamFunction · 0.85
handleMethod · 0.85
killTeamsFunction · 0.85
killPlayersFunction · 0.85
initiatekeepawayFunction · 0.85
playAlertFunction · 0.85
processMethod · 0.85
killAllHuntersFunction · 0.85
killTeamsFunction · 0.85
killPlayersFunction · 0.85
initiatekothFunction · 0.85

Calls 5

packUInt8Method · 0.80
packStdStringMethod · 0.80
packFVec3Method · 0.80
getPlayerByIndexFunction · 0.50
sendMethod · 0.45

Tested by 1

handleMethod · 0.68