Serverside for SetPedControlState
Is your feature request related to a problem? Please describe.
In Client, you can make NPCs press or release certain buttons to do actions. You can't do it on server since its only client-sided.
Describe the solution you'd like
Making SetPedControlState a shared function.
Describe alternatives you've considered
No response
Additional context
https://wiki.multitheftauto.com/wiki/SetPedControlState
Security Policy
- [x] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
If someone wants to add this I don't see an issue, but this can be achieved easily in Lua without (m)any tradeoffs compared to a 'native' shared function.
Server code
triggerClientEvent(players, "onPlayerRPC", resourceRoot, "setPedControlState", ped, "fire", true)
Client code
function handleRPC(proc, ...)
local func = _G[proc]
if (type(func) ~= "function") then
return
end
func(unpack({...}))
end
addEvent("onPlayerRPC", true)
addEventHandler("onPlayerRPC", resourceRoot, handleRPC)
You can now also use this for any other function which is available on client, but not server. If you needed the return value it could be achieved with a secondary event back to the server and the use of a callback function. Of course, this is where a native shared function serves a better purpose.
If someone wants to add this I don't see an issue, but this can be achieved easily in Lua without (m)any tradeoffs compared to a 'native' shared function.
Server code
triggerClientEvent(players, "onPlayerRPC", resourceRoot, "setPedControlState", ped, "fire", true)Client code
function handleRPC(proc, ...) local func = _G[proc] if (type(func) ~= "function") then return end func(unpack({...})) end addEvent("onPlayerRPC", true) addEventHandler("onPlayerRPC", resourceRoot, handleRPC)You can now also use this for any other function which is available on client, but not server. If you needed the return value it could be achieved with a secondary event back to the server and the use of a callback function. Of course, this is where a native shared function serves a better purpose.
You only have to send it to whichever player is being returned by getElementSyncer even. Very easy to implement yourself but I do agree that it's nice to have on the server nevertheless.