-- client side
bindKey("f", "down", function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
triggerServerEvent("onPlayerToggledInvisibility", localPlayer, vehicle)
end
end)
-- server side
function onPlayerToggledInvisibility(vehicle)
if vehicle then
local list = getElementsByType('player') -- we need to get every player so when can give a different message
for i, player in pairs(list) do
if player ~= client then -- if player we get is different from the one that trigger the server event
outputChatBox(getPlayerName(client) .. "pressed the f button", player) --to other player will show in chat that someplayer press F button
else
outputChatBox("you pressed the f button", client) -- to the player who pressed will show you pressed
end
end
end
end
its not good send localPlayer as argument to triggerServerEvent. If you want to use who trigger's it, on server side you can use client variable.