eSPeZet Posted June 10, 2018 Share Posted June 10, 2018 (edited) Hello, I want to pass the Client-player with the function triggerServerEvent (for example to trigger an event and ONLY the client triggered the event so that ONLY HE would receive a message) and this is how i would do it: triggerServerEvent("blabla", localPlayer, bla) But MTA-wiki says the following sentence: Warning: You should use the global variable client serverside instead of passing the localPlayer by parameter or source. Otherwise event faking (passing another player instead of the localPlayer) would be possible. So I assume, that I shouldn't do it the way I just posted above, but I have no clue what they mean by this sentence and how else I should do it then.. Could anyone explain this WITH an example? Edited June 10, 2018 by eSPeZet Link to comment
Tails Posted June 10, 2018 Share Posted June 10, 2018 (edited) When a client triggers a server event a hidden variable called 'client' is passed in the event. triggerServerEvent("blabla", bla) -- server addEvent('blabla', true) addEventHandler('blabla', resourceRoot, function(bla) print(bla, getPlayerName(client)) end) Edited June 10, 2018 by Tails 1 Link to comment
eSPeZet Posted June 10, 2018 Author Share Posted June 10, 2018 (edited) ohhh wow that was simple thank you very much I didn't get it cause in the example script it said "the predefined variable 'client' points to the player who triggered the event and should be used due to security issues" And this made me wonder about how to "predefine" it Another question: HOW can anyone fake an event (in case we passed localPlayer)? How does this work? Edited June 10, 2018 by eSPeZet Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now