[solved] Need Help for server adds on Nexgen

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

[solved] Need Help for server adds on Nexgen

Post by Letylove49 »

Code: Select all

 //
/***************************************************************************************************
 *
 *  $DESCRIPTION  This is our home cooked timer, which ticks at a frequency of 1 Hz and is
 *                independent of the game speed.
 *
 **************************************************************************************************/
function virtualTimer() {
	local int index;
	local NexgenClient client;
	
	// Update countdown.
	if (gInf.countDown > 0) {
		gInf.countDown--;
	}
	
	// Check if the game if ready to start
	if (gInf.countDown == 0 && gInf.gameState == gInf.GS_Waiting && sConf.enableNexgenStartControl) {
		gInf.gameState = gInf.GS_Ready;
		for (client = clientList; client != none; client = client.nextClient) {
			showGameReadyToLaunchMessage(client);
		}
	}
	if (gInf.countDown == 0 && gInf.gameState == gInf.GS_Starting) {
		startGame();
	}
	
	// Automatically disable an inactive match?
	if (sConf.matchModeActivated && sConf.autoDisableMatchTime > 0 && clientList == none &&
	    timeSeconds - lastPlayerLeftTime > secondsPerMinute * sConf.autoDisableMatchTime) {
		// Yes.
		sConf.matchModeActivated = false;
		sConf.saveConfig();
		signalConfigUpdate(sConf.CT_MatchSettings);
		if (sConf.matchAutoLockTeams) {
			gInf.bTeamsLocked = false;
		}
	}
	
	// Reboot server?
	if (gInf.rebootCountDown > 0) {
		gInf.rebootCountDown--;
		if (gInf.rebootCountDown == 0) {
			sConf.isAdminReboot = true;
			sConf.saveConfig();
			consoleCommand(rebootCommand);
		}
	}
	
	    // display an advert
    if (sConf.numAdverts > 0 && level.TimeSeconds >= sConf.nextAdvertTime) {

        if (sConf.bRandomAdvertOrder)
		  sConf.advertIndex = rand(sConf.numAdverts);

       broadcastMsg("<C07>"$sConf.serverAdverts[sConf.advertIndex], , , , , , , , , true);

        if (++sConf.advertIndex >= sConf.numAdverts)
		  sConf.advertIndex = 0;

        sConf.nextAdvertTime = level.TimeSeconds + sConf.advertTimeInterval;
    }
	
	// Notify plugins.
	while (index < arrayCount(plugins) && plugins[index] != none) {
		plugins[index].virtualTimer();
		index++;
	}
}


Code: Select all

/***************************************************************************************************
 *
 *  $DESCRIPTION  Broadcasts the given message to all connected clients.
 *  $PARAM        msg   Message that should send to all the clients.
 *  $PARAM        str1  Message specific content.
 *  $PARAM        str2  Message specific content.
 *  $PARAM        str3  Message specific content.
 *  $PARAM        str4  Message specific content.
 *  $PARAM        pri   Replication info of the player related to this message.
 *
 **************************************************************************************************/
function broadcastMsg(string msg, optional string str1, optional string str2, optional string str3,
                      optional string str4, optional PlayerReplicationInfo pri) {
	local NexgenClient client;
	
	// Format message.
	msg = class'NexgenUtil'.static.format(msg, str1, str2, str3, str4);
	
	// Log message.
	nscLog(class'NexgenUtil'.static.removeMessageColorTag(msg), LT_Event);
	
	// Send message to all clients.
	for (client = clientList; client != none; client = client.nextClient) {
		client.showMsg(msg, pri);
	}
}


Class NexgenController.ux

Error: C:\UT coding\UnrealTournament\Nexgen113T\Classes\NexgenController.uc(2080) : Error, Call to 'broadcastMsg': Bad ',' or missing ')'
Critical: appError called:
Critical: Failed due to errors.
Exit: Executing UObject::StaticShutdownAfterError
Critical: CompileError
Critical: TryCompile
Critical: FScriptCompiler::CompileScript
Critical: (Class Nexgen113T.NexgenController, Pass 1, Line 2080)
Critical: CompileScripts
Critical: CompileScripts
Critical: CompileScripts
Critical: CompileScripts
Critical: CompileScripts
Critical: DoScripts
Critical: UEditorEngine::MakeScripts
Critical: UMakeCommandlet::Main
Exit: Exiting.




i don't want to make display the message on center like in NexgenMH
Last edited by Letylove49 on Wed Aug 10, 2022 8:09 pm, edited 11 times in total.
Image



Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Need jHelp for server adds on Nexgen

Post by Barbie »

Maybe add some more info like class and function name to get hints.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: Need jHelp for server adds on Nexgen

Post by Letylove49 »

Barbie wrote: Sat Aug 06, 2022 7:06 pm Maybe add some more info like class and function name to get hints.
i have put all the fonction and the fonction broadcasst on my post. this is on Nexgencontroller.uc
Image



Letylove49 aka Alicia
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: Need jHelp for server adds on Nexgen

Post by Buggie »

broadcastMsg("<C07>"$sConf.serverAdverts[sConf.advertIndex], , , , , , , , , true);
not match to
function broadcastMsg(string msg, optional string str1, optional string str2, optional string str3, optional string str4, optional PlayerReplicationInfo pri) {
Too many commas. And last "true" goes to nowhere. broadcastMsg not accept bool params.
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: Need jHelp for server adds on Nexgen

Post by Letylove49 »

thanks Buggie i have fun the solution that work now

Code: Select all

   broadcastMsg("<C07>"$sConf.serverAdverts[sConf.advertIndex], , , , , ); 
ihave loked to the Function BroadcastMsg and this has help me to fund the good solution.

Automatically merged

i have another problem

When I put an advertise message it does not appear in the list. I have to do a reconection so that the message is displayed in the list. Normally this should be done directly.

Code: Select all

 
 /***************************************************************************************************
 *
 *  NSC. Nexgen Server Controller by Zeropoint.
 *
 *  $CLASS        NexgenRCPServerAdds
 *  $VERSION      1.05 (15-12-2007 15:38)
 *  $AUTHOR       BoBstah
 *  $DESCRIPTION  Nexgen server adds control panel
 *
 **************************************************************************************************/
class NexgenRCPServerAdds extends NexgenPanel;

var NexgenClientCore rpci;                        // Remote Procedure Call interface.

var NexgenSimpleListBox sAddList;
var UWindowSmallButton sAddButton;
var UWindowSmallButton sRemoveButton;
var UWindowSmallButton sUpdateButton;
var UWindowSmallButton setTimeButton;
var NexgenEditControl serverAddInp;
var NexgenEditControl setTimeInp;
var UWindowCheckbox randomOrderInp;



/***************************************************************************************************
 *
 *  $DESCRIPTION  Creates the contents of the panel.
 *  $OVERRIDE
 *
 **************************************************************************************************/
function setContent() {
	local NexgenContentPanel p;
	local int region;

	// Create layout & add components.
	createWindowRootRegion();

	splitRegionH(180, defaultComponentDist);
	p = addContentPanel();

    sAddList = NexgenSimpleListBox(p.addListBox(class'NexgenSimpleListBox'));

	p = addContentPanel();
    p.splitRegionV(80);
    p.divideRegionH(3);
    p.divideRegionH(3);

	p.addLabel(client.lng.saEditTxt);
    p.skipRegion();
    p.skipRegion();

    serverAddInp = p.addEditBox();
    p.divideRegionV(3, defaultComponentDist);
    p.DivideRegionV(5);

    sAddButton = p.addButton(client.lng.saAddTxt, 96);
	sRemoveButton = p.addButton(client.lng.saRemoveTxt, 96);
	sUpdateButton = p.addButton(client.lng.saUpdateTxt, 96);

    p.addLabel(client.lng.saRandomTxt);
	randomOrderInp = p.addCheckBox(TA_Right);
    p.addLabel(client.lng.saTimeTxt, , TA_Right);
    setTimeInp = p.addEditBox( ,40);
	setTimeButton = p.addButton(client.lng.saSetTxt, 24, AL_Left);

    serverAddInp.SetMaxLength(100);
    setTimeInp.SetMaxLength(3);
    setTimeInp.SetNumericOnly(true);

    sAddList.register(self);
    sAddButton.register(self);
    sRemoveButton.register(self);
    sUpdateButton.register(self);
    setTimeButton.register(self);
    serverAddInp.register(self);
    setTimeInp.register(self);
    randomOrderInp.register(self);

    loadAdvertSettings();
}



/***************************************************************************************************
 *
 *  $DESCRIPTION  Loads the server advert list
 *
 **************************************************************************************************/
function loadAdvertSettings() {
	local int index;
	local NexgenSimpleListItem item;

	// Clear list.
	sAddList.items.clear();
	sAddList.selectedItem = none;

	// Add advert.
	while(index < arrayCount(client.sConf.serverAdverts) && client.sConf.serverAdverts[index] != "") {
		item = NexgenSimpleListItem(sAddList.items.append(class'NexgenSimpleListItem'));
  		item.displayText = client.sConf.serverAdverts[index];
		item.itemID = index;
		index++;
    }
    randomOrderInp.bChecked = client.sConf.bRandomAdvertOrder;
    setTimeInp.SetValue(string(client.sConf.advertTimeInterval));

    sRemoveButton.bDisabled = true;
    sUpdateButton.bDisabled = true;
}



/***************************************************************************************************
 *
 *  $DESCRIPTION  Attemps to locate the RPC interface for this control panel.
 *  $REQUIRE      client != none
 *  $RETURN       True if the RPC interface has been set, false if not.
 *  $ENSURE       result == true ? rcpi != none : true
 *
 **************************************************************************************************/
function bool setRPCI() {

	// Check if RPC interface is already set.
	if (rpci == none) {
		// Attempt to get the RPC interface.
		rpci = NexgenClientCore(client.getController(class'NexgenClientCore'.default.ctrlID));
		return rpci != none;

	} else {
		// It is.
		return true;
	}
}



/***************************************************************************************************
 *
 *  $DESCRIPTION  Notifies the dialog of an event (caused by user interaction with the interface).
 *  $PARAM        control    The control object where the event was triggered.
 *  $PARAM        eventType  Identifier for the type of event that has occurred.
 *  $REQUIRE      control != none
 *  $OVERRIDE
 *
 **************************************************************************************************/
function notify(UWindowDialogControl control, byte eventType) {
	local NexgenSimpleListItem newItem;

	super.notify(control, eventType);

	setRPCI();

	if (control == sAddList && eventType == DE_Click) {
	    sRemoveButton.bDisabled = sAddList.selectedItem == none;
        sUpdateButton.bDisabled = sAddList.selectedItem == none;
        serverAddInp.setValue(NexgenSimpleListItem(sAddList.selectedItem).displayText);
    }

	// Add button pressed?
	if (control == sAddButton && eventType == DE_Click && rpci != none) {
		rpci.addServerAdvert(class'NexgenUtil'.static.trim(serverAddInp.getValue()));
	}

	// Update button pressed?
	if (control == sUpdateButton && eventType == DE_Click && rpci != none) {
		rpci.updateServerAdvert(NexgenSimpleListItem(sAddList.selectedItem).itemID, class'NexgenUtil'.static.trim(serverAddInp.getValue()));
	}

	// Remove button pressed?
	if (control == sRemoveButton && eventType == DE_Click && rpci != none) {
		rpci.deleteServerAdvert(NexgenSimpleListItem(sAddList.selectedItem).itemID);
	}

   	// Set time button pressed?
	if ((control == setTimeButton || control == randomOrderInp) && eventType == DE_Click && rpci != none) {
		rpci.updateServerAdvertSettings(int(class'NexgenUtil'.static.trim(setTimeInp.getValue())), randomOrderInp.bChecked);
	}
}



/***************************************************************************************************
 *
 *  $DESCRIPTION  Notifies this panel that the server configuration has been updated.
 *  $PARAM        configType  Type of settings that have been changed.
 *  $OVERRIDE
 *
 **************************************************************************************************/
function configChanged(byte configType) {

	// Relevant settings for this panel?
	if (configType == client.sConf.CT_AdvertSettings)
		loadAdvertSettings();
}



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

defaultproperties
{
    panelIdentifier="serveradds"
}
 

this is on Nexgenclientcore.uc

Code: Select all

 
/***************************************************************************************************
 *
 *  $DESCRIPTION  Adds an advert to the server adverts list
 *  $PARAM        theAdvert     String containing the advert to add
 *
 **************************************************************************************************/
function addServerAdvert (string theAdvert) {
	local byte entryNum;
	local bool bFound;

	// Preliminary checks.
	if (!client.hasRight(client.R_ServerAdmin))
		return;

	// Find a free slot.
	while (!bFound && entryNum < arrayCount(control.sConf.serverAdverts)) {
		if (control.sConf.serverAdverts[entryNum] == "") {
			bFound = true;
		} else {
			entryNum++;
		}
	}

	// Cancel on error.
	if (!bFound) {
	    client.showMsg(control.lng.saNoRoomMsg);
		return;
	}

	// Store advert.
	control.sConf.serverAdverts[entryNum] = theAdvert;
    control.sConf.numAdverts++;

	// Save changes.
	control.sConf.saveConfig();

    // Signal update.
   	control.signalConfigUpdate(control.sConf.CT_AdvertSettings);

}

/***************************************************************************************************
 *
 *  $DESCRIPTION  Updates an advert in the server adverts list
 *  $PARAM        entryNum      Index of the advert to update
 *  $PARAM        theAdvert     String containing the advert to update
 *
 **************************************************************************************************/
function updateServerAdvert (byte entryNum, string theAdvert) {

	// Preliminary checks.
	if (!client.hasRight(client.R_ServerAdmin) ||
        entryNum >= arrayCount(control.sConf.serverAdverts) ||
	    control.sConf.serverAdverts[entryNum] == "")
		return;

	// Update ban.
	control.sConf.serverAdverts[entryNum] = theAdvert;

	// Save changes.
	control.sConf.saveConfig();

    // Signal update.
   	control.signalConfigUpdate(control.sConf.CT_AdvertSettings);
}

/***************************************************************************************************
 *
 *  $DESCRIPTION  Deletes an advert in the server adverts list
 *  $PARAM        entryNum      Index of the advert to delete
 *
 **************************************************************************************************/
function deleteServerAdvert (byte entryNum) {
	local bool bFound;
	local int index;

	// Preliminary checks.
	if (!client.hasRight(client.R_ServerAdmin) ||
        entryNum >= arrayCount(control.sConf.serverAdverts) ||
	    control.sConf.serverAdverts[entryNum] == "")
		return;

	for (index = entryNum; index < arrayCount(control.sConf.serverAdverts); index++) {
		// Last entry?
		if (index + 1 == arrayCount(control.sConf.serverAdverts)) // Yes, clear fields.
			control.sConf.serverAdverts[index] = "";
		else // No, copy fields from next entry.
			control.sConf.serverAdverts[index] = control.sConf.serverAdverts[index + 1];
	}

	// Save changes.
	control.sConf.saveConfig();
    control.sConf.numAdverts--;

    // Signal update.
   	control.signalConfigUpdate(control.sConf.CT_AdvertSettings);

}

/***************************************************************************************************
 *
 *  $DESCRIPTION  Updates the server advert settings
 *  $PARAM        timeInterval  Number of seconds between each show of an advert
 *  $PARAM        bRandomOrder  TRUE if adverts should be picked from the list at random
 *
 **************************************************************************************************/
function updateServerAdvertSettings (byte timeInterval, bool bRandomOrder) {

	if (!client.hasRight(client.R_ServerAdmin))
	   return;

    if (timeInterval >= 1)
        control.sConf.advertTimeInterval = timeInterval;
    else
   	    client.showMsg(control.lng.saInvTimeMsg);

    control.sConf.bRandomAdvertOrder = bRandomOrder;

	// Save changes.
	control.sConf.saveConfig();

    // Signal update.
   	control.signalConfigUpdate(control.sConf.CT_AdvertSettings);

    client.showMsg(control.lng.settingsSavedMsg);
}


/***************************************************************************************************   
somone know why i have this issue
Last edited by Letylove49 on Tue Aug 09, 2022 10:53 am, edited 1 time in total.
Image



Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Need jHelp for server adds on Nexgen

Post by Barbie »

Can you please change the QUOTE tag into CODE tag? It would be much better readable then. Thanks.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: Need jHelp for server adds on Nexgen

Post by Letylove49 »

Barbie wrote: Tue Aug 09, 2022 12:07 am Can you please change the QUOTE tag into CODE tag? It would be much better readable then. Thanks.
ok have change de Quote to Code.
Image



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

Re: Need jHelp for server adds on Nexgen

Post by Letylove49 »

Problem fixed now i have forgot to update a value in Nexgen Client.

Code: Select all

 // Config change events.
var int nextDynamicUpdateCount[10];                // Last received config update count per config type.
var int nextDynamicChecksum[10];                   // Checksum to wait for.
var byte bWaitingForNewConfig[10];                 // Whether the client is waiting for the configuration.
The value was to 9 is why the Serveradvert was not take in the checksum.
Image



Letylove49 aka Alicia
Post Reply