How to get an npc to check?

08/01/2010 18:30 2010mrsurfer#1
How would you get a npc to check the players level and if they are second reborn?
08/01/2010 19:09 Fish*#2
Code:
public static byte LEVEL = 200;//If should be over level 200
public static byte REBORNS = 2;//If should be over 2nd rb
//You could also just replace LEVEL and REBORNS with the value u want
if (GC.MyChar.Level >= LEVEL && GC.MyChar.Reborns >= REBORNS)
08/01/2010 19:12 2010mrsurfer#3
Thanks grill! :D
08/01/2010 21:01 Zkiller110#4
Quote:
Originally Posted by grillmad View Post
Code:
public static byte LEVEL = 200;//If should be over level 200
public static byte REBORNS = 2;//If should be over 2nd rb
//You could also just replace LEVEL and REBORNS with the value u want
if (GC.MyChar.Level >= LEVEL && GC.MyChar.Reborns >= REBORNS)
:p or could just make a simple if statment
Code:
if (GC.MyChar.Level >= 200 && GC.MyChar.Reborns >= 2)
to make it easier and less typing
08/01/2010 21:06 2010mrsurfer#5
Thanks :D
08/01/2010 21:12 Fish*#6
Quote:
Originally Posted by Zkiller110 View Post
:p or could just me a simple if
Code:
if (GC.MyChar.Level >= 200 && GC.MyChar.Reborns >= 2)
to make it easier and less typing
I also wrote that :)
If u read the comments i putted.
08/02/2010 03:27 pro4never#7
I don't feel like re-writing a TON of stuff seeing as it's already been posted... If you look at my linklist there is some mini tutorials I wrote up that cover how to use some different types of things in C# including if/else if/else, try/catch and some similar stuff.


The tldr version though is that if(code to check) checks everything inside the bracket to verify if it is either true or false. If true the code under it is executed... if not then it isn't run.

You can do a string of if statements using else if.

Else simple means if no preceding statement is called then the else statement is run.

Eg:


if(GC.MyChar.Level >= 100)
{
//you are level 100 or over
}
else if (GC.MyChar.Level >=120)
{
you are over 120. This will NEVER be called because the first if statement is already confirming you are over 100!
}
else
{
//will only be called if under 100
}


If you do a string of if statements and then an else... then only 2 things can be called!


if(GC.MyChar.Level >= 100)
{
100 or over called
}

if(GC.MyChar.Level >= 120)
{
120 or over called (ALWAYS calls both if over 120.. because you are obviously over 100 if you are 120+)
}
else
{
will be called at 0-120. EVEN IF YOU ARE 110-120 THIS WILL BE CALLED BECAUSE YOU DID NOT DO ELSE IF FOR THE SECOND CHECK!
}



Also here are the things you can use for if statements


&& = and (both statements must be true)

|| = or (either statement must be true)

> = greater than

< = less than

>= greater than or equal to

<= less than or equal to
08/02/2010 04:27 Fish*#8
Quote:
Originally Posted by pro4never View Post
I don't feel like re-writing a TON of stuff seeing as it's already been posted... If you look at my linklist there is some mini tutorials I wrote up that cover how to use some different types of things in C# including if/else if/else, try/catch and some similar stuff.


The tldr version though is that if(code to check) checks everything inside the bracket to verify if it is either true or false. If true the code under it is executed... if not then it isn't run.

You can do a string of if statements using else if.

Else simple means if no preceding statement is called then the else statement is run.

Eg:


if(GC.MyChar.Level >= 100)
{
//you are level 100 or over
}
else if (GC.MyChar.Level >=120)
{
you are over 120. This will NEVER be called because the first if statement is already confirming you are over 100!
}
else
{
//will only be called if under 100
}


If you do a string of if statements and then an else... then only 2 things can be called!


if(GC.MyChar.Level >= 100)
{
100 or over called
}

if(GC.MyChar.Level >= 120)
{
120 or over called (ALWAYS calls both if over 120.. because you are obviously over 100 if you are 120+)
}
else
{
will be called at 0-120. EVEN IF YOU ARE 110-120 THIS WILL BE CALLED BECAUSE YOU DID NOT DO ELSE IF FOR THE SECOND CHECK!
}



Also here are the things you can use for if statements


&& = and (both statements must be true)

|| = or (either statement must be true)

> = greater than

< = less than

>= greater than or equal to

<= less than or equal to
remember to tell || can be used to make 2 checks to see if one is right.
ex.
Code:
if (GC.MyChar.Level >= 120 && GC.MyChar.Reborns >= 1 || GC.MyChar.Reborns >= 2 && GC.MyChar.Level >= 110)//If you are over level 120 and 1st rb OR if you are 2nd rb and over level 110