Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DonateChatCommand : public ChatCommandClass {
- void Triggered(int ID,const TokenClass &Text,int ChatType) {
- GameObject *object = Get_GameObj(ID);
- GameObject *obj;
- unsigned int seconds = The_Game()->GameDuration_Seconds;
- if ((seconds / 60) < Settings->DonationTime)
- {
- Console_Input(StrFormat("ppage %d Donations are only allowed after %d minutes into the game.",ID,Settings->DonationTime).c_str());
- return;
- }
- if (!Text[1].empty() && !Text[2].empty()) {
- std::string name = Text[1].c_str();
- int money = (int)atof(Text[2].c_str());
- float clientsmoney = Commands->Get_Money(object);
- int amount = 0;
- amount = Get_Part_Names(name.c_str());
- if (amount == 1) {
- obj = Get_Part_Name(name.c_str());
- if (Commands->Get_Player_Type(obj) == Commands->Get_Player_Type(object)) {
- name = Get_Player_Name(obj);
- if (ID != Get_Player_ID(obj)) {
- if (money > 0) {
- if (clientsmoney >= money) {
- Commands->Give_Money(obj,(float)money,false);
- Commands->Give_Money(object,(float)-money,false);
- Console_Input(StrFormat("ppage %d You just donated %i credits to player %s.",ID,money,name.c_str()).c_str());
- Console_Input(StrFormat("ppage %d %s has donated you %i credits.",Get_Player_ID(obj),Get_Player_Name_By_ID(ID),money).c_str());
- }
- else {
- Console_Input(StrFormat("ppage %d Insufficient amount of credits.",ID).c_str());
- }
- }
- else {
- Console_Input(StrFormat("ppage %d You can't donate a negative amount.",ID,money).c_str());
- }
- }
- else {
- Console_Input(StrFormat("ppage %d You can't donate to yourself.",ID,money).c_str());
- }
- }
- else {
- Console_Input(StrFormat("ppage %d %s isn't on your team.",ID,name.c_str()).c_str());
- }
- }
- else if (amount == 0) {
- Console_Input(StrFormat("ppage %d Player not found.",ID).c_str());
- return;
- }
- else if (amount > 1) {
- obj = Get_GameObj_By_Player_Name(name.c_str());
- if (!obj) {
- Console_Input(StrFormat("ppage %d There are %i players with that substring, please make the name more unique.",ID,amount).c_str());
- return;
- }
- }
- }
- }
- };
- ChatCommandRegistrant<DonateChatCommand> DonateChatCommandReg("!donate;!d",CHATTYPE_ALL,1,GAMEMODE_ALL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement