Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Add /unfreeze and /setcash ( #54 )
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeAlDente committed Jan 24, 2018
1 parent 702c0ca commit 80e8173
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pawno/include/PPC_Defines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ new ACommands[][TCommands] =
{1, "/car", "Spawns a car of your choice"},
{1, "/endspec", "Stop spectating a player"},
{1, "/freeze <Player> <Duration (in Seconds)> <Reason>", "Freeze a player for a certain time in seconds"},
{1, "/unfreeze <Player>", "Unfreeze a player"},
{1, "/fuel", "Refuels your vehicle for free"},
{1, "/get <Player>", "Teleports another player to your location"},
{1, "/jail <Player> <Duration (in Seconds)> <Reason>", "Jails another player for a certain time in seconds"},
Expand Down Expand Up @@ -1046,6 +1047,7 @@ new ACommands[][TCommands] =
{3, "/rangeban <Player> <Reason>", "Ban a player's entire IP-range"},
{3, "/repairall", "Repair all vehicles for free"},
{3, "/setscore <Player> <Amount>", "Sets another player's score to the given value"},
{3, "/setcash <Player> <Amount>", "Sets another player's money to the given value"},
{3, "/unban <PlayerToUnban>", "Unban a player"},
{4, "/cash <amount>", "Give cash to yourself"},
{4, "/score <amount>", "Give scorepoints to yourself"},
Expand Down
104 changes: 104 additions & 0 deletions pawno/include/PPC_PlayerCommands.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3999,6 +3999,60 @@ COMMAND:freeze(playerid, params[])
return 1;
}

// Unfreeze a player (he can move again)
COMMAND:unfreeze(playerid, params[])
{
// Setup local variables
new Msg[128], Name[24], AdminName[24], Reason[128], OtherPlayer, Duration;

// Send the command to all admins so they can see it
SendAdminText(playerid, "/unfreeze", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "uis[128]", OtherPlayer)) SendClientMessage(playerid, COLOR_RED, "Usage: \"/unfreeze <Player>\"");
else
{
// Check if the otherplayer is online
if (IsPlayerConnected(OtherPlayer))
{
// Check if the player is frozen
if (APlayerData[playerid][PlayerFrozen] >= 1) {
// Just set the frozen timer to zero
// the freeze timer will do the rest
APlayerData[playerid][PlayerFrozen] = 0;

// Get the player names
GetPlayerName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(OtherPlayer, Name, sizeof(Name));
// Let the other player know that he has been un-frozen
format(Msg, 128, "{FF0000}You have been un-frozen by {FFFF00}%s {FF0000}for {FFFF00}%s", AdminName, Reason);
SendClientMessage(OtherPlayer, COLOR_WHITE, Msg);
// Let the admin know who he has un-frozen
format(Msg, 128, "{00FF00}You have un-frozen {FFFF00}%s", Name);
SendClientMessage(playerid, COLOR_WHITE, Msg);
}
else
SendClientMessage(playerid, COLOR_RED, "That player has not been frozen");
}
else
SendClientMessage(playerid, COLOR_WHITE, "{FF0000}That player isn't online");
}
}
else
return 0;
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}

// Transfer money to another player
COMMAND:givecash(playerid, params[])
{
Expand Down Expand Up @@ -5035,6 +5089,56 @@ COMMAND:setscore(playerid, params[])
return 1;
}

// Sets the money of another player
COMMAND:setcash(playerid, params[])
{
// Setup local variables
new Msg[128], Name[24], OtherName[24], OtherPlayer, pMoney;

// Send the command to all admins so they can see it
SendAdminText(playerid, "/setcash", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 3
if (APlayerData[playerid][PlayerLevel] >= 3)
{
if (sscanf(params, "ui", OtherPlayer, pMoney)) SendClientMessage(playerid, COLOR_RED, "Usage: \"/setcash <Player> <Amount>\"");
else
{
// Check if the otherplayer is online
if (IsPlayerConnected(OtherPlayer))
{
// Get the player-names
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(OtherPlayer, OtherName, sizeof(OtherName));

// Set the other player's money
APlayerData[OtherPlayer][PlayerMoney] = pMoney;
// Let the other player know that his money has been changed
format(Msg, 128, "{00FF00}Your cash has been set to {FFFF00}%i{00FF00} by {FFFF00}%s", pMoney, Name);
SendClientMessage(OtherPlayer, COLOR_WHITE, Msg);
// Let the player know he has set the money of the other player
format(Msg, 128, "{00FF00}You've set the cash of {FFFF00}%s{00FF00} to {FFFF00}%i", OtherName, pScore);
SendClientMessage(playerid, COLOR_WHITE, Msg);
// Save the other player's account
PlayerFile_Save(OtherPlayer);
}
else
SendClientMessage(playerid, COLOR_WHITE, "{FF0000}That player isn't online");
}
}
else
return 0;
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}

// Allows the player to setup a bank account, login to his bank account, or use his bank account after he logged in to his bank account
COMMAND:bank(playerid, params[])
{
Expand Down

0 comments on commit 80e8173

Please sign in to comment.