Raised This Month: $12 Target: $400
 3% 

Compass


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 08-11-2010 , 23:35   Compass
Reply With Quote #1

Compass


- What is it? -
To simply put it, this works like a compass. As you can see from the image above, this will change your HUD by adding an indicator which is in the area of the
cardinal directions. Additionally, it will also display which direction you are facing using the standard N 45W.

- Other Applications -
This plugin could be used for a GPS style plugin to find objects or players. For example, if you could grab a players angle to a flag in CTF, then this plugin could help you with where that flag is in relation to you without being able to see the location of the flag.

- CVARS -
Quote:
amx_compass <0/1> (Default: 1) //Enable/Disable plugin
amx_compass_method <0/1/2> (Default: 2) //Don't show angles/show 360 degree angle/show N 45W method
Attached Files
File Type: sma Get Plugin or Get Source (compass.sma - 1243 views - 2.8 KB)
File Type: sma Get Plugin or Get Source (compass2.sma - 1205 views - 3.1 KB)
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 08-12-2010 at 16:56.
Tirant is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-12-2010 , 00:35   Re: Compass
Reply With Quote #2

This should be in "New Plugin Submissions" and not in "Code Snippets/Tutorials".

Braces starting on Line 42 serve no purpose.
You shouldn't recreate variables on prethink if you can avoid it, you can use static variables instead.
You should try to minimize all native calls by caching values if possible (like cvars).
__________________

Last edited by fysiks; 08-12-2010 at 00:59.
fysiks is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 08-12-2010 , 00:48   Re: Compass
Reply With Quote #3

I don't consider this a full plugin worthy of submission, because I see no complete purpose to it. I just think it could be useful to anyone who might be making a GPS-style plugin where they need to find stuff. Like a geo-cache mod or locating a player. I think that this was better suited if somebody needed code for a compass, not as a single addon that is a compass. I mean, what the hell would that accomplish ingame other then knowing what direction you are facing.

While the braces on line 42 server no purpose to the code, they help my eyes see what part handles the actual angle->hud float conversions.

I cached one of the variables, but not the other because I didn't think it was necessary because it was only being questioned once.

What do you mean by recreating variables? Do you mean that I should make them all global?

Thank you for your comments, I really appreciate you taking your time to go through my code and help me.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-12-2010 , 01:04   Re: Compass
Reply With Quote #4

More:
There are two places that I see that a switch would be more efficient.

You should only need to do if(method) once because if method is 0 then nothing happens anyways (except for the very last hud message) so why do anything?

Also, it looks like when you are pointing only in one of the cardinal directions it uses whole words but if you move 1 degree then it switches to short names. So, this would make it look like the full names pop up every so often and not look consistent.

Quote:
Originally Posted by Tirant View Post
While the braces on line 42 server no purpose to the code, they help my eyes see what part handles the actual angle->hud float conversions.

I cached one of the variables, but not the other because I didn't think it was necessary because it was only being questioned once.

What do you mean by recreating variables? Do you mean that I should make them all global?

Thank you for your comments, I really appreciate you taking your time to go through my code and help me.
When you do something in prethink it is called thousands of times per second* so accessing a variable is much more efficient than retrieving the value again using a native. Besides, how often is a cvar going to change? It's definitely not going to change more than once per second or even minute or maybe even for the whole map. Personally, I would probably only read the cvars once per map or even on a new round event.

By recreating variables I mean that when you use "new" it creates the variable then when the function is complete the variable is destroyed. Repeat thousands of times per second*. You should be able to use static variabls.

* I'm not sure about the 1000 times per second but it's sure is a lot.
__________________
fysiks is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 08-12-2010 , 02:03   Re: Compass
Reply With Quote #5

Quote:
Also, it looks like when you are pointing only in one of the cardinal directions it uses whole words but if you move 1 degree then it switches to short names. So, this would make it look like the full names pop up every so often and not look consistent.
I tried to make it idiot-proof. I'll change the words to abbreviations.

I will also try and reduce the variables as much as I can.

Your suggestion for the switch was for the cardinal checks and the degree method?
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-12-2010 , 04:01   Re: Compass
Reply With Quote #6

Quote:
Originally Posted by Tirant View Post
Your suggestion for the switch was for the cardinal checks and the degree method?
Cardinal checks, yes. May be debatable elsewhere, I will have to look at it again later.
__________________
fysiks is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 08-12-2010 , 07:28   Re: Compass
Reply With Quote #7

Awesome plugin
Good JOB
__________________
alan_el_more is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-12-2010 , 08:01   Re: Compass
Reply With Quote #8

You gave me an idea with this plugin. I will release a good one soon.
Good job. And also good idea.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
aaarnas
Veteran Member
Join Date: Jun 2008
Location: Lithuania
Old 08-12-2010 , 14:46   Re: Compass
Reply With Quote #9

I was considering how to find a players, and this idea is awesome. Thanks.
__________________
My plugins:
[ZP] ZM_VIP (v2.0.0 is comming. v1.9.1 BETA is out!)

aaarnas is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 08-12-2010 , 16:21   Re: Compass
Reply With Quote #10

You would just have to find the angle your facing relative to their position. I assume adding in another HUD channel or something to mark their direction

Uploaded new version at first post.

I added the brackets that are there for no reason to know what code handles the horizontal movement. I had ambitions for adding in vertical ones as well. I guess I had a theory that this could work out to be a wallhack of sorts if need be, or a more accurate method of seeing your object.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 08-12-2010 at 16:58.
Tirant is offline
Reply


Thread Tools
Display Modes

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:55.


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