Home » Renegade Discussions » Mod Forum » SSGM Chat Hook
Re: SSGM Chat Hook [message #274710 is a reply to message #274709] |
Sat, 21 July 2007 11:40   |
Genesis2001
Messages: 1397 Registered: August 2006
Karma:
|
General (1 Star) |
|
|
bool IsNum(const char *sPtr) {
while (*sPtr != '\0') {
if (*sPtr < 48 || *sPtr > 57) return false;
++sPtr;
}
return true; // else, return a true value :)
}
class DonateChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
// Text[1] - Nick ~~ Text[2] - Amt
int Amt = (int)atoi(Text[2].c_str());
char Nick[20] = Commands->Get_ID(Text[1]);
GameObject *Donater = Get_GameObj(ID); //Get the gameobj of the player who's donating.
GameObject *Receiver = Get_GameObj_By_Player_Name(Text[1].c_str()); //Get the gameobj of the player being being donated to.
if (!IsNum(Text[2].c_str()) || Text[2].size() > 6) { //If it contains letters or is too big.
return;
}
// Check to see if the players are on the same team, if so, proceed to donate.
if (Commands->Get_Player_Type(*Donater) == Commands->Get_Player_Type(*Reciever)) { // Players are on the same teams
// Now, check to see if they player has enough money to donate :)
if (Commands->Get_Money(*Donater) > Amt) {
Commands->Give_Money(*Donater,Commands->Get_Money(GameObject *Donater)-Amt), true);
Commands->Give_Money(*Reciever,Commands->Get_Money(GameObject *Reciever)+Amt), true);
Console_Input(StrFormat("ppage %d You have donated %d credits to %d.",ID,Text[2],Text[1]).c_str());
Console_Input(StrFormat("ppage %d %d has donated you %d credits.",Nick,ID,Text[2]).c_str());
}
else {
Console_Input(StrFormat("ppage %d You do not have enough credits to donate to the specified player.",ID).c_str());
}
}
else {
Console_Input(StrFormat("ppage %d You need to be on the same team to donate to this person.",ID).c_str());
}
}
}
ChatCommandRegistrant<DonateChatCommand> DonateChatCommandReg("!donate;!d",CHATTYPE_TEAM,2,GAMEMODE_ALL);
Would the !donate/!d command be like that? 
Thanks, in advance, for the help!
-MathK1LL
[Updated on: Sat, 21 July 2007 11:44] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 24 04:01:02 MST 2025
Total time taken to generate the page: 0.02700 seconds
|