swag_k_dog Posted December 30, 2016 Share Posted December 30, 2016 so I made a window script to open when people join client: addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("noMoreHud", root) mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", root) destroyElement(mainWindow) destroyElement(playButton) end end end addEventHandler("onClientGUIClick", resourceRoot, buttonPress) server: addEvent("noMoreHud", true) addEventHandler("noMoreHud", resourceRoot, function() showCursor(source, true) showChat(source, false) setPlayerHudComponentVisible(source, "all", false) end ) addEvent("spawnPlayerPos", true) addEventHandler("spawnPlayerPos", resourceRoot, function() showCursor(source, false) showChat(source, true) setPlayerHudComponentVisible(source, "all", true) setElementPosition(source, 2245.70, -1260.03, 25.9) setElementFrozen(source, false) setCameraTarget(source) end ) I wanted when someone joins the server, the server script functions only apply to that someone. but when my friend joined the server, the function which hides my hud and makes the cursor visible applied to me too. how do I make the function only for him and not for the whole server? I want the server functions to apply to the player that joined the server. not the whole server thanks. Link to comment
Miika Posted December 30, 2016 Share Posted December 30, 2016 (edited) There's no need for triggerServerEvent("nomorehud"). You can do all that stuff in clientside; addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("noMoreHud", root) mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) setPlayerHudConponentVisible("all", false) showCursor(true) showChat(false) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", resourceRoot) destroyElement(mainWindow) destroyElement(playButton) end end end Btw, when you use triggerServerEvent(), use always 'client' instead of 'source' in server side function. And when triggering serverside event, use resourceRoot instead of root (that caused your problem) Edited December 30, 2016 by Miika822 Link to comment
swag_k_dog Posted December 31, 2016 Author Share Posted December 31, 2016 12 hours ago, Miika822 said: There's no need for triggerServerEvent("nomorehud"). You can do all that stuff in clientside; addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("noMoreHud", root) mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) setPlayerHudConponentVisible("all", false) showCursor(true) showChat(false) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", resourceRoot) destroyElement(mainWindow) destroyElement(playButton) end end end Btw, when you use triggerServerEvent(), use always 'client' instead of 'source' in server side function. And when triggering serverside event, use resourceRoot instead of root (that caused your problem) Okay so I wrote the code like this: client: addEventHandler("onClientResourceStart", resourceRoot, function() mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) setPlayerHudConponentVisible("all", false) showCursor(true) showChat(false) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", resourceRoot) destroyElement(mainWindow) destroyElement(playButton) end end end addEventHandler("onClientGUIClick", resourceRoot, buttonPress) and server: addEvent("spawnPlayerPos", true) addEventHandler("spawnPlayerPos", resourceRoot, function() showCursor(source, false) showChat(source, true) setPlayerHudComponentVisible(source, "all", true) setElementPosition(source, 2245.70, -1260.03, 25.9) setElementFrozen(source, false) setCameraTarget(source) end ) and it still does not work. the show hud false does not work. the hidechat does not work. and the showCursor true doesnt work either for the client script. welp? Link to comment
Dimos7 Posted December 31, 2016 Share Posted December 31, 2016 addEventHandler("onClientResourceStart", resourceRoot, function() mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) setPlayerHudComponentVisible("all", false) showCursor(true) showChat(false) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", resourceRoot) destroyElement(mainWindow) destroyElement(playButton) end end end addEventHandler("onClientGUIClick", resourceRoot, buttonPress) Link to comment
swag_k_dog Posted December 31, 2016 Author Share Posted December 31, 2016 8 minutes ago, Dimos7 said: addEventHandler("onClientResourceStart", resourceRoot, function() mainWindow = guiCreateWindow(0.05, 0.08, 0.89, 0.83, "", true) guiWindowSetMovable(mainWindow, false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.90) mainImage = guiCreateStaticImage(845, 18, 367, 611, ":freeroam_login/images/chick.png", false, mainWindow) mainText = guiCreateLabel(0.01, 0.04, 0.68, 0.13, "Welcome to San Andreas Online. This is a pre-alpha preview of the server.", true, mainWindow) playButton = guiCreateButton(0.88, 0.93, 0.12, 0.06, "PLAY", true) setCameraMatrix(1945, -1690, 67, 1902, -1602, 13) setPlayerHudComponentVisible("all", false) showCursor(true) showChat(false) end ) function buttonPress(btn, state) if btn == "left" and state == "up" then if source == playButton then triggerServerEvent("spawnPlayerPos", resourceRoot) destroyElement(mainWindow) destroyElement(playButton) end end end addEventHandler("onClientGUIClick", resourceRoot, buttonPress) thanks Link to comment
Miika Posted December 31, 2016 Share Posted December 31, 2016 Whoops, my bad. I wrote: setPlayerHudConponentVisible Instead of setPlayerHudComponentVisible 1 Link to comment
swag_k_dog Posted December 31, 2016 Author Share Posted December 31, 2016 3 hours ago, Miika822 said: Whoops, my bad. I wrote: setPlayerHudConponentVisible Instead of setPlayerHudComponentVisible ah 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