[Script] zbl_Building_Attack_Announce [message #371667] |
Wed, 11 February 2009 17:11 |
Genesis2001
Messages: 1397 Registered: August 2006
Karma: 0
|
General (1 Star) |
|
|
.h
class zbl_Building_Attack_Announce : public ScriptImpClass
{
bool announced;
int team;
public:
void Created(GameObject *o);
void Damaged(GameObject *o, GameObject *d, float damage);
void Timer_Expired(GameObject *o, int num);
};
.cpp
void zbl_Building_Attack_Announce::Created(GameObject *o)
{
announced = 0;
team = Get_Int_Parameter("Object_Team");
}
void zbl_Building_Attack_Announce::Damaged(GameObject *o, GameObject *d, float damage)
{
if (!announced)
{
unsigned int r = 255, g = 255, b = 255;
char Announce[256];
sprintf(Announce, "Warning - The %s is under attack!", Get_Parameter("Translated"));
Send_Message_Team(team, r, g, b, Announce);
Create_2D_Sound_Team(Get_Parameter("Sound"), team);
announced = 1;
Commands->Start_Timer(o, this, Get_Float_Parameter("Interval"), 123);
}
}
void zbl_Building_Attack_Announce::Timer_Expired(GameObject *o, int num)
{
if (num == 123)
{
if (announced)
{
announced = 0;
}
}
}
Toggle SpoilerScriptRegistrant<zbl_Building_Attack_Announce> zbl_Building_Attack_Announce_Registrant("zbl_Building_Attack_Announce", "Object_Team=0:int,Interval=30000.00:float,Sound=amb_airraid.wav:string", "Translated=GDI Weapons Factory:string");
Parameters:
Object_Team:int - The team the object belongs to.
Interval:float - The interval at which to announce "<building> is under attack!"
Sound:string - The sound file to play for the team, e.g. "Warning - Nod Airstrip Under Attack!" etc
Translated:string - The Translated Screenname of the object (what you want the object to be called)
The "Translated" parameter is there because I didn't want to look for a translation function nor include one for getting the preset's screenname. If another coder finds one, you're more than welcome to replace this parameter with that function call.
[Updated on: Thu, 12 February 2009 10:29] Report message to a moderator
|
|
|
|
|
Re: [Script] zbl_Building_Attack_Announce [message #371781 is a reply to message #371755] |
Thu, 12 February 2009 09:55 |
Genesis2001
Messages: 1397 Registered: August 2006
Karma: 0
|
General (1 Star) |
|
|
reborn wrote on Thu, 12 February 2009 06:18 | Pretty cool man, nice.
Just a couple of suggestions that might be nice for people...
Make the variables for r,g,b input parameters so people can send different colored messages. This is helpful for mods where the team colours are different to Red and Yellow, White messages are boring.
Also, allow the user to choose between a team message and a global message, and a team sound, or a global sound.
|
All I did was clone what Renegade does already, but what Renegade does for only buildings, this works for anything.
EDIT: Reborn, you can always just use "Get_Team_Color()" :/
unsigned int R, G, B; //might need to be pointers, but unsure - lol
Get_Team_Color(0, &R, &G, &B);
[Updated on: Thu, 12 February 2009 10:30] Report message to a moderator
|
|
|
Re: [Script] zbl_Building_Attack_Announce [message #372340 is a reply to message #371781] |
Mon, 16 February 2009 06:03 |
|
rrutk
Messages: 617 Registered: June 2007
Karma: 0
|
Colonel |
|
|
yes, and please, someone fix those bugs with the message_send_custom_xx scripts on custom! (they show only the numeral message and color doesnt work too)
scripts 4.0 should include the bugfixed versions!
We should have a simple WORKING script: Display_Message_Custom_Team_Sound (to display a textmessage for seperated NOD/GDI teams on custom and play a sound).
[Updated on: Mon, 16 February 2009 06:07] Report message to a moderator
|
|
|
Re: [Script] zbl_Building_Attack_Announce [message #372398 is a reply to message #372340] |
Mon, 16 February 2009 15:46 |
Genesis2001
Messages: 1397 Registered: August 2006
Karma: 0
|
General (1 Star) |
|
|
rrutk wrote on Mon, 16 February 2009 06:03 | We should have a simple WORKING script: Display_Message_Custom_Team_Sound (to display a textmessage for seperated NOD/GDI teams on custom and play a sound).
|
Just FYI...
JFW_Message_Send_Custom
Display_Message - the message to display
Red/Blue/Green - RGB colour codes to send a coloured message
Sound - Sound to play
Message - Custom event to trigger on
Delete - Whether to delete itself after it's been sent. (defaults to false(0) I think...)
|
|
|
Re: [Script] zbl_Building_Attack_Announce [message #372399 is a reply to message #372398] |
Mon, 16 February 2009 15:53 |
|
rrutk
Messages: 617 Registered: June 2007
Karma: 0
|
Colonel |
|
|
Zack wrote on Mon, 16 February 2009 17:46 |
rrutk wrote on Mon, 16 February 2009 06:03 | We should have a simple WORKING script: Display_Message_Custom_Team_Sound (to display a textmessage for seperated NOD/GDI teams on custom and play a sound).
|
Just FYI...
JFW_Message_Send_Custom
Display_Message - the message to display
Red/Blue/Green - RGB colour codes to send a coloured message
Sound - Sound to play
Message - Custom event to trigger on
Delete - Whether to delete itself after it's been sent. (defaults to false(0) I think...)
|
this script is bugged. like written. try to use it.
[Updated on: Mon, 16 February 2009 15:54] Report message to a moderator
|
|
|
|
Re: [Script] zbl_Building_Attack_Announce [message #372727 is a reply to message #372399] |
Fri, 20 February 2009 08:16 |
Genesis2001
Messages: 1397 Registered: August 2006
Karma: 0
|
General (1 Star) |
|
|
rrutk wrote on Mon, 16 February 2009 15:53 |
Zack wrote on Mon, 16 February 2009 17:46 |
rrutk wrote on Mon, 16 February 2009 06:03 | We should have a simple WORKING script: Display_Message_Custom_Team_Sound (to display a textmessage for seperated NOD/GDI teams on custom and play a sound).
|
Just FYI...
JFW_Message_Send_Custom
Display_Message - the message to display
Red/Blue/Green - RGB colour codes to send a coloured message
Sound - Sound to play
Message - Custom event to trigger on
Delete - Whether to delete itself after it's been sent. (defaults to false(0) I think...)
|
this script is bugged. like written. try to use it.
|
I have used it. Wilost0rm has used. He recommended it to me. It's used several times on his server-side mod for C&C_GDI_Survival. It must be how you're using it. Unless Wilo can confirm your statement..
|
|
|