Home » Renegade Discussions » Mod Forum » !tdonate
() 2 Votes
Re: !tdonate [message #339928 is a reply to message #339723] |
Wed, 09 July 2008 08:12 |
|
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
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
|
|
|
|
|
!tdonate
|
|
|
Re: !tdonate
By: bmruze on Tue, 08 July 2008 11:19
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: cAmpa on Tue, 08 July 2008 14:28
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Wed, 09 July 2008 01:22
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Wed, 09 July 2008 08:12
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Wed, 09 July 2008 09:54
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Wed, 09 July 2008 14:24
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Thu, 10 July 2008 02:10
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: ExEric3 on Wed, 09 July 2008 23:22
|
|
|
Re: !tdonate
By: ExEric3 on Sat, 12 July 2008 18:20
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: reborn on Mon, 14 July 2008 10:48
|
|
|
Re: !tdonate
By: ExEric3 on Mon, 14 July 2008 22:17
|
|
|
Re: !tdonate
By: raven on Mon, 14 July 2008 23:06
|
|
|
Re: !tdonate
|
|
|
Re: !tdonate
By: raven on Mon, 14 July 2008 23:47
|
|
|
Re: !tdonate
By: ExEric3 on Sat, 19 July 2008 05:19
|
|
|
Re: !tdonate
By: raven on Sat, 19 July 2008 10:02
|
Goto Forum:
Current Time: Thu Dec 26 14:05:21 MST 2024
Total time taken to generate the page: 0.01111 seconds
|