Page 1 of 1

NexgenMH2MB : i got a errror with &&

Posted: Fri Nov 25, 2022 12:03 am
by Letylove49
hello
in' unable to find why that don't work;

this Fonction must be used only if the 2 value are on True ( Bool function)

buseMH2BrodcastMultikillMessage==True ; clients side ( the player can enable or diseable it
bBrocastMH2GOLDMHAMultikillMessages==True; Serverside and only a ServerAdmin can enable or disable it to alowed or not this function)

i got this error if i put my if with && like that :
Error: C:\UT coding\UnrealTournament\NexgenMH2MB112SDL\Classes\NexgenMH2MBClient.uc(127) : Error, '&&': Bad command or expression

Code: Select all

  /***************************************************************************************************
 *
 *  $DESCRIPTION  Broadcasts an MH2 GOLD MHA Multikill Message to all players.
 * 
 **************************************************************************************************/
function broadcastmh2Multikill(int type, string playerName) {
  local string msg;

if(buseMH2BrodcastMultikillMessage==True) && (bBrocastMH2GOLDMHAMultikillMessages==True);
  
  if (type == 0) {
    msg = class'NexgenUtil'.static.format(mh2MultikillMessage, playerName);
  } else if(type == 1)   {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[0], playerName);
  } else if(type == 2) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[1], playerName);
  } else if(type == 3) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[2], playerName);
  } else if(type ==4) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[3], playerName);
  } else if(type == 5) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[4], playerName);
  } else if(type == 6 ) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[5], playerName);
  }else if(type >= 7 && type <=39) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[6], playerName);
  }else if(type >= 40 ) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[7], playerName);
  }
  if(msg != "") control.broadcastMsg(msg);
}

i got this error if i put my if with && like that :
Error: C:\UT coding\UnrealTournament\NexgenMH2MB112SDL\Classes\NexgenMH2MBClient.uc(127) : Error, Bad or missing expression after '&&'

Code: Select all

  /***************************************************************************************************
 *
 *  $DESCRIPTION  Broadcasts an MH2 GOLD MHA Multikill Message to all players.
 * 
 **************************************************************************************************/
function broadcastmh2Multikill(int type, string playerName) {
  local string msg;

if(buseMH2BrodcastMultikillMessage==True && bBrocastMH2GOLDMHAMultikillMessages==True);
  
  if (type == 0) {
    msg = class'NexgenUtil'.static.format(mh2MultikillMessage, playerName);
  } else if(type == 1)   {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[0], playerName);
  } else if(type == 2) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[1], playerName);
  } else if(type == 3) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[2], playerName);
  } else if(type ==4) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[3], playerName);
  } else if(type == 5) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[4], playerName);
  } else if(type == 6 ) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[5], playerName);
  }else if(type >= 7 && type <=39) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[6], playerName);
  }else if(type >= 40 ) {
    msg = class'NexgenUtil'.static.format(mh2multiKillMessage[7], playerName);
  }
  if(msg != "") control.broadcastMsg(msg);
}

What i'm doing wrong ?? somone could give me a help please.

Re: NexgenMH2MB : i got a errror with &&

Posted: Fri Nov 25, 2022 12:30 am
by Barbie
As often too less information; i suspect bBrocastMH2GOLDMHAMultikillMessages is not known to the compiler.

PS: the semicolon at the end prevents any code to be executed depending on the if-condition.
PPS: You could shorten that to

Code: Select all

if (buseMH2BrodcastMultikillMessage && bBrocastMH2GOLDMHAMultikillMessages)

Re: NexgenMH2MB : i got a errror with &&

Posted: Fri Nov 25, 2022 3:01 am
by Shrimp
It's likely the compiler is choking on the empty statement following the `if`.

Replace the semicolon at the end of the line with an opening brace, like so, and put a closing brace after all the other if conditions:

Code: Select all

   if (buseMH2BrodcastMultikillMessage && bBrocastMH2GOLDMHAMultikillMessages) { // opening brace
     if (type == 0) {
       msg = class'NexgenUtil'.static.format(mh2MultikillMessage, playerName);
     } else if(type == 1) {
     ....
    }
   } // new closing brace
A cleaner solution though is a "short circuit" condition, if you want the rest of the function to not be executed.

Code: Select all

  if (!buseMH2BrodcastMultikillMessage || !bBrocastMH2GOLDMHAMultikillMessages) return;
If either condition is not true, the rest of the function does not execute.

Re: NexgenMH2MB : i got a errror with &&

Posted: Fri Nov 25, 2022 4:42 am
by Buggie
Compiler not able get what you mean when write
if(buseMH2BrodcastMultikillMessage==True) && (bBrocastMH2GOLDMHAMultikillMessages==True);
It see valid if(buseMH2BrodcastMultikillMessage==True) after which follow &&. On which it throw error.

In fact code above is:

Code: Select all

if(buseMH2BrodcastMultikillMessage==True)
   && (bBrocastMH2GOLDMHAMultikillMessages==True);
And code line can't start from bare && in front.

If you use brackets - ensure if condition come as one single bracket.

Re: NexgenMH2MB : i got a errror with &&

Posted: Fri Nov 25, 2022 10:47 pm
by Letylove49
Shrimp wrote: Fri Nov 25, 2022 3:01 am It's likely the compiler is choking on the empty statement following the `if`.

Replace the semicolon at the end of the line with an opening brace, like so, and put a closing brace after all the other if conditions:

Code: Select all

   if (buseMH2BrodcastMultikillMessage && bBrocastMH2GOLDMHAMultikillMessages) { // opening brace
     if (type == 0) {
       msg = class'NexgenUtil'.static.format(mh2MultikillMessage, playerName);
     } else if(type == 1) {
     ....
    }
   } // new closing brace
A cleaner solution though is a "short circuit" condition, if you want the rest of the function to not be executed.

Code: Select all

  if (!buseMH2BrodcastMultikillMessage || !bBrocastMH2GOLDMHAMultikillMessages) return;
If either condition is not true, the rest of the function does not execute.

Code: Select all

   ]i have try this   if (!buseMH2BrodcastMultikillMessage || !bBrocastMH2GOLDMHAMultikillMessages) return;      [/code

now i got  this error :Error: C:\UT coding\UnrealTournament\NexgenMH2MB112SDL\Classes\NexgenMH2MBClient.uc(127) : Error, Bad or missing expression after '!'

Re: NexgenMH2MB : i got a errror with &&

Posted: Sat Nov 26, 2022 12:40 am
by Shrimp
Does the variable bBrocastMH2GOLDMHAMultikillMessages actually exist in your class?

Re: NexgenMH2MB : i got a errror with &&

Posted: Sat Nov 26, 2022 4:05 am
by Buggie
bBrocastMH2GOLDMHAMultikillMessages sound as typo and must be with "d": bBrodcastMH2GOLDMHAMultikillMessages
Or maybe even with "ad" - "Broadcast".

Re: NexgenMH2MB : i got a errror with &&

Posted: Sat Nov 26, 2022 11:18 am
by Letylove49
Shrimp wrote: Sat Nov 26, 2022 12:40 am Does the variable bBrocastMH2GOLDMHAMultikillMessages actually exist in your class?
no i have add it in another class.
I have add it in tthis class and now and i don't have this error.

if I understand the logic each function I use in a class must be declared in that class for the compiler to find it. If I put her in another class it doesn’t work.

Thanks i think that will help me a lot.

Re: NexgenMH2MB : i got a errror with &&

Posted: Sat Nov 26, 2022 11:54 am
by Shrimp
Yes, a class is a self-contained entity, it can generally only access variables it has declared in it (and variables of other actors it has declared as variables).

If you want to get a better understanding I'd suggest maybe doing a very short couple of hours Java course to learn the basics. UnrealScript is fairly similar to Java in its class composition. That would give you the basics of things like variable scope and references and things which you can apply to UnrealScript.

Re: NexgenMH2MB : Error in NexgenMH2MBMain.uc (28): Illegal character in name

Posted: Mon Nov 28, 2022 3:44 pm
by Letylove49
i get this : Error in NexgenMH2MBMain.uc (28): Illegal character in name ( i don0t fund the ilegal carater here:

Code: Select all

/***************************************************************************************************
 *
 *  $DESCRIPTION  Modifies the setup of the Nexgen remote control panel.
 *  $OVERRIDE
 *
 **************************************************************************************************/
simulated function setupControlPanel() {

if (Level.Game.IsA('MonsterHunt2GoldMHA.MonsterHunt'));

     NexgenMH2MBClientConfigRCP = NexgenMH2MBClientConfigRCP(client.mainWindow.mainPanel.addPanel("Multikill setting", class'NexgenMh2MBClientConfigRCP', , "client"));

	
	if (client.hasRight(client.R_ServerAdmin)) {
		
		client.addPluginConfigPanel(class'NexgenMH2MBServersettingsRCP');
		

	}
}

 

Re: NexgenMH2MB : i got a errror with &&

Posted: Mon Nov 28, 2022 3:56 pm
by sektor2111
I cannot find it either... but I think I can see it...
NAMES are not written with double-quotes - > "somename" is written as 'somename'. String values are using "double-quotes". Also I think SPACE is not really supported in name type variables.
You can write a small actor which in PostBeginPlay will print a log.
See what is compiled and what is not from here:

Code: Select all

log("I am an actor for testing",'ATest');
Then

Code: Select all

log("I am an actor for testing",'A Test');
Then

Code: Select all

log("I am an actor for testing","A Test");
Go figure what is being compiled and what is pointed as error in each case.

Re: NexgenMH2MB : i got a errror with &&

Posted: Mon Nov 28, 2022 11:40 pm
by Barbie
Letylove49 wrote: Mon Nov 28, 2022 3:44 pmif (Level.Game.IsA('MonsterHunt2GoldMHA.MonsterHunt'));
IsA() expects a name, but "MonsterHunt2GoldMHA.MonsterHunt" isn't one.

Code: Select all

if (Level.Game.IsA('MonsterHunt'))
should work.

PS: It would have been nice if you had told us WHAT line 28 is.
PPS: You did it again: the semicolon at end of the if-statement makes the if statement useless - nothing happens if the condition is true. :wth:

Re: NexgenMH2MB : Error in NexgenMH2MBMain.uc (28): Illegal character in name

Posted: Tue Nov 29, 2022 3:01 am
by Buggie
Letylove49 wrote: Mon Nov 28, 2022 3:44 pm i get this : Error in NexgenMH2MBMain.uc (28): Illegal character in name ( i don0t fund the ilegal carater here:

Code: Select all

if (Level.Game.IsA('MonsterHunt2GoldMHA.MonsterHunt'));
Name can't contain dot ("."). So it is your illegal character.