Racing script troubles

Clear as the sky on a cold winter morning somewhere in Siberia. BUT. Could you explain, please, how is it relate to IsEntityVisibleToScript native? Native itselfs checks if a vehicle visible and returns 1 or false (prints above prove that). Or are you hinting that I need to make a new variable?

Nvm. I tried to do something like this


and it worked out…
UPD: I just can’t get HOW? It works with IsEntityVisibleToScript(GetVehiclePedIsIn(PlayerPedId(), 1)) in one place but doesn’t work in another :thinking: There’s an if in line 126 too :thinking:
UPD2: Or if in line 126 and if here - are different things?
UPD3: IsEntityVisibleToScript(GetVehiclePedIsIn(PlayerPedId(), 1)) checks if it returns 1, right? And IsEntityVisibleToScript(GetVehiclePedIsIn(PlayerPedId(), false)) checks if it returns false. The main question is why it doesn’t work in line 263 as I supposed?


Tried something on my own :grin: (red timer delay). Is it correct?

I’ve made the script add penalty time to finishTime when race is finished. Ms were displayed correctly but as it compares two finishTime variables and there wasn’t + raceState.penaltyTime, script counted that the Lancer was first (in fact it bumped several times and get those +500 extra ms, which were added to ms but not to finishTime, I guess)

No, that’s incorrect. Check the description of the native GetVehiclePedIsIn(). The 1 or false only will matter for peds entering or exiting a vehicle.
This should also hopefully clear up the question how the code works.
Btw:
if not IsEntityVisibleToScript(GetVehiclePedIsIn(PlayerPedId(), 1)) then would be a nicer line.

1 Like

Does it work? If yes it is a nice solution :smiley:
So now your code does the following:
It checks every frame for collisions, adds 99 ms of penalty time and pauses for 100 ms before resuming the check. The timer will display red for 3 seconds.
Please note that multiple collisions in a short time frame will still see the timer turn white after 3 seconds. E.g. you have a collision at t = 0 s and a collision at t = 1 s. The timer will turn white at t = 3 s, the second collision would demand it turn white at t = 4 s. But that shouldn’t be too much of a problem.

So the time comparing issue is fixed as well?

Yep! I see no problems with scoreboards on my server for now.

Works as intended, all credit goes to you of course :grin:
I can barely describe how I’m grateful for your help, time, all these detailed instructions and explanations… damn, I even started to think that you are a teacher or something like that (especially after 29th post).
Anyway, I’ve learned a lot of new things, tips and tricks during all this time while we were trying to figure out how to fix all this mess, so thanks again!

1 Like

@Silverman
It’s me again :sweat_smile:
Got 1 more problem: players can push each other during countdown saving 5-10 secs by that, kinda unfair to others. “SetEntityNoCollisionEntity” makes vehicle fall through the ground so I don’t know how to disable vehicle to vehicle collision only. Any tips?

Do you have a video for me showcasing the problem? Or do you mean players not in the race pushing racing players?

I’m searching for the way to disable collision only till countdown ends to prevent such things.

Search through the FiveM native reference to see what could possibly solve your problem. In this case I already searched, only linking you one native though. There might be better options :stuck_out_tongue:

The FiveM native reference is your best tool to solving such problems. As you are in need of a native for vehicles check out the vehicle category :slight_smile:

EDIT: On further note you might wanna consider the entity category too. However it might be best to “ghost” the vehicle entirely if you are going for fair time trials. I don’t know how that works at all though so you are on your own there.

#1
Well, I tried something, first look at this: :) - YouTube
As you can see I used SetLocalPlayerAsGhost(PlayerPedId(), true) also I tried SetNetworkVehicleAsGhost(GetVehiclePedIsIn(PlayerPedId()), true) and both work but… I can’t find a native to disable it. False or 0 don’t work for me sadly. I wonder if there is even a way to disable it…
FreezeEntityPosition also works for me but ghost mode is preferable ofc as I want to avoid players bump each other during time trials not only during the countdown.

#2
I use this awesome script (SimplePassive: Passive Mode in your FiveM server, just like in GTA:O) for passive mode whenever a player wants it on. The main problem of this script is the auto-adjustment of the camera when you go through another player in passive mode. It’s like the camera has collision with other entities. DisableCamCollisionForObject(or ForEntity as there are 2 natives) doesn’t work :frowning:

Sorce code -
Lines that have been edited by me: 171, 222, 250, 265

1 Like

can you post the no collision code in the video? I have one but it also bugs de camera collision, in the video your code looks perfect

well, let’s check whether the native works as intended or not. For this write a small code that you can use to verify what works and what doesn’t:

The easiest way is:
Create a new, small resource. Put in a code, that upon start of the resource ghosts your vehicle for 10 seconds, then unghosts it. Like this:

CreateThread(function()
  local ped = PlayerPedId()
  local veh = GetVehiclePedIsIn(ped, false)

  SetNetworkVehicleAsGhost(veh, true)

  Wait(10000)

  SetNetworkVehicleAsGhost(veh, false)
end)

Have fun testing for a bit. When you figured out a native that works with the above code, you can try and start working on your code. For now: The lines you have mentioned are in a few while-loops. The native you use only needs to be called once. I suspect that your issue lies here.

EDIT: Also please fix your codeshare. The indenting of the code looks horrible in there, can barely read the code :smiley:

My bad! Won’t use codeshare anymore :sweat_smile:
It worked, btw! The problem was indeed with the place where I decided to put this native (I hate my carelessness too).
Unfortunately, DisableCamCollisionForObject//ForEntity doesn’t work. I think I’ll remove that script and just put this ghost function in server menu as an option.

I’ll surely release it on public as soon as it will be done. (And if the owner of this script will allow me to do this)

Hello, I am here cuz I have the same issues and I wonder if u can give me the nessecery scripts to get that reach that objective that u made.
Btw u did a good job, very understandable questions and reponses.

how to fix camera collision? Anyone has idea for that?

2 Likes