Check vehicles nearby
#7

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
No. I'd not update anything. I don't mind if server has to store some floats in memory. When starting the server vehicles will be created at those coords, the coords will get stored in the vehicle's enum after that, so you can use the same coords to check if you are near a vehicle of those without stocking around. Also you are forgetting that you will have the vehicle to respawn not only when it gets destroyed, but also when someone rams that car away. You would use another stock to respawn it, I'd use a "simple" for() and whenever the coords arent the same the car will get respawned. Keep it clean.
Let's not make any assumptions since we don't know how this guy is writing his gamemode. So let's take a common case in a server where vehicles don't respawn until they are destroyed. A player gets in the vehicle, drives 100 units away. Now your script will not only NOT detect when the player is near the vehicle, but will also DETECT when they are next to the original cords WITHOUT the vehicle there.

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Am sorry, but you did something similar.


there could be many cars with the same id, or he could need to check all of them to make moved cars respawn. This will make script getvehiclepos n times, and check the range of point n times. What's wrong with that? That you need to get the position everytime creating new floats everytime, and then do the checking. This ain't memory cheap thing at all. I prefer having my enum so the checkings are less, used functions are less. Also, you check MAX_VEHICLES regardless if the server has only 50 cars around.
My code checks the distance AFTER verifying 1) it's a valid vehicle and 2) it's the correct model. Lets say there are 20 FBI ranchers in the server. Mine will compare the distance between those 20 vehicles, not all 1000 like yours. You should also break out of the loop when a valid match is found.

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Technically this is true, but has zero bearing on the output of the compiled code. In fact, I think the function will simply be excluded from the compiled source if not used at all. It's nit-picky (which I used to be as well) but hardly an "issue". I could complain about no use of Hungarian notation, improper use of the static keyword, no use of the const keyword, people misidentifying pawn as having types (ints, floats, strings, etc), but I'd rather stick to what is more important.
Reply


Messages In This Thread
Check vehicles nearby - by Drak03 - 26.03.2018, 12:55
Re: Check vehicles nearby - by v1k1nG - 26.03.2018, 13:32
Re: Check vehicles nearby - by Grim_ - 26.03.2018, 13:48
Re: Check vehicles nearby - by v1k1nG - 26.03.2018, 14:55
Re: Check vehicles nearby - by Grim_ - 26.03.2018, 15:01
Re: Check vehicles nearby - by v1k1nG - 26.03.2018, 15:26
Re: Check vehicles nearby - by Grim_ - 26.03.2018, 15:41
Re: Check vehicles nearby - by v1k1nG - 26.03.2018, 16:05
Re: Check vehicles nearby - by Lokii - 26.03.2018, 16:27
Re: Check vehicles nearby - by Grim_ - 26.03.2018, 17:32

Forum Jump:


Users browsing this thread: 3 Guest(s)