[Help]Some C# help ><

01/13/2010 18:54 xScott#1
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?
01/13/2010 19:04 ramix#2
try this

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

:)
01/13/2010 19:07 xScott#3
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?
01/13/2010 19:12 Nullable#4
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
01/13/2010 19:13 xScott#5
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 :)
01/13/2010 19:15 ElitePVPer10#6
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
01/13/2010 19:16 xScott#7
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 =]
01/13/2010 19:19 ElitePVPer10#8
Quote:
Originally Posted by xScott View Post
OHHHH haha ty! i knew it would be something stupid xD

It works now =]
:)