Register for your free account! | Forgot your password?

You last visited: Today at 18:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help]Some C# help ><

Discussion on [Help]Some C# help >< within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
[Help]Some C# help ><

Hey im tryna to make an NPC which checks if your three differance classes
and if your one of the classes i put it does the code under it

im poo at C# so could you tell me how to resolve this D:

Code:
                                             if(Control == 1)
                                             {
                                                 if (GC.MyChar.Job = 15 || GC.MyChar.Job = 25 || GC.MyChar.Job = 135)
                                                 {
                                                     //code preformed if true
                                                 }
The error im getting is:
Quote:
Operator "||" cannot be applied to operands of type 'int' and 'byte'
What should i do to try to resolve this?
xScott is offline  
Old 01/13/2010, 19:04   #2
 
ramix's Avatar
 
elite*gold: 0
Join Date: Aug 2008
Posts: 272
Received Thanks: 61
try this

if (GC.MyChar.Job = 15 && GC.MyChar.Job = 25 && GC.MyChar.Job = 135)

ramix is offline  
Old 01/13/2010, 19:07   #3
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
Quote:
Originally Posted by ramix View Post
try this

if (GC.MyChar.Job = 15 && GC.MyChar.Job = 25 && GC.MyChar.Job = 135)

if you do that, doesnt all jobs IDs have to be true in order to carry the code out? && is And right?
xScott is offline  
Old 01/13/2010, 19:12   #4
 
Nullable's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
Because, you should do it like MyChar.Job == 15, not only 1 equal sign, 1 equal sign is the assignment operator, double equal signs is the check equality operator, which changes this (MyChar.Job == 15) to a bool value
Nullable is offline  
Old 01/13/2010, 19:13   #5
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
Quote:
Originally Posted by Nullable View Post
This is weird, the variable is the same but it is giving an error..
Try something like if(MyChar.Job == (int)15 || MyChar.Job == (int)25 etc..
yeah i was messing around with it and it gave an error like, "Did you miss a cast?" or something like that. thanks for your post ill try it now
xScott is offline  
Old 01/13/2010, 19:15   #6
 
elite*gold: 0
Join Date: Jan 2010
Posts: 73
Received Thanks: 9
Code:
if(Control == 1)
                                             {
                                                 if (GC.MyChar.Job == 15 || GC.MyChar.Job == 25 || GC.MyChar.Job == 135)
                                                 {
                                                     //code preformed if true
                                                 }
= means assining a value
== means checking if it's an equal statement
ElitePVPer10 is offline  
Old 01/13/2010, 19:16   #7
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
Quote:
Originally Posted by ElitePVPer10 View Post
Code:
if(Control == 1)
                                             {
                                                 if (GC.MyChar.Job == 15 || GC.MyChar.Job == 25 || GC.MyChar.Job == 135)
                                                 {
                                                     //code preformed if true
                                                 }
= means assining a value
== means checking if it's an equal statement
OHHHH haha ty! i knew it would be something stupid xD

It works now =]
xScott is offline  
Old 01/13/2010, 19:19   #8
 
elite*gold: 0
Join Date: Jan 2010
Posts: 73
Received Thanks: 9
Quote:
Originally Posted by xScott View Post
OHHHH haha ty! i knew it would be something stupid xD

It works now =]
ElitePVPer10 is offline  
Reply




All times are GMT +2. The time now is 18:28.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.