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