Find Player by Number Plate?
#2

I've made some pseudo code for you here that might help you in figuring it out, it's got a bit of an explanation:

pawn Код:
Command findcarp
{
    Do checks if they are a cop or whatever you want to check here before they can use the command
    Show the dialog here asking the user to enter the car plate
}

Dialog response
{
    Check if the dialog is equal to the dialog ID that you used for the command
    {
        Create a variable that will store the ID of the vehicle (e.g. new vehid;)
        Set vehid to -1, you will understand why later
        Create a loop that will go through all the vehicle information (CarInfo)
        {
            Use strcmp (compares if two strings are equal) to check if the inputtext is equal to the plate on the vehicle
            {
                If so, set vehid to the variable used by the loop (like, for(new i = ...), the variable used by the loop is i)
                break the loop here to avoid lag and waste of time
            }
        }
        Remember when we set the vehid to -1? Check if the vehid variable is still equal to -1
        {
            Tell the user that no vehicle exists with that ID
        }
        Otherwise, if it is not equal to -1 anymore (i.e. a vehicle has been found)
        {
            You can simply use vehid as you have done for "idx" in LoadCars, "c" in LoadMyCar, just as what the vehicle ID is
            Here is a quick example that might help you:
            Send a client a message with cOwner by using: CarInfo[vehid][cOwner];
            On your LoadMyCar stock it would have been used as: CarInfo[c][cOwner]; as c is what determines the record if you will
            Notice how I used vehid there.
            Do whatever you want here (right after the last { and the next }), add dialogs blabla using the vehid
        }
    }
}
strcmp documentation: https://sampwiki.blast.hk/wiki/Strcmp

Fun fact: I had this idea too back in the day for police members, such as enabling an ANPR system (Automatic Number Plate Recognition) on specific police vehicles with objects such as cameras all around the vehicle and if anyone was to drive past (or even if the car was empty and was not in a garage or a secure location) something like this would appear (of course not fully on the screen, but a little less details and some information regarding the problem): http://www.radcommuk.co.uk/images/an...r-software.jpg

I completely forgot about this idea, if you wanna use it feel free, I'll probably think of a new one and implement it on my server a little later. Can't be bothered using this now.
Reply


Messages In This Thread
Find Player by Number Plate? - by SweetRP - 27.02.2015, 18:08
Re: Find Player by Number Plate? - by DanishHaq - 27.02.2015, 23:30
Re: Find Player by Number Plate? - by InglewoodRoleplay - 28.02.2015, 00:11
Re: Find Player by Number Plate? - by SweetRP - 28.02.2015, 00:27
Re: Find Player by Number Plate? - by SweetRP - 28.02.2015, 09:31
Re: Find Player by Number Plate? - by ball - 28.02.2015, 09:41
Re: Find Player by Number Plate? - by SweetRP - 01.03.2015, 17:47

Forum Jump:


Users browsing this thread: 1 Guest(s)