Still showing to have the enemies flag

perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: Still showing to have the enemies flag

Post by perrinoia »

Interesting... it refreshes the HUD every time you receive a message but doesn't parse the message?

We're gonna have to figure out where"$TeamData::TeamNum" is set.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: Still showing to have the enemies flag

Post by perrinoia »

This is the code in v1.40 that parses the messages to control the flag hud. It is also far more complicated than it needs to be.

Code: Select all

function Legacy::flagEvents( %msg ) {
	if (%msg == "You couldn't buy Flag")
		return "mute";
	
	%event = "";
	%id = 0;
	
	if( ( %idx = String::FindSubStr( %msg, " took the" ) ) != -1 ) {
		%name = String::GetSubStr(%msg, 0, %idx); 
		if ( %name == "You") 
			%name = Client::getName(getManagerId());
		%id = getClientByName( %name );
		%team = Client::GetTeam( %id ) ^ 1;
		%event = "FlagTaken";	
	} else if ( ( %idx = String::FindSubStr( %msg, " dropped the" ) ) != -1 ) {
		%name = String::GetSubStr(%msg, 0, %idx); 
		if ( %name == "You") 
			%name = Client::getName(getManagerId());
		%id = getClientByName( %name );
		%team = Client::GetTeam( %id ) ^ 1;
		%event = "FlagDropped";
	} else if ( ( %idx = String::FindSubStr(%msg, " returned the" ) ) != -1 ) {
		%name = String::GetSubStr(%msg, 0, %idx); 
		if ( %name == "You") 
			%name = Client::getName(getManagerId());
		%id = getClientByName( %name );
		%team = Client::GetTeam( %id );
		%event = "FlagReturned";
	} else if( ( %idx = String::FindSubStr( %msg, " captured the" ) ) != -1 ) {
		%name = String::GetSubStr(%msg, 0, %idx); 
		if ( %name == "You") 
			%name = Client::getName(getManagerId());
		else if ( %name == "Your Team" )
			return;
		%id = getClientByName( %name );
		%team =  Client::GetTeam( %id ) ^ 1;
		%event = "FlagCaptured";
	} else if ( (%idx = String::FindSubStr( %msg, " left the mission" ) ) != -1 ) {
		%name = String::GetSubStr(%msg, 0, %idx); 
		if ( %name == "You") 
			%name = Client::getName(getManagerId());
		%id = getClientByName( %name );
		%team = Client::GetTeam( %id ) ^ 1;
		%event = "FlagReturned";
	}

	if ( %id == 0 || %event == "" )
		return false;
	*"remote"~%event( 2048, %team, %id );
	return true;
}
This function is only called if the message contains the word "flag".
It searches the message for the following phrases: " took the", " dropped the", " returned the", " captured the", " left the mission".
If found, it truncates the message where the phrase was found, isolating what should be a player's name.
Then it gets the client Id using the player's name, and gets the team number using the client Id.
Last, it evaluates a different function for each of those phrases: "remoteFlagTaken", "remoteFlagDropped", "remoteFlagReturned", "remoteFlagCaptured", or "remoteFlagReturned"

Each of these functions update the flag hud and some auto waypoint if configured to do so.

Despite the fact that this code is extra complicated, it works most of the time. The only reason I can think of for it to fail is if the server was modified to change the flag related announcements. And that's the case with the BR server, which announces the armor description of the flag carrier.

While it's nice to know which armor the flag carrier is wearing, this feature has probably broken every flag hud script in existence.

I'd have to write a new one to compensate, and while I'd like to make it far less complicated than the two convoluted examples posted here, I fear that I'll have to make them somewhat complicated for compatibility with the two configs mentioned.

Unfortunately, this takes me a bit out of my zone of expertise. I know server side scripting, AKA darkstar script. I attempted to teach myself HUD coding awhile back, but wasn't very successful. The GUI interface seemed convoluted to me.

This is not something I can fix in a matter of seconds, although, I originally thought it was.
Image
User avatar
KILROY
Posts: 1315
Joined: Sat Apr 05, 2014 8:59 pm
Location: Texas

Re: Still showing to have the enemies flag

Post by KILROY »

K, that helps explain a lot more. I'm still running 1.30 that was created for Window's Vista, and my best guess it's conflicting with the server scripting.

Yeah, looks like it's going to take time to sort this out. I can live with it, it's not conflicting with player game play, just mine, or finally switch to 1.41, which basically I'll have to get used to the way it looks and the way the interface works. Which will basically make me a newbie again.

I just logged on again using it, and noticed my character is constantly hopping also. If I decide to use it, I'll have to correct this.

Appreciate your time and help though. Thanks!
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: Still showing to have the enemies flag

Post by perrinoia »

I've had that happen before. Had to do with holding the spacebar while spawning I think... Inverted the ski script somehow.

Switching to 1.40 might not solve your problem as it's flag hud probably also fails due to the new server flag notifications.

We can keep following the rabbit hole in your config if you want... Maybe send me a copy if you want me to dig into it myself rather than walking you through it. It's up to you.
Image
Post Reply