Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » !tdonate  () 2 Votes
Re: !tdonate [message #339928 is a reply to message #339723] Wed, 09 July 2008 08:12 Go to previous messageGo to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
Try this out then, I havn't tested it, so if you could and report any bugs that would be nice, as I plan to use it myself too.

class tdonateChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
GameObject *obj = Get_GameObj(ID);
if (!Text[1].empty()) {
	float money = atof(Text[1].c_str());

/*const char* s_money = Text[1].c_str();
sscanf(s_money,"%f",&money);
if (sscanf(s_money,"%f",&money) != 1)
{
	Console_Output("There was blood, everywhere. Nobody could tell what did this to them, but there was one thing for certain. Something had gone horribly wrong.");
}
*/

float clientsmoney = Commands->Get_Money(obj);

if(clientsmoney >= money){
int Team = Get_Team(ID);
int count = Get_Team_Player_Count(Team);
if(count > 1){
int amounttodonate = money/(count - 1);
Commands->Give_Money(obj,(money * -1),false);
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x){
GameObject *o = (GameObject *)x->NodeData;
if (o && Commands->Is_A_Star(o) && (Commands->Get_Player_Type(o) == Team)){
	if(Get_Player_ID(o) != ID){
Commands->Give_Money(o,amounttodonate,false);
Console_Input(StrFormat("ppage %d You have just been donated $%i by player %s.",Get_Player_ID(o),amounttodonate,Get_Player_Name(obj)).c_str());
	}
}
x = x->NodeNext;
}
}
else{
	Console_Input(StrFormat("ppage %d Dude, you're the only player on your team :-S",ID).c_str());
}
}
else{
Console_Input(StrFormat("ppage %d You do not have $%i, please lower your donation.",ID,money).c_str());
}
}
}
};
ChatCommandRegistrant<tdonateChatCommand> tdonateChatCommandReg("!tdonate",CHATTYPE_ALL,1,GAMEMODE_ALL);


There's probably some casts I havn't done that I should of, but I'm a lazy bitch and keep my warning levels down all the time.
You're probably able to make it say some weird numbers if you type !tdonate 34098563406854968409680954870986504, but it shouldn't actually do any harm.

Feel free anyone to pop there two cents in and make it better Smile



Oh, I also found a flaw with int Get_Team_Player_Count(int Team), so you'll need to change that function to read like this:

int Get_Team_Player_Count(int Team)
{
	int Total = 0;
	GenericSLNode *x = BaseGameObjList->HeadNode;
	while (x)
	{
		GameObject *o = (GameObject *)x->NodeData;
		if (o && Commands->Is_A_Star(o))
		{
			if (Get_Team(Get_Player_ID(o)) == Team)
			{
			Total++;
		}
		}
		x = x->NodeNext;
	}
	return Total;
}



[Updated on: Wed, 09 July 2008 08:16]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Looking for Bot maps
Next Topic: Bot Waypaths
Goto Forum:
  


Current Time: Thu Dec 26 14:05:21 MST 2024

Total time taken to generate the page: 0.01111 seconds