'LinKin Posted December 31, 2013 Share Posted December 31, 2013 Hello, I customized a community script which disables the car-smoke. So, when I type /dissmoke [player] it disables the car-smoke for that player ONLY. But I'm having one trouble, when I perform that command, it disables the car-smoke of EVERY player. This is part of the script: Clientside: addEvent("sync:forceSmoke", true) addEventHandler("sync:forceSmoke",root,toggleSmoke) Serverside: selectedPlayer = getPlayerFromName(theTarget) triggerClientEvent("sync:forceSmoke", selectedPlayer) I believe it is because of the 'root' in the clientside script; However, I'm not sure... How can I make it so that it only turns off the car-smoke of the selected player? Thanks, - Linkin. Link to comment
TAPL Posted December 31, 2013 Share Posted December 31, 2013 This is first argument (Optional). sendTo: The event will be sent to all players that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player. This argument can also be a table of player elements. triggerClientEvent(selectedPlayer, "sync:forceSmoke", selectedPlayer) Link to comment
'LinKin Posted December 31, 2013 Author Share Posted December 31, 2013 Thanks TALP. I just found out that in another script I made, I had a similar trouble, so instead of writting 'root' in the clientevent, I wrote getLocalPlayer() and it worked.. What do you say about this getLocalPlayer() ? Link to comment
Renkon Posted December 31, 2013 Share Posted December 31, 2013 getLocalPlayer can be used only when using triggerServerEvent as it's client-sided. What you can use is MTA-var 'client' Link to comment
TAPL Posted December 31, 2013 Share Posted December 31, 2013 Thanks TALP.I just found out that in another script I made, I had a similar trouble, so instead of writting 'root' in the clientevent, I wrote getLocalPlayer() and it worked.. What do you say about this getLocalPlayer() ? This also will work but it's not the right way to do because if you didn't put the first argument of triggerClientEvent it will be by default root which mean it will send packet to every player in the server but the event in the client side will be active only for the source of the trigger event because you attached the event to localPlayer. 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