New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onClientVehicleEnter requires connection with server causing possibility to drive cars #1130
Comments
I'd recommend you to also set the vehicle engine state serverside. Never trust the client! |
Yeah, I did it, but when you start entering a car and you unplug your internet, onVehicleEnter won't trigger and you can't even block it clientside. I have another suggestion how to fix it - in server config could be start_vehicle_engine_on_enter default set to true determining if engine will start when you enter a car. Most of gamemodes other than race and freeroam would set it to false. It could be fixed now by getPedSimplest task attached to onClientRender - when it changes first time to entering a car, then script could get player's vehicle and turn off engine. In my opinion that event should work without connection with a server cause you could steal other players cars, destroy them etc. |
I noticed the above when reading your comment. Perhaps it is an idea to use https://wiki.multitheftauto.com/wiki/OnClientVehicleStartEnter |
This is really a non-issue as it can be solved by verification on the server, rather than client. |
It is a issue - you can drive every car and you can't block it by clientside and serverside. When you start entering a vehicle and you disconnect your internet cable, server events won't work because on the server your character will stay in one place. You can't even block it clientside with onClientVehicleStartEnter and onClientVehicleEnter because events will trigger AFTER you connect again your internet cable - after you move car with running engine by GTA - engine will be disabled after ~5 seconds of driving a car. |
You can use the |
local networkTimer = nil
local function networkStatusTimer()
local vehicle = getPedOccupiedVehicle(localPlayer)
local vehicleSeat = getPedOccupiedVehicleSeat(localPlayer)
if vehicle and vehicleSeat and vehicleSeat == 0 then
setVehicleEngineState(vehicle, false)
end
end
addEventHandler("onClientPlayerNetworkStatus", localPlayer, function(status, ticks)
if status == 0 then
if isTimer(networkTimer) then
killTimer(networkTimer)
end
networkTimer = setTimer(networkStatusTimer, 500, 0)
else
if isTimer(networkTimer) then
killTimer(networkTimer)
end
end
end) Works fine but in my opinion should be fixed in MTA or at least adding information on the wiki. |
Copying my text from Discord:
|
Describe the bug
Clientside onClientVehicleEnter requires connection with server. If player try to enter car and disconnect his internet cable, he can drive cars even if your clientside script is turning off engine. This can cause problems for RPG servers, where every player has his own car and can enter open cars without freeze - he can move them without permission.
To reproduce
Expected behaviour
Engine sould turn off.
Version
Multi Theft Auto v1.5.7-release-20288 - client
MTA:SA Server v1.5.7-release-18957 - server
The text was updated successfully, but these errors were encountered: