Hiding Posted August 19, 2023 Posted August 19, 2023 Hi, I would like to ask how can I check the player's serial on the server side and send it to the client? -- Server side function isPlayerAllowed(player) return allowedPlayers[getPlayerSerial(player)] ~= nil end -- Client side function handleKey(button, press) if not imagesEnabled and press and getKeyState("mouse2") then return false for i, allowedImage in ipairs(allowedImages) do if button == allowedImage.key then if isPlayerAllowed(localPlayer) then ... end end end end addEventHandler("onClientKey", root, handleKey)
Shady1 Posted August 19, 2023 Posted August 19, 2023 3 hours ago, Hiding said: Hi, I would like to ask how can I check the player's serial on the server side and send it to the client? -- Server side function isPlayerAllowed(player) return allowedPlayers[getPlayerSerial(player)] ~= nil end -- Client side function handleKey(button, press) if not imagesEnabled and press and getKeyState("mouse2") then return false for i, allowedImage in ipairs(allowedImages) do if button == allowedImage.key then if isPlayerAllowed(localPlayer) then ... end end end end addEventHandler("onClientKey", root, handleKey) --clientside function handleKey(button, press) if not imagesEnabled and press and getKeyState("mouse2") then return false end for i, allowedImage in ipairs(allowedImages) do if button == allowedImage.key then triggerServerEvent("checkPlayerAllowed",localPlayer) end end end addEventHandler("onClientKey", root, handleKey) --serverside function isPlayerAllowed(player) return allowedPlayers[getPlayerSerial(player)] ~= nil end addEvent("checkPlayerAllowed",true) addEventHandler("checkPlayerAllowed",resourceRoot, function() if isPlayerAllowed(client) then --whatever you do, write server side functions or do client operations with triggerClientEvent end end)
Shady1 Posted August 21, 2023 Posted August 21, 2023 13 minutes ago, Hiding said: Thank you so much! you're welcome
Recommended Posts