Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 06:41

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

Advertisement



[Help]I need Simple C# help??

Discussion on [Help]I need Simple C# help?? within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
iCraziE's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 456
Received Thanks: 218
[Help]I need Simple C# help??

EDIT :: I FIXED IT.. turns out I was using the "OR" operator instead of the "AND" operator.. lol silly me

I needed a little bit of help making a compass feature for a game.

SO, this is my code.. it will only show "E" (east) .. im assuming because for some reason its always seeing the direction as 0 and not updating with the direction.

Code:
long eOffset = this.GameMemory.ReadInt64(gOffset);
                long pOffset = this.GameMemory.ReadInt64(eOffset + 0x22D8);
                pD = this.GameMemory.ReadFloat(pOffset + 0x128);

                if (pD > -0.5 || pD < 0.5 )
                {
                    compass = "E";
                }
                else if (pD > 0.5 || pD < 0.9)
                {
                    compass = "NE";
                }
                else if (pD > 0.9 || pD < 2.0)
                {
                    compass = "N";
                }
                else if (pD > 2.0 || pD < 2.4)
                {
                    compass = "NW";
                }
                else if (pD > 2.4 || pD <= 3.14)
                {
                    compass = "W";
                }
                else if (pD >= -3.14 || pD < -2.4)
                {
                    compass = "W";
                }
                else if (pD > -2.4 || pD < -2.0)
                {
                    compass = "SW";
                }
                else if (pD > -2.0 || pD < -0.9)
                {
                    compass = "S";
                }
                else if (pD > -0.9 || pD < -0.5)
                {
                    compass = "SE";
                }
so that's my terrible attempt at coding. I tried to follow along with what I've seen but I am a complete noob when it comes to this. Can anyone help me know what is wrong here?

Also, I have this declared in the main class

Code:
        public static float pD;

        public string compass; // <----- maybe this is not the right format to set this?
Here is my TextRegion

Code:
TextRegion = new POINT(this.GameWindowRect.Left + 15, this.GameWindowRect.Top + 35);
                if (ShowDirection)
                {
                    DrawText("Direction: " + pD.ToString("F2") + " : " + compass, ref TextRegion, Color.Cyan);
                }
The Direction (pD) is outputting the correct information and updating in my text region.. however no matter what.. the "compass" always show it as east.. meaning its always getting a value of 0, and not the value of (pD) ever y time it changes.

Just for further clarification.. let me give an example of my problem.

In the drawn text, it shows "Direction: 2.10 : E".

This is clearly wrong because according to the math, if the pD ("2.10") is greater than 2.0 and also less than 2.4, it should be displaying "NW" not "E".


Any help or info would be appreciated thanks.
iCraziE is offline  
Old 03/15/2015, 17:46   #2
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,137
Received Thanks: 573
Code:
pD > -0.5 || pD < 0.5
this will always be true, use and (&&) not or (||)
warfley is offline  
Old 03/16/2015, 07:27   #3
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
Quote:
Originally Posted by warfley View Post
Code:
pD > -0.5 || pD < 0.5
this will always be true, use and (&&) not or (||)
Lies mal die 1. Zeile seines Posts.
alpines is offline  
Old 03/19/2015, 22:41   #4

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
please use Math.Pi
x]vIrus[x is offline  
Reply




All times are GMT +1. The time now is 06:43.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.