[Release] SecretCars > car only in local need to be fix

yeah i dont see anything wrong !

it has interiors but i think ur missing the metas thats why you cannot see it maybe thats causing it ??? try a different car and see

work fine for me idk …

I have the jumping issue @SorensenDK has mentioned. Say you have two players on a server, Player 1 and Player 2. The cars spawn on each of the players screens.

If Player 1 enters a vehicle and drives around, Player 2 does not see the car Player 1 is entering. Player 2 sees Player 1 spazzing out and jumping around.

The cars are only spawning locally for each client. You need to enable the isNetwork argument to true when spawning the car. However, I did that, but now it spawns multiple cars (one for each player).

I’m thinking (to avoid multiple cars) have a variable on the clients for something like areCarsSpawned. When the script wants to spawn the cars, it will check if that variable is true or not. Once the cars spawn once, it will trigger an event on the server and then trigger an event on all clients setting that variable to true (only causing it to spawn for the first person).

That could cause issues, however. For example, if you have two people loading at the same exact time (or if you restart the resource) the script will be run at the exact same time. So it will not have enough time to trigger the events and set the variable. Another check could possibly be added in to see if the car of that type exists at the location just to avoid the 2 people connecting at once issue.

@Streetcorps didn’t u fix this issue with the taxi resource ?

well if you can post the fix that would be cool because idk how and yes i got the same issue for the second player jumping in the car @GanjaMonster @SorensenDK

Are you talking about this ( [Release] Simple Taxi Work [UPDATED] )?

If so, I checked the code, and that doesn’t even spawn any cars. It only checked if you’re in a specific vehicle.

@Antoine, I can take a look into it. It is something I would like to do in my server as well. Just never really got around to doing it.

1 Like

it spawns two taxis at the downtown cab place but you would have to ask @Streetcorps

ok cool sound good i will be in touch

Unless he released a new script (which I can’t find), that script does not spawn taxis.

in one of the first version yes whit npc but its not there anymore

To spawn car you should use this script

local carmodel = GetHashKey("taxi")
							RequestModel(carmodel)
							while not HasModelLoaded(carmodel) do
								Citizen.Wait(0)
							end
							car = CreateVehicle(carmodel, x,y,z,a, true, false)
Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(car))

Do not forget Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(car)) , to clear memory.

1 Like

@MarkViolla - The issue is, we want to have cars spawn when the resources starts, but if there are multiple players, the car will spawn multiple times. Do you have any idea for how to do a check to make sure the car does not spawn more than once?

Yes, you create an event that you can trigger with a command, don’t give away the command , run it when the server is starting and thats it or add it as an admin command if you use em or if you created your own admin system

Yes. Look at mapmanager resource for information how it works.
I am from mobile,so i cant give you example.

@hbk I’d really prefer for it to be an automated process immediately on server start.

@MarkViolla I’ve tried adding in cars using the mapmanager, but it doesn’t even allow me to join the game.

@Briglair, Ok. Later. I know what to do.

@MarkViolla Awesome. Thanks, Mark!

ty guys for all that :stuck_out_tongue:

Easy: only spawn the car if there isn’t a car in the area already. I don’t know how migration handles this (if the car will be seen as existent, even), but IS_ANY_VEHICLE_NEAR_POINT could help.

1 Like