Hello guys, I was wondering how can I approach this: so if a player presses the f button, and if it was the source, who pressed the button then it should say "you pressed the button" otherwise "playername pressed the f button". My question is how can i get the owner of the presser? So if I press the F button then I should know that it was by me, but for others they should know that it was also me. I hope it's clear I need the the source's localPlayer on server side. (I guess)
-- client side
bindKey("f", "down", function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
triggerServerEvent("onPlayerToggledInvisibility", localPlayer, vehicle, localPlayer)
end
end)
-- server side
function onPlayerToggledInvisibility(vehicle, localPlayer)
if vehicle then
if source == localPlayer then
outputChatBox("you pressed the f button")
else
outputChatBox(getPlayerName(source) .. "pressed the f button")
end
end
end
addEvent("onPlayerToggledInvisibility", true)
addEventHandler("onPlayerToggledInvisibility", root, onPlayerToggledInvisibility)