[help] Why wont this work?

for some reason i can not get this to work idk what im doing wrong new to this sorry:D

Client.lua

RegisterNetEvent( 'engineoff' )
AddEventHandler( 'engineoff', function()
		local ped = GetPlayerPed(-1)
		local playercar = GetVehiclePedIsUsing(ped)
			if ped == playercar then
				SetVehicleUndriveable(playercar, true)
				SetVehicleEngineOn(playercar, false)
				ShowNotification("~g~The engine of this vehicle is off.")
			end
		end
	end
end)

-- Shows a notification on the player's screen 
function ShowNotification( text )
    SetNotificationTextEntry( "STRING" )
    AddTextComponentString( text )
    DrawNotification( false, false )
end

Server.lua

-- Add an event handler for the 'chatMessage' event
AddEventHandler( 'chatMessage', function( source, n, msg )  

    msg = string.lower( msg )
    
    -- Check to see if a client typed in /
    if ( msg == "/engineoff" or msg == "/EngineOff" ) then 
    
        -- Cancel the chat message event (stop the server from posting the message)
        CancelEvent() 

        -- Trigger the client event 
        TriggerClientEvent( 'engineoff', source )
    end
end )
```





thanks for the help

It burns my tired eyes, you are just comparing a vehicle to a player :
GetPlayerPed returns your ped entity, and GetVehiclePedIsUsing returns the last used/actually used vehicle.

So remove the if, as it makes no sense

so just remove the whole if

and sorry about hurting your eyes xD

Edited Original post with code tags.

Does this even work anymore? seems like it wont.

nah i could not get it to work
but theres other ways to do it

whats the other ways, do you know

If you are actually using essential mode (no matter the version) you should use it as a base :

TriggerEvent('es:addCommand', 'jobadd', function(source, args, user)


	if user.permission_level <= 5 then
		TriggerClientEvent("izone:notification", source, "Tu n'as pas la permision de faire cela, 5 nécéssaire.", false)
		CancelEvent()
	else
		if #args ~= 3 then
			TriggerClientEvent("izone:notification", source, "Ustilisation /jobadd Bucheron serverId ou /jobadd SansEmplois serverId", false)
			CancelEvent()
		else
			if type(args[3]) == type(0) then
				TriggerEvent("es:getPlayerFromId", args[3], function(targetUser)
					if allJob.args[2].name ~= nil then
						if targetUser ~= nil then
							TriggerClientEvent("izone:notification", source, "Le job " .. allJob[i].name .. " a été appliqué au joueur donné.", true)
							--TriggerClientEvent("ijob:addjob", args[3], allJob[i].name) innutil maintenant
							allJob[args[2]]:addEmploye(targetUser.identifier, args[3])
							CancelEvent()
						else
							TriggerClientEvent("izone:notification", source, "iJob ne trouve pas le joueur demandé.", false)
							CancelEvent()
						end
					else
	 					TriggerClientEvent("izone:notification", source, "iJob ne trouve pas de job correspondant a ta demande.", false)
						TriggerClientEvent("ijob:displayjobname", source)
						CancelEvent()
					end
			else
				TriggerClientEvent("izone:notification", source, "iJob attend un chiffre en deuxième argument.", false)
				CancelEvent()
			end
		end
	end

end)

No matter what is in there, just remember that : (I show you that so you can understand the verification I done and so you have an example)

TriggerEvent('es:addCommand', 'YourCommandWithoutSlash', function(source, args, user)
 -- Note that #args (lenght of arguments contain the command, like /jobadd test test : args = {"jobadd", "test", "test"}
end)

I hope it’ll help you :slight_smile:

vehicle controls is the best for my opinion

yeah but that saves your vehicle and stuff :confused:

what do you mean?? you click m it gives you those options for the vehicle you are in or the last one