SA-MP Forums Archive
Fix for car variable WITH SetVehicleNumberPlate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fix for car variable WITH SetVehicleNumberPlate (/showthread.php?tid=416803)



Fix for car variable WITH SetVehicleNumberPlate - jakejohnsonusa - 18.02.2013

So I made this for my GM that would asign all vehicles in the owned car folder to load with a license plate that would have 3 letters and then their vehicle ID.

It worked, but the variable "ownedcar[m]" did not load, which ended up making them all appear as Unowned cars IG (and nothing about them would save to the folders after loading).


Here is the code, how can I fix this/change it so that it works?
pawn Код:
new PlatePossible[][] ={"AVI", "ZIS", "VYQ", "AUB", "IFQ", "SQU", "QUG", "PTR", "BRW", "CTI", "BTA", "DPF", "EAG", "FPA", "GJD", "HFI", "JTV", "KUB", "LPQ", "MAT", "NXT", "OFY", "RES", "TEH", "SVP", "VAW", "WHF", "XQW", "YGJ", "ZGO", "KDF", "LTS", "JOS"};
            new string[128];
            new randdr = random(sizeof(PlatePossible));
            format(string, sizeof(string), "%s - %d", PlatePossible[randdr], m);
            ownedcar[m] = SetVehicleNumberPlate(CreateVehicle(CarInfo[m][cModel],CarInfo[m][cLocationx],CarInfo[m][cLocationy],CarInfo[m][cLocationz]+1.0,CarInfo[m][cAngle],CarInfo[m][cColorOne],CarInfo[m][cColorTwo],60000), string);
*It works fine without the SetVehicleNumberPlate things, but when I add that it doesn't load them as owned cars.


THANKS in advance!
jakejohnsonusa

PS: I'll Rep you if you want/care about a rep


Re: Fix for car variable WITH SetVehicleNumberPlate - jakejohnsonusa - 18.02.2013

Thanks ******, but I don't honestly understand what that means. What should I do differently then?


Re: Fix for car variable WITH SetVehicleNumberPlate - Dubya - 18.02.2013

It basically mean change it to this
pawn Код:
SetVehicleNumberPlate(CreateVehicle(CarInfo[m][cModel],CarInfo[m][cLocationx],CarInfo[m][cLocationy],CarInfo[m][cLocationz]+1.0,CarInfo[m][cAngle],CarInfo[m][cColorOne],CarInfo[m][cColorTwo],60000), string);



Re: Fix for car variable WITH SetVehicleNumberPlate - jakejohnsonusa - 18.02.2013

But I need the created car to be "ownedcar" when it loads the car. So I can't just scrap that part. That's where I'm stuck, I need to keep that AND set the vehicle's plate.


Re: Fix for car variable WITH SetVehicleNumberPlate - iTorran - 18.02.2013

Create the vehicle under the variable ownedcar.
Then set the number plate using the variable you just saved the vehicle ID in to, then respawn the vehicle.


Re: Fix for car variable WITH SetVehicleNumberPlate - RajatPawar - 18.02.2013

You can assign different vars to the 'CreateVehicle thing' and then set the vehicle number plate so you know what car you set number plate of, and you can do whatever you want to with it. Maybe?


Re: Fix for car variable WITH SetVehicleNumberPlate - jakejohnsonusa - 18.02.2013

Thanks, that was it. (Sorry ******, I didn't relize that's what you meant).

Here's what I did:
pawn Код:
ownedcar[m] = CreateVehicle(CarInfo[m][cModel],CarInfo[m][cLocationx],CarInfo[m][cLocationy],CarInfo[m][cLocationz]+1.0,CarInfo[m][cAngle],CarInfo[m][cColorOne],CarInfo[m][cColorTwo],60000);
            SetVehicleNumberPlate(ownedcar[m], string);
            SetVehicleToRespawn(ownedcar[m]);
+1 For EVERYONE that helped, thanks guys!