NexgenMH2MB : i got a errror with &&

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

NexgenMH2MB : i got a errror with &&

Post 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.
Image





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

Re: NexgenMH2MB : i got a errror with &&

Post 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)
"If Origin not in center it be not in center." --Buggie
User avatar
Shrimp
Adept
Posts: 305
Joined: Wed Oct 10, 2018 11:15 am
Location: Australia

Re: NexgenMH2MB : i got a errror with &&

Post 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.
Last edited by Shrimp on Fri Nov 25, 2022 1:13 pm, edited 1 time in total.
ShrimpWorks
Unreal Archive - preserving over 25 years of user-created content for the Unreal series!
Buggie
Godlike
Posts: 3230
Joined: Sat Mar 21, 2020 5:32 am

Re: NexgenMH2MB : i got a errror with &&

Post 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.
Letylove49
Adept
Posts: 282
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse

Re: NexgenMH2MB : i got a errror with &&

Post 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 '!'
Image





Letylove49 aka Alicia
User avatar
Shrimp
Adept
Posts: 305
Joined: Wed Oct 10, 2018 11:15 am
Location: Australia

Re: NexgenMH2MB : i got a errror with &&

Post by Shrimp »

Does the variable bBrocastMH2GOLDMHAMultikillMessages actually exist in your class?
ShrimpWorks
Unreal Archive - preserving over 25 years of user-created content for the Unreal series!
Buggie
Godlike
Posts: 3230
Joined: Sat Mar 21, 2020 5:32 am

Re: NexgenMH2MB : i got a errror with &&

Post by Buggie »

bBrocastMH2GOLDMHAMultikillMessages sound as typo and must be with "d": bBrodcastMH2GOLDMHAMultikillMessages
Or maybe even with "ad" - "Broadcast".
Letylove49
Adept
Posts: 282
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse

Re: NexgenMH2MB : i got a errror with &&

Post 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.
Image





Letylove49 aka Alicia
User avatar
Shrimp
Adept
Posts: 305
Joined: Wed Oct 10, 2018 11:15 am
Location: Australia

Re: NexgenMH2MB : i got a errror with &&

Post 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.
ShrimpWorks
Unreal Archive - preserving over 25 years of user-created content for the Unreal series!
Letylove49
Adept
Posts: 282
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse

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

Post 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');
		

	}
}

 
Image





Letylove49 aka Alicia
User avatar
sektor2111
Godlike
Posts: 6443
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: NexgenMH2MB : i got a errror with &&

Post 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.
User avatar
Barbie
Godlike
Posts: 2956
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: NexgenMH2MB : i got a errror with &&

Post 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:
"If Origin not in center it be not in center." --Buggie
Buggie
Godlike
Posts: 3230
Joined: Sat Mar 21, 2020 5:32 am

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

Post 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.