Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Coolkid on Jun 23, 2016, 04:41 PM

Title: vehicle id
Post by: Coolkid on Jun 23, 2016, 04:41 PM
how can i get vehicle id after creating it without sitting in it?

i am creating a vehicle system but i coulbot figure out how could i get vehicle id without sitting in it

Thanks in advance
Title: Re: vehicle id
Post by: Thijn on Jun 23, 2016, 04:44 PM
CreateVehicle returns the new vehicle created, so just get the .ID from that.
Title: Re: vehicle id
Post by: KAKAN on Jun 23, 2016, 05:27 PM
Take a look at this:-
local veh = CreateVehicle(...);
print( typeof veh );
Output: Instance
That means you can access/use all the properties/methods of that veh variable.
So, use: veh.ID to get its ID.
Title: Re: vehicle id
Post by: Coolkid on Jun 23, 2016, 08:07 PM
Quote from: KAKAN on Jun 23, 2016, 05:27 PMTake a look at this:-
local veh = CreateVehicle(...);
print( typeof veh );
Output: Instance
That means you can access/use all the properties/methods of that veh variable.
So, use: veh.ID to get its ID.
If I do vehicle count  then it will be also if I think
Title: Re: vehicle id
Post by: Thijn on Jun 23, 2016, 09:05 PM
Quote from: Coolkid on Jun 23, 2016, 08:07 PM
Quote from: KAKAN on Jun 23, 2016, 05:27 PMTake a look at this:-
local veh = CreateVehicle(...);
print( typeof veh );
Output: Instance
That means you can access/use all the properties/methods of that veh variable.
So, use: veh.ID to get its ID.
If I do vehicle count  then it will be also if I think
Why would you do that instead of just getting the ID directly? You have the vehicle instance...
Title: Re: vehicle id
Post by: Coolkid on Jun 23, 2016, 09:08 PM
I have 1 more question when vehicle explodes and respawn does it have same I'd or its is changes
Title: Re: vehicle id
Post by: DizzasTeR on Jun 23, 2016, 09:26 PM
ID remains same if it explodes and respawns
Title: Re: vehicle id
Post by: Coolkid on Jun 23, 2016, 10:25 PM
Quote from: Doom_Kill3R on Jun 23, 2016, 09:26 PMID remains same if it explodes and respawns
Thanks for sharing this info but thik in of I use vehicle count at the same time of creating vehicle will not it give me I'd exactly I am asking you this because I have already scripted whole car system and don't want to mess with it :(
Title: Re: vehicle id
Post by: Thijn on Jun 24, 2016, 06:02 AM
Quote from: Coolkid on Jun 23, 2016, 10:25 PM
Quote from: Doom_Kill3R on Jun 23, 2016, 09:26 PMID remains same if it explodes and respawns
Thanks for sharing this info but thik in of I use vehicle count at the same time of creating vehicle will not it give me I'd exactly I am asking you this because I have already scripted whole car system and don't want to mess with it :(
jesus. DON'T USE VEHICLE COUNT TO GET THE ID. USE Vehicle.ID
Title: Re: vehicle id
Post by: KAKAN on Jun 24, 2016, 08:30 AM
Well, that's because, Vehicle ID starts from 0 while vehicle count starts from one( I think so )
Title: Re: vehicle id
Post by: Xmair on Jun 24, 2016, 08:50 AM
Quote from: KAKAN on Jun 24, 2016, 08:30 AMWell, that's because, Vehicle ID starts from 0 while vehicle count starts from one( I think so )
Vehicle IDs start from 1 while GetVehicleCount starts from 0.