[Solved]NexgenMBMH2v112UK

Discussions about Coding and Scripting
Post Reply
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

[Solved]NexgenMBMH2v112UK

Post by Letylove49 »

hi

i have almost done my first plugin but that don't work like expected.

the multikill message are displayed twice like on this sceenshot :
Shot00783.png


How i can fixe that ?

the code come from MH2Gold for the function that i show to you.

Code: Select all

 function CheckBroadCast(Pawn Killer,int num)
{
   if(Killer.bIsPlayer && !Killer.PlayerReplicationInfo.bIsABot)
      BroadCastMessage(Killer.PlayerReplicationInfo.PlayerName@GetText(num));
}  

2nd prioblem with Holyshit message displayed only 1 time is now solved:

i have put a if functon in the code for that.

Code: Select all


/***************************************************************************************************
 *
 *  $DESCRIPTION  Creates the string for this localized message.
 *  $PARAM        switch          Optional message switch.
 *  $PARAM        pri1            Replication info of the first player involved with the message.
 *  $PARAM        pri1            Replication info of the second player involved with the message.
 *  $PARAM        optionalObject  Extra object related to the message.
 *  $RETURN       The message string.
 *
 **************************************************************************************************/
static function string getString(optional int switch, optional PlayerReplicationInfo pri1,
                                 optional PlayerReplicationInfo pri2, optional Object optionalObject) {
	local string msg;
	
	if (pri1 != none) {
		if (1 <= switch) {
			if (switch == 50) {
				msg = class'NexgenUtil'.static.format(default.cheaterMessage, pri1.playerName);;
			} else if (switch >= 40) {
				msg = class'NexgenUtil'.static.format(default.StillgoingMessage, pri1.playerName);;
		     } else if (switch > arrayCount(default.multiKillMessage)) {
				msg = class'NexgenUtil'.static.format(default.multiKillMessage[arrayCount(default.multiKillMessage) - 1], pri1.playerName);
			} else {
				msg = class'NexgenUtil'.static.format(default.multiKillMessage[switch - 1], pri1.playerName);
			}
		}
	}
	
	return msg;
}




/***************************************************************************************************
 *
 *  $DESCRIPTION  Default properties block.
 *
 **************************************************************************************************/

defaultproperties
{   

multiKillMessage(0)="<C03>%1  has Double Kill!"
multiKillMessage(1)="<C09>%1  has Multi Kill!"
multiKillMessage(2)="<C12>%1  has Mega Kill!"
multiKillMessage(3)="<C00>%1  has ULTRA KILL!!"
multiKillMessage(4)="<C10>%1  has M O N S T E R  K I L L !!!"
multiKillMessage(5)="<C13>%1  has L U D I C R O U S  K I L L !!!!"
multiKillMessage(6)="<C06>%1  has H  O  L  Y   S  H  I  T !!!!!!!"
StillgoingMessage="<C14>%1  is still going.... !!!!!!!!!!!"
cheaterMessage="<C15>  Someone better be checking %1 for cheats!"
}

 
Last edited by Letylove49 on Sat Apr 29, 2023 11:08 pm, edited 1 time in total.
Image



Image
Letylove49 aka Alicia
loveut99
Novice
Posts: 6
Joined: Mon Jan 23, 2023 1:27 am

Re: NexgenMBMH2v112UK

Post by loveut99 »

What does your mutatorTeamMessage function look like?

Do you have something like this near the top?

Code: Select all

if (tournamentPlayer(sender) != none && (sender == receiver))
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: NexgenMBMH2v112UK

Post by Letylove49 »

loveut99 wrote: Mon Apr 10, 2023 2:22 am What does your mutatorTeamMessage function look like?

Do you have something like this near the top?

Code: Select all

if (tournamentPlayer(sender) != none && (sender == receiver))
here the function MutatorteamMessage in Nexgen :

Code: Select all

 function bool mutatorTeamMessage(Actor sender, Pawn receiver, PlayerReplicationInfo pri,
                                 coerce string s, name type, optional bool bBeep) {
	local bool bIsCommand;
	local NexgenClient client;
	local byte logType;
	local int index;
	local bool bSend;
	
	// Check for commands.
	if (sender != none && sender.isA('PlayerPawn') && sender == receiver &&
	    (type == 'Say' || type == 'TeamSay')) {
		bIsCommand = handleMsgCommand(PlayerPawn(sender), s);
	}
	
	// Check if player is muted.
	client = getClient(sender);
	if (client != none && client.isMuted()) {
		// Yeah he/she is, block the message.
		if (sender == receiver) {
			if (bIsCommand) {
				return true;
			} else {
				client.showMsg(lng.mutedReminderMsg);
			}
		}
		return false;
	}
	
	// Log message.
	if (sender == none && receiver != none && receiver.nextPawn == none) {
		nscLog(s, LT_Message);
	} else if (sender != none && sender == receiver && receiver.playerReplicationInfo != none) {
		if (type == 'Say') {
			logType = LT_Say;
		} else if (type == 'TeamSay') {
			logType = LT_TeamSay;
		} else {
			logType = LT_Message;
		}
		nscLog(receiver.playerReplicationInfo.playerName $ ": " $ s, logType);
	}
	
	// Notify plugins.
	while (index < arrayCount(plugins) && plugins[index] != none) {
		bSend = plugins[index].mutatorTeamMessage(sender, receiver, pri, s, type, bBeep);
		if (!bSend) return false;
		index++;
	}
	
	// Allow other message mutators to do their job.
    if (nextMessageMutator != none) {
        return nextMessageMutator.mutatorTeamMessage(sender, receiver, pri, s, type, bBeep);
    } else {
        return true;
    }	
}
 
i have this on function scorkill in NexgenMBMH2 plugin

Code: Select all

 /***************************************************************************************************
 *
 *  $DESCRIPTION  Called when a player was killed by another player.
 *  $PARAM        killer  The pawn that killed the other pawn. Might be none.
 *  $PARAM        victim  Pawn that was the victim.
 *
 **************************************************************************************************/
function scoreKill(Pawn killer, Pawn victim) {
	local NexgenClient client;
	local NXPMBClient xClient;
	
	if (killer != none && victim != none && killer != victim) {
		// Get extended client controller.
		client = control.getClient(killer);
		if (client != none) {
			xClient = NXPMBClient(client.getController(class'NXPMBClient'.default.ctrlID));
		}
		
		if (xClient != none) {
			// Check for double, multi, mega, ultra, monster, Ludicrous kills, Holyshit, Is still going.....
			if (level.timeSeconds - xClient.lastKillTime < maxMultiScoreInterval) {
				xClient.multiLevel++;
				level.game.broadcastLocalizedMessage(class'NXPMultiKillMessage', xClient.multiLevel, killer.playerReplicationInfo);
			} else {
				xClient.multiLevel = 0;
			}
			
			// Update last kill time.
			xClient.lastKillTime = level.timeSeconds;
		}
		
	}
}
Image



Image
Letylove49 aka Alicia
loveut99
Novice
Posts: 6
Joined: Mon Jan 23, 2023 1:27 am

Re: NexgenMBMH2v112UK

Post by loveut99 »

My original message was misleading, the mutatorTeamMessage function is not involved here. I'm not sure this message will be any more helpful, I have a blindness to any script that I'm not working on myself.

So the scoreKill function in your plugin calls level.game.broadcastLocalizedMessage. This is defined in Actor.uc, and in turn, this calls ReceiveLocalizedMessage() for every player in the game. ReceiveLocalizedMessage() takes the message class passed to it (i.e., NXPMultiKillMessage) and calls ClientReceive(). This then calls LocalizedMessage() on the player's HUD, which places the message into a queue, which eventually gets draw on the screen in the HUD's postRender() function. I'm just writing this out so that I can follow the sequence of events.

I'm not clear about where you're calling the CheckBroadCast() function that you mentioned in your original post. I had a look at the MH2Gold scipt, and that function is just a wrapper around BroadcastMessage(), which ultimately calls the Message() function in the HUD class, and essentially does the same thing as LocalizedMessage(), placing the message in a queue to be printed to the screen in postRender().

In your screenshot you can see that one of the two copies of the "Double kill" message is colorized. I'm not sure where Nexgen is doing this. Do you have a MutatorBroadcastLocalizedMessage function in your plugin?

But anyway, it looks as though you don't need to make a call to CheckBroadCast() since this appears to be doing the same job as broadcastLocalizedMessage().
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: NexgenMBMH2v112UK

Post by Letylove49 »

Maybe I will have to tell you what I want to do with my plugin: it must replace the messages in the hud by those in color in my plugin. I use a personal version of MH2 in which the multikill message in the center are colorized in different colors as with the smartctf or smartsb.   
Auto merged new post submitted 18 hours 22 minutes later
loveut99 wrote: Tue Apr 11, 2023 2:53 am My original message was misleading, the mutatorTeamMessage function is not involved here. I'm not sure this message will be any more helpful, I have a blindness to any script that I'm not working on myself.

So the scoreKill function in your plugin calls level.game.broadcastLocalizedMessage. This is defined in Actor.uc, and in turn, this calls ReceiveLocalizedMessage() for every player in the game. ReceiveLocalizedMessage() takes the message class passed to it (i.e., NXPMultiKillMessage) and calls ClientReceive(). This then calls LocalizedMessage() on the player's HUD, which places the message into a queue, which eventually gets draw on the screen in the HUD's postRender() function. I'm just writing this out so that I can follow the sequence of events.

I'm not clear about where you're calling the CheckBroadCast() function that you mentioned in your original post. I had a look at the MH2Gold scipt, and that function is just a wrapper around BroadcastMessage(), which ultimately calls the Message() function in the HUD class, and essentially does the same thing as LocalizedMessage(), placing the message in a queue to be printed to the screen in postRender().

In your screenshot you can see that one of the two copies of the "Double kill" message is colorized. I'm not sure where Nexgen is doing this. Do you have a MutatorBroadcastLocalizedMessage function in your plugin?

But anyway, it looks as though you don't need to make a call to CheckBroadCast() since this appears to be doing the same job as broadcastLocalizedMessage().
the function MutatorbrodcastLocalizedMessge is in class NexgenController on Nexgen not in my plugin :

Code: Select all

 /***************************************************************************************************
 *
 *  $DESCRIPTION  Hooked into the message mutator chain so messages can be logged.
 *  $PARAM        sender          The actor that has send the message.
 *  $PARAM        receiver        Pawn receiving the message.
 *  $PARAM        message         The class of the localized message that is to be send.
 *  $PARAM        switch          Optional message switch argument.
 *  $PARAM        relatedPRI_1    PlayerReplicationInfo of a player that is related to the message.
 *  $PARAM        relatedPRI_2    PlayerReplicationInfo of a player that is related to the message.
 *  $PARAM        optionalObject  Optional object used to construct the message string.
 *  $REQUIRE      message != none
 *  $RETURN       True if the message should be send, false if it should be suppressed.
 *  $OVERRIDE
 *
 **************************************************************************************************/
function bool mutatorBroadcastLocalizedMessage(Actor sender, Pawn receiver,
                                               out class<LocalMessage> message,
                                               out optional int switch,
                                               out optional PlayerReplicationInfo relatedPRI_1,
                                               out optional PlayerReplicationInfo relatedPRI_2,
                                               out optional Object optionalObject) {
	local PlayerReplicationInfo senderPRI;
	local string msg;
	local int index;
	local bool bSend;
	
	// Get sender player replication info.
	if (sender != none && sender.isA('Pawn')) {
		senderPRI = Pawn(sender).playerReplicationInfo;
	}
	
	// Prevent duplicate messages in the log.
	if (receiver != none && receiver.nextPawn == none && message != none) {
		
		// Construct message.
		msg = message.static.getString(switch, relatedPRI_1, relatedPRI_2, optionalObject);
		
		// Log the message.
		if (senderPRI == none) {
			nscLog(msg, LT_Message);
		} else {
			nscLog(senderPRI.playerName $ ": " $ msg, LT_Message);
		}
	}
	
	// Notify plugins.
	while (index < arrayCount(plugins) && plugins[index] != none) {
		bSend = plugins[index].mutatorBroadcastLocalizedMessage(sender, receiver, message, switch,
		                                                        relatedPRI_1, relatedPRI_2, optionalObject);
		if (!bSend) return false;
		index++;
	}
	
	// Allow other message mutators to do their job.
	if (nextMessageMutator != none) {
		return nextMessageMutator.mutatorBroadcastLocalizedMessage(sender, receiver, message,
		                                                           switch, relatedPRI_1,
		                                                           relatedPRI_2, optionalObject);
	} else {
		return true;
	}
}
the function MutatorbrodcastLocalizedMessge is in class Nexgenplugin on Nexgen not in my plugin :

Code: Select all

 /***************************************************************************************************
 *
 *  $DESCRIPTION  Called to check if the given localized message should be send to the specified
 *                receiver.
 *  $PARAM        sender          The actor that has send the message.
 *  $PARAM        receiver        Pawn receiving the message.
 *  $PARAM        message         The class of the localized message that is to be send.
 *  $PARAM        switch          Optional message switch argument.
 *  $PARAM        relatedPRI_1    PlayerReplicationInfo of a player that is related to the message.
 *  $PARAM        relatedPRI_2    PlayerReplicationInfo of a player that is related to the message.
 *  $PARAM        optionalObject  Optional object used to construct the message string.
 *  $REQUIRE      message != none
 *  $RETURN       True if the message should be send, false if it should be suppressed.
 *
 **************************************************************************************************/
function bool mutatorBroadcastLocalizedMessage(Actor sender, Pawn receiver,
                                               out class<LocalMessage> message,
                                               out optional int switch,
                                               out optional PlayerReplicationInfo relatedPRI_1,
                                               out optional PlayerReplicationInfo relatedPRI_2,
                                               out optional Object optionalObject) {
	// To implement in subclass.
	return true;
} 
Image



Image
Letylove49 aka Alicia
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: NexgenMBMH2v112UK

Post by Letylove49 »

i have add this in the classe MH2Base ( als this mod is open source)

function CheckBroadCast(Pawn Killer,int num)
{
if(bBrodcastMultikill)
if(Killer.bIsPlayer && !Killer.PlayerReplicationInfo.bIsABot)
BroadCastMessage(Killer.PlayerReplicationInfo.PlayerName@GetText(num));
}

now if this is on False i don0't have doppel message anymore.
Image



Image
Letylove49 aka Alicia
Post Reply