# SolvedW2Screen

#### Lolita1

##### Newbie
Hello,
I would like to ask if someone can help me out what is possibly wrong with my w2s. In middle of screen that mana bar is in place where it should be, but when player is on top of the screen mana bar is moved more top than it should be. Anyone can take a look what am i missing ?

https://s15.postimg.org/httfgc0e2/w2s.jpg

in second case it's moved top left away from place where it should be, but again when player is in middle of screen everything is fine

https://s29.postimg.org/d98hd9t92/w2s2.jpg

C#:
``````        public static bool WorldToScreen(Vector3 Position, out Vector3 vScreen)
{
float[] w2s = Memory.Read<float>(Memory.GetModule(Offsets.Engine) + Offsets.WorldToScreen, 16, false);

float w = (w2s[12] * Position.X + w2s[13] * Position.Y + w2s[14] * Position.Z + w2s[15]);
vScreen.Z = 0f;

if (w > 0.01)
{
float fl1DBw = 1.0f / w;
vScreen.X = (float)((Width / 2) + (0.5 * ((w2s[0] * Position.X + w2s[1] * Position.Y + w2s[2] * Position.Z + w2s[3]) * fl1DBw) * Width + 0.5));
vScreen.Y = (float)((Height / 2) - (0.5 * ((w2s[4] * Position.X + w2s[5] * Position.Y + w2s[6] * Position.Z + w2s[7]) * fl1DBw) * Height + 0.5));

return true;
}

vScreen.X = 0f;
vScreen.Y = 0f;

return false;
}``````

Last edited:

Last edited:

#### Lolita1

##### Newbie
All right, it's been here for a while and noone said a thing so i have to ask.. Noone knows or are you mad at me because of AnomanderRake ?

#### dmo

##### Coder
Full Member
Nobleman
In cs:go you need to get head position and feet position to keep it in place. Maybe you can apply this logic.

#### Rake

Which bar is the one you are drawing? the blue one?

#### Lolita1

##### Newbie
Which bar is the one you are drawing? the blue one?
Yes the blue one with text. I want it to be under hero. When hero is in middle of screen it's under hero how i want it to be, but when hero is on top of screen as you can see on the first screenshot that blue bar is in middle of that hero and on second screenshot when hero is top/right that blue bar is in middle of hero and moved left and i can't figure up what's wrong. Any help i would appreciate.

Last edited:

#### Lolita1

##### Newbie
The position variable that you feed into your w2s is what? The center of the model, the models head or what? And then we need to see your draw function to see how you calculate location of the bar from the screen coordinates. Most ESPs get a little wierd towards the edge of the screen but yours does appear to more than a "little wierd"
PlayerClass :
C#:
``````        public float X
{
}

public float Y
{
}

public float Z
{
}

public Vector3 Location // Player's position on map
{
get { return new Vector3(X, Y, Z); }
}``````
Drawing :
C#:
``````                Drawing.ClearScreen();
Drawing.Device.BeginScene();
................
................

var players = GameObjectManager.Players.Where(x => x.IsEnemy).ToList();

foreach (var player in players)
{
if (player.IsAlive)
{
Vector3 v;
if (Drawing.WorldToScreen(player.Location, out v))
Drawing.DrawManaBar(v.X, v.Y, 90, 7, player.Mana, player.MaximumMana);
}
}

................
................

Drawing.Device.EndScene();
Drawing.Device.Present();``````
Draw Mana Bar :
C#:
``````        public static void DrawManaBar(float x, float y, float w, float h, float current, float max)
{
DrawTransparentBox((x - 50, y - 30, w, h, 100, Color.Gray);
DrawFilledBox((x - 50, y - 30, (current / max) * w, h, Color.Blue);
DrawText((int)current + "/" + (int)max, x - 20, y - 32, Color.White);
}``````

Last edited:

#### Lolita1

##### Newbie
All right. I found solution for this problem by adding +100 to Width and adding minus to Height. Now it works fine (plus/minus a bit) and that blue bar stays in place doest matter how i move around....but I dont understand it at all...

Game Resolution : 1366x768
OverLay Resolution : 1366x768
Even when i printed :
GetRect.Right - GetRect.Left = 1366
GetRect.Bottom - GetRect.Top = 768

My question now is HOW is that possible that it works now if the result Wight = 1466 and Height = 638 ?????

C#:
``````Drawing.Width = GetRect.Right - GetRect.Left + 100;  // 1466
Drawing.Height = GetRect.Bottom - GetRect.Top - 130;  // 638``````

Last edited:
Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language