Jump to content

!carloc on MTA:VC


Guest newman123

Recommended Posts

hello people!

I need a car locations script for my server but don't know how to make it. can someone help me please? something so that when someone types !carloc (car name) or something similar, it says where the car was last seen. I heard this can be done by recording the co-ordinates of the last person to exit the vehicle, but i don't know how to do this. any help would be great :)

thank you!

Link to comment

i wouldn't recommend even attempting to make a script like this. I have one coded by myself on our stunt server and because of the way the server engine works, it doesn't work well for newly joined players.

You are correct when you say you can record it's location when someone exits; however, to my knowledge of the way the 0.5 core works, when a new player joins, they see all cars at spawn unless a player is in it (ie: if a car was exited at south of the map and it's original spawn was north, if a new player joined and noone was in the vehicle they would see it in the north).

It works "ok" for players who were in the server at the time someone exited the vehicle, but i wouldn't use it for general usage.

Now, if the server engine is where the current car locations were kept (memory), then we might have a different story (being client side though causes that issue).

The only way around this i see is by calculating when the player exited the vehicle, and when the player initiating the !carloc joined the server. So, if that player joined after the carloc entry was added, then give them the location of where it spawns. Therefore, if they joined the server before the carloc entry was added (so if they were in game whilst someone exited), give them the coords that are in a database you have made).

Of course, this would only work if the player is actually in game, and not just connected to the server :)

- Bungle

Link to comment
  • 2 weeks later...

Hey,

Yes that is true. Though there is a way to fix that. Possible make it seperate for each player, though that would use alot of CPU and resources. Not to mention alot of scripting.

Cya,

[XE]Tommis

Link to comment

I agree with Tommis's point about the un-necessary activity that would be required on the CPU, though not because of it being separate players (i have noted this below). I don't feel it's a feature worth attempting for the reason of the points that i mentioned both in my first post and the paragraph following the below code example.

on *:signal:mta.command: {
 ;check if cmd is !carloc
    ;check if the car is in use by someone now
    ;(if true, return the location of the driver)
    ;else goto below code
        ;check if there is an entry for when the last person used it
          ;(if there is, compare it against when the player joined the server)
            ;if player joined after entry was added, they will see it at spawn,
             so return default location
            ;else we'll assume they were in game when the entry was added,
             so they should see it at the coords that are in the database
          ;else if there isn't an entry, assume the car has yet to be used, so
           should still be at default spawn location
}

That is basically how i see it, though i don't see any point writing a whole script because i don't see it actually being worthwhile. There are 2 ways of doing it though; 1) using car IDs (much easier from a scripting perspective), 2) using actual car names (starts to get icky).

If you use CarIDs in the !carloc command (so search for a exact car), you can simply reference the number with the database and check if there is a match. However, if you use car names, not only will you have to convert it to an ID, but also it would then have to calculate the current location of every vehicle that matches that name, and return the result of the one which is the closest to the player upon executing that command. Whether that is what you meant by "CPU Intensive" tommis, possibly, as that is only reason why i would think it would be intensive on the processor.

My script uses CarIDs, so players simply have to remember which ID the car they want to find is.

This also assumes, as i mentioned in my first post, that the player executing the command is actually in game, and if they have just come in game, but had been connected to the server for a significant amount of time, additional code would be required to check if their status has only recently become ingame (again, that may require a constant timer for every player which also adds to the CPU load as Tommis pointed out).

Basically my point is, to get a good script of this is certainly not worth the effort, at all :)

- Bungle

Link to comment

I think this is in GRS, but when I had it enabled on my stunt server (which was really popular), it was an overused command and frequently crashed the mirc which was hosting it, so I disabled it. It is a very CPU intensive script.

Link to comment
and return the result of the one which is the closest to the player upon executing that command.

Just judging which is the closest is a whole problem in itself, one may be closer geographically yet actually be the furthest away! If it is over the water on the other island for example.

Link to comment
one may be closer geographically yet actually be the furthest away!

That is a good example about not being a feasable script (although i admit, i never thought of that, but it still validates my point) :P

I suppose if you returned a list of cars that were closest (say the closest 3), it might be a workaround for that, but again that is adding additional workload to the scripter and the CPU which is un-necessary.

I am not a fan nor a user of GRS so i can't comment on the the script which is included within it, but if you say that it is CPU intensive, i suppose that speaks for itself.

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...