Raised This Month: $32 Target: $400
 8% 

Get map size (width and length) and player positions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostdlr
Senior Member
Join Date: Aug 2010
Old 12-03-2022 , 13:45   Get map size (width and length) and player positions
Reply With Quote #1

I'm making a plugin and I want to display a live preview of the game on my website.

On top of a map image, i want to display the exact position of each player (updated every 5 seconds).

I can use get_user_origin() function to get the player position and it returns something like this:
-1060 1118 -4
I presume first 2 numbers are the X and Y coordinates on the map and the last one is the height where the player is? Can someone confirm this?


I also need to get the map size (width and length) so I can position the players over the map image preview properly.
I couldn't find a function for that. Can anyone help?

Last edited by ghostdlr; 12-03-2022 at 13:46.
ghostdlr is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 12-03-2022 , 14:27   Re: Get map size (width and length) and player positions
Reply With Quote #2

Why are the coordinates with minus sometimes? Do they represent the position relative to the center of the map?

Last edited by ghostdlr; 12-03-2022 at 14:27.
ghostdlr is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 12-03-2022 , 17:09   Re: Get map size (width and length) and player positions
Reply With Quote #3

Quote:
Originally Posted by ghostdlr View Post
Why are the coordinates with minus sometimes? Do they represent the position relative to the center of the map?
yes. you could try to get pev_mins and pev_maxs of worldspawn to get the map boundaries
jimaway is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2022 , 17:54   Re: Get map size (width and length) and player positions
Reply With Quote #4

The coordinates are based on the 3D cartesian coordinate system where the origin is at some arbitrary location in the map, it really depends on where the original map developer started creating the map elements. And, yes, the third coordinate is the Z axis which is the vertical position (relative to the origin).
__________________
fysiks is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 12-03-2022 , 19:56   Re: Get map size (width and length) and player positions
Reply With Quote #5

Is there any way to find out where the corners of the map are, to somehow pin point where a player is located on it?

Is there any way to teleport myself to a certain location, maybe some kind of plugin? I could teleport to 0, 0 coordinates to find the center then figure out where everything else is located ...

Last edited by ghostdlr; 12-03-2022 at 19:58.
ghostdlr is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-03-2022 , 19:57   Re: Get map size (width and length) and player positions
Reply With Quote #6

corners of the map no, but the origin of the map YES

Origin of the map is 0x0x0 Actually the origin of the overview in the map is saved in the category global in the overview of the map .txt file.

and as you can see the overview of the map is transferred from units to photo size in pixels depending on the view aspect...

and the overview of the map width and height are constant which is 1024x768
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-03-2022 at 21:14.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2022 , 21:21   Re: Get map size (width and length) and player positions
Reply With Quote #7

If you're curious about coordinates of a map, you might be interested in using BSPViewer. You can float around and it will tell you your origin (the location of your viewport in the map).

While it is possible to write a plugin to teleport to the origin, it won't actually be that useful IMO, I would just use BSPViewer.

Regardless, I don't think you even need to do this because, as Natsheh said, the data you need is in the TXT file that comes with the overview of the map (you'll need to use that overview or one that is equivalent for the image you're planning on putting your player locations on).

If you look up on how to make overviews, it will probably have some good info for what you're trying to do (because you are literally doing exactly what the game does already in the minimap).
__________________
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-03-2022 , 21:49   Re: Get map size (width and length) and player positions
Reply With Quote #8

Here're some useful references from the Xash3D engine code.

https://github.com/FWGS/xash3d/blob/...ient/cl_view.c
https://github.com/FWGS/xash3d/blob/...t/gl_backend.c
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ghostdlr
Senior Member
Join Date: Aug 2010
Old 12-04-2022 , 04:36   Re: Get map size (width and length) and player positions
Reply With Quote #9

The game doesn't show the overview and players properly though.
They appear to be moving inside the walls or even going out of the map all the time.

Are the coordinates displayed in bspviewer accurate?
I'm thinking I can make a list of coordinates on the counter-strike map and the coresponding pixel in the overview picture. (for example bomb sites, team bases, corners of the map)
Then I can calculate the places between.


I'm gonna give it a try but if it's too complicated and unreliable, I will probably give up. I thought it would be a lot more easier to do it.

bspviewer gives some errors (memory could not be read) and crashes sometimes ...

Last edited by ghostdlr; 12-04-2022 at 04:53.
ghostdlr is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 12-04-2022 , 05:56   Re: Get map size (width and length) and player positions
Reply With Quote #10

This is a little bit unethical but give netshark cs 1.6 cheat a try, they have overviews of the map with player locations pretty accurate, maybe you can figure out how to do it too.

My guess is that you can just set the origin of the map to be 0.0.0 aka center of an image, and set the boundaries to be the corners of the map(you can get the origins by manually going in the corners of the maps you want), and then u just draw the playerdot at closest_corner - player_location, sounds easy enough (it always does but then u get to do it...)

Also check this out too: https://forums.alliedmods.net/showpo...8&postcount=20

note that this will probably get ALL the corners even if unreachable by player.
__________________

Last edited by deprale; 12-04-2022 at 06:01.
deprale is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode