Anubhav Posted August 17, 2014 Posted August 17, 2014 Hello everyone!, I want to ask that, how to trigger a event only for a player? It should render something only FOR HIM. My server side code: addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source,"createGUI", root) -- will it only trigger for him? D: end ) I'm not showing my full client sided code due to script leakings! My client side code: function startRendering(forWhom) local whoToRender = forWhom or lp addEventHandler("onClientRender", whoToRender, render) end addEvent("createGUI", true) addEventHandler("createGUI", root, startRendering) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Arnold-1 Posted August 17, 2014 Posted August 17, 2014 it should work, did you test it with multiple people? Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 I'll test it soon with multiple people. I will reply tommorow maybe. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 Another doubt: function startRendering() guiSetVisible(windowOne, true) end addEvent("createGUI", true) addEventHandler("createGUI", root, startRendering) So will it set the window visible for everyone? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
DNL291 Posted August 17, 2014 Posted August 17, 2014 Depends on who you'll trigger the event. If you call the function startRendering(), it will execute the function for each client. Please do not PM me with scripting related question nor support, use the forums instead.
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 Can you give me a example for only the player who loginned? :-/ See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
DNL291 Posted August 17, 2014 Posted August 17, 2014 Actually, your server-side code above is correct, but the another one is wrong. Use this one: function startRendering() addEventHandler("onClientRender", root, render) end addEvent("createGUI", true) addEventHandler("createGUI", root, startRendering) It should work. Please do not PM me with scripting related question nor support, use the forums instead.
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 If I use guiSetVisible instead of addEventHandler( I removed dx functions. ), will it only be for that plr? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
DNL291 Posted August 17, 2014 Posted August 17, 2014 If I use guiSetVisible instead of addEventHandler( I removed dx functions. ), will it only be for that plr? Yes, of course. But like I said, if you call startRendering without calling it for a specific player, the function will be called for all clients. Please do not PM me with scripting related question nor support, use the forums instead.
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 So if I do like this: lp = localPlayer or getLocalPlayer() addEventHandler("onClientPlayerJoin", root, function() startRendering(lp) end ) correct? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
DNL291 Posted August 17, 2014 Posted August 17, 2014 That function will be called for all players except the local player. This event is triggered when a player joins a server. It is triggered for all players except the local player, as the local player joins the server before their client-side resources are started. If that is what you want then it's right. By the way, lp = localPlayer or getLocalPlayer() is useless. Change it to: lp = localPlayer Please do not PM me with scripting related question nor support, use the forums instead.
#DRAGON!FIRE Posted August 17, 2014 Posted August 17, 2014 You do not have to do anything in Client .. because u sent the trigger For Player and Client just for local player To Contact Me at Skype : [email protected]
Anubhav Posted August 17, 2014 Author Posted August 17, 2014 If I do it like this: SERVER: [lua] addEventHandler("onPlayerJoin", root, function() triggerClientEvent(source, "createGUI", root, source) end ) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
#DRAGON!FIRE Posted August 17, 2014 Posted August 17, 2014 trigger will send just to player because in First arg u put player .. and arg 3 it's the source of event To Contact Me at Skype : [email protected]
DNL291 Posted August 17, 2014 Posted August 17, 2014 If I do it like this:SERVER: addEventHandler("onPlayerJoin", root, function() triggerClientEvent(source, "createGUI", root, source) end ) You can pass the player element as the source of the event instead of an argument. Please do not PM me with scripting related question nor support, use the forums instead.
Arnold-1 Posted August 17, 2014 Posted August 17, 2014 Do you understand that a client can't affect another client at all? Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Saml1er Posted August 17, 2014 Posted August 17, 2014 (edited) addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source,"createGUI", source) -- due to first argument, this will trigger for 1 player and 3rd argument is for specifying source of the évent end ) local function startRendering () dxDrawText(...) end addEvent("createGUI",true) addEventHandler("createGUI", root, function() addEventHandler("onClientRender", root, startRendering ) end ) EDIT: I changed the event name to "createGUI". I have no idea how I missed this Edited August 18, 2014 by Guest
Et-win Posted August 18, 2014 Posted August 18, 2014 Stuff. This event is triggered when a player joins a server. It is triggered for all players except the local player As soon as a client joins the server, you just can use 'onClientResourceStart' (Remember to use the resource-root, not root! (Otherwise it will start by every resource that gets started)) or put: functionname() to start the function. Why? Because when she/he joins, the scripts get started. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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