Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. class DonateChatCommand : public ChatCommandClass {
  2.     void Triggered(int ID,const TokenClass &Text,int ChatType) {
  3.         GameObject *object = Get_GameObj(ID);
  4.         GameObject *obj;
  5.         unsigned int seconds = The_Game()->GameDuration_Seconds;
  6.         if ((seconds / 60) < Settings->DonationTime)
  7.         {
  8.             Console_Input(StrFormat("ppage %d Donations are only allowed after %d minutes into the game.",ID,Settings->DonationTime).c_str());
  9.             return;
  10.         }
  11.         if (!Text[1].empty() && !Text[2].empty()) {
  12.             std::string name = Text[1].c_str();
  13.             int money = (int)atof(Text[2].c_str());
  14.             float clientsmoney = Commands->Get_Money(object);
  15.             int amount = 0;
  16.             amount = Get_Part_Names(name.c_str());
  17.             if (amount == 1) {
  18.                 obj = Get_Part_Name(name.c_str());
  19.                 if (Commands->Get_Player_Type(obj) == Commands->Get_Player_Type(object)) {
  20.                     name = Get_Player_Name(obj);
  21.                     if (ID != Get_Player_ID(obj)) {
  22.                         if (money > 0) {
  23.                             if (clientsmoney >= money) {
  24.                                 Commands->Give_Money(obj,(float)money,false);
  25.                                 Commands->Give_Money(object,(float)-money,false);
  26.                                 Console_Input(StrFormat("ppage %d You just donated %i credits to player %s.",ID,money,name.c_str()).c_str());
  27.                                 Console_Input(StrFormat("ppage %d %s has donated you %i credits.",Get_Player_ID(obj),Get_Player_Name_By_ID(ID),money).c_str());
  28.                             }
  29.                             else {
  30.                                 Console_Input(StrFormat("ppage %d Insufficient amount of credits.",ID).c_str());
  31.                             }
  32.                         }
  33.                         else {
  34.                             Console_Input(StrFormat("ppage %d You can't donate a negative amount.",ID,money).c_str());
  35.                         }
  36.                     }
  37.                     else {
  38.                         Console_Input(StrFormat("ppage %d You can't donate to yourself.",ID,money).c_str());
  39.                     }
  40.                 }
  41.                 else {
  42.                     Console_Input(StrFormat("ppage %d %s isn't on your team.",ID,name.c_str()).c_str());
  43.                 }
  44.             }
  45.             else if (amount == 0) {
  46.                 Console_Input(StrFormat("ppage %d Player not found.",ID).c_str());
  47.                 return;
  48.             }
  49.             else if (amount > 1) {
  50.                 obj = Get_GameObj_By_Player_Name(name.c_str());
  51.                 if (!obj) {
  52.                     Console_Input(StrFormat("ppage %d There are %i players with that substring, please make the name more unique.",ID,amount).c_str());
  53.                     return;
  54.                 }
  55.             }
  56.         }
  57.     }
  58. };
  59. ChatCommandRegistrant<DonateChatCommand> DonateChatCommandReg("!donate;!d",CHATTYPE_ALL,1,GAMEMODE_ALL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement