scripting question

Post Reply
User avatar
item9
Posts: 184
Joined: Tue Nov 05, 2013 9:50 pm

scripting question

Post by item9 »

Code: Select all

Event::Attach(eventFlagTaken, FlagSound::FlagTaken);
Event::Attach(eventFlagDropped, FlagSound::FlagDropped);
Event::Attach(eventFlagReturned, FlagSound::FlagReturned);
Event::Attach(eventFlagCaptured, FlagSound::FlagCaptured);

function FlagSound::FlagTaken(%team, %client)
{
	if(%team == Team::Enemy() && %client != getManagerId())
		sound("sound.wav");
	else if(%team == Team::Friendly())
		sound("sound.wav");
}

function FlagSound::FlagDropped(%team, %client)
{
	if(%team == Team::Enemy() && %client != getManagerId())
		sound("sound.wav");
	else if(%team == Team::Friendly())
		sound("sound.wav");
}

function FlagSound::FlagReturned(%team, %client)
{
	if(%team == Team::Friendly() && %client != getManagerId())
		sound("sound.wav");
	else if(%team == Team::Enemy())
		sound("sound.wav");
}

function FlagSound::FlagCaptured(%team, %client)
{
	if(%team == Team::Enemy()  && %client != getManagerId())
		sound("sound.wav");
	else if(%team == Team::Friendly())
		sound("sound.wav");
}
I want to make it more team specific. I'm adding the halo blue flag dropped red flag returned announcer sounds.

I dont really care or want to know who dropped what, just what team did it.

for example diamondsword flag dropped (blue flag dropped) blood eagle flag returned (red flag returned).

I'll try messing with it tonight see if i can get it to work this way.
BlackSheep
Posts: 174
Joined: Tue Jul 02, 2013 11:27 am

Re: scripting question

Post by BlackSheep »

It is easier if you don't use presto (I fucking hate presto, bias)


Anyway, take a look at this function. These are the droids that you are looking for.
This function gets called on your end when you receive a message from the server.

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client) //if its a message from a player
      $lastClientMessage = %client;

   // filter other messages here
   return true;
}
You have to search for the messages, and then call what ever you want to happen upon receiving that message. This defines what you are searching for to the game, and makes it respond in the way that you tell it to.

Example:

Code: Select all

function onClientMessage(%client, %msg)
{
   if(%client)
      $lastClientMessage = %client;
   else
   {
	if(String::findSubStr(%msg,"Your team has the") != "-1" && String::findSubStr(%msg,"flag!") !="-1")
	{ 
		// Enemy Flag Away

		return; // this is called to end the function
	}

	if(%msg == "Your teams flag has been taken.")
	{ 
		// Friendly Flag Away

		return; // this is called to end the function
	}

	if(%msg == "Your teams flag was returned to base." || %msg == "Your teams flag was captured.")
	{ 
		// Friendly Flag Home

		return; // this is called to end the function
	}

	

   }

   // filter messages here
   return true;
}
This is how you define what you are searching for. I did not finish this for you, you will have to filter the rest of the messages. (Like when the flag gets dropped, etc.) If you need me to elaborate just let me know. Its pretty easy once you get the hang of it.

I would also recommend that you start small. Try to filter one message and see if it responds in the way that you intended, then move on to the next one.
Image
User avatar
item9
Posts: 184
Joined: Tue Nov 05, 2013 9:50 pm

Re: scripting question

Post by item9 »

could I just do this? I really like the way this script works already. Since I want flag drop sounds.

function FlagSound::FlagTaken(%client, %team)

else if(%team == Team::Team0

else if(%team == Team::Team1
Post Reply