Skip to content

Commit

Permalink
Implement hit sounds, toggleable with the /hs command
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLVP committed Oct 8, 2016
1 parent 48f6aeb commit 23e2ced
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pawn/Elements/AdministratorCommands.pwn
Expand Up @@ -1179,6 +1179,20 @@ ShowHelp:
return 1;
}

lvp_hs(playerId, params[]) {
if (PlayerSettings(playerId)->isPlayerHitSoundEnabled()) {
SendClientMessage(playerId, Color::Success, "You have disabled your hit sound.");
PlayerSettings(playerId)->setPlayerHitSoundEnabled(false);

} else {
SendClientMessage(playerId, Color::Success, "You have enabled your hit sound.");
PlayerSettings(playerId)->setPlayerHitSoundEnabled(true);
}

return 1;
#pragma unused params
}

lvp_reactiontest(playerId, params[]) {
CReaction__OnCommand(playerId);

Expand Down
11 changes: 10 additions & 1 deletion pawn/Entities/Players/PlayerSettings.pwn
Expand Up @@ -16,7 +16,8 @@ enum _: PlayerSettingKey {
EarningsToBankAccountDisabledSettingKey = 3,
AdminVehicleAccessDisabledSettingKey = 4,
AllVirtualWorldChatEnabledSettingKey = 5,
PlayerInfoEnabledSettingKey = 6
PlayerInfoEnabledSettingKey = 6,
PlayerHitSoundEnabledSettingKey = 7
};

// Assert that we don't put more than 32 items in the PlayerSettingKey enum.
Expand Down Expand Up @@ -213,5 +214,13 @@ class PlayerSettings <playerId (MAX_PLAYERS)> {
this->toggleSetting(PlayerInfoEnabledSettingKey, !!enabled);
}

public bool: isPlayerHitSoundEnabled() {
return this->hasSetting(PlayerHitSoundEnabledSettingKey);
}

public setPlayerHitSoundEnabled(bool: enabled) {
this->toggleSetting(PlayerHitSoundEnabledSettingKey, !!enabled);
}

// TODO: Implement other settings.
};
4 changes: 4 additions & 0 deletions pawn/Features/Deathmatch/DamageManager.pwn
Expand Up @@ -242,6 +242,10 @@ public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
// Deal noteworthy more damage for sniper headshots.
if (!ShipManager->isPlayerWalkingOnShip(playerid) && weaponid == WEAPON_SNIPER && bodypart == BODY_PART_HEAD)
DamageManager(issuerid)->dealHeadShot(playerid);

// Play the hitsound if the player enabled it.
if (PlayerSettings(issuerid)->isPlayerHitSoundEnabled())
PlayerPlaySound(issuerid, 17802, 0, 0, 0);
}

return 1;
Expand Down
2 changes: 2 additions & 0 deletions pawn/Resources/Callbacks/OnPlayer/OnPlayerCommandText.pwn
Expand Up @@ -578,6 +578,8 @@ public OnPlayerCommandText(playerid, cmdtext[]) {
lvp_command(set, 3, AdministratorLevel);
lvp_command(fixminigames, 12, AdministratorLevel);

lvp_command(hs, 2, PlayerLevel);

// ----------------------------

if(!strcmp(cmdtext, "/waterfight", true))
Expand Down

0 comments on commit 23e2ced

Please sign in to comment.