| 3565 | //------------------------------------------------------------------------- |
| 3566 | |
| 3567 | BZF_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 |
| 3606 | BZF_API bool bz_registerCustomPluginHandler(const char* extension, bz_APIPluginHandler* handler) { |