Skip to content

Commit

Permalink
Enable players to reset their custom colour
Browse files Browse the repository at this point in the history
Fixes #383
  • Loading branch information
RussellLVP committed Oct 12, 2016
1 parent 1ae76db commit 22b481b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pawn/Features/Gameplay/Colors/ColorManager.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ class ColorManager {
this->synchronizePlayerColorIndex(playerId);
}

public releasePlayerCustomColor(playerId) {
m_playerColorStack[playerId][CustomColorIndex] = InvalidColorId;
this->synchronizePlayerColorIndex(playerId);
}

/**
* Stores a copy of the current player's custom color in a local buffer. This is necessary
* because giving a player temporary administrator rights shouldn't override the
Expand Down
12 changes: 10 additions & 2 deletions pawn/Features/Gameplay/VIP/VeryImportantPlayersCommands.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class VeryImportantPlayersCommands {
* @param playerId Id of the player who is changing their colour.
* @param subjectId Id of the player who this command should be applied to.
* @param params Any further text that the player passed to the command. Unused.
* @command /my color
* @command /my color [reset]?
*/
@switch(PlayerCommand, "color")
public onPlayerColorCommand(playerId, subjectId, params[]) {
Expand All @@ -208,11 +208,19 @@ class VeryImportantPlayersCommands {
if (playerId != subjectId)
return 0; /* VIPs don't need admins to change their color for them */

if (Player(playerId)->isVip() == false && Player(playerId)->isAdministrator() == false) {
if (!Player(playerId)->isVip() && !Player(playerId)->isAdministrator()) {
SendClientMessage(playerId, Color::Error, "This is a VIP only command. For more information, check out \"/donate\"!");
return 1;
}

// Handle the case where the player typed "/my color reset" to be subject to randomness again.
if (Command->parameterCount(params) == 1 && !strcmp(params, "reset", true, 5)) {
ColorManager->releasePlayerCustomColor(playerId);

SendClientMessage(playerId, Color::Success, "Your custom color has been reset!");
return 1;
}

// The color changing itself is done within the ColorPicker class.
ColorPicker->showColorPicker(playerId, PlayerColor);

Expand Down

0 comments on commit 22b481b

Please sign in to comment.