waqaarali Posted March 9, 2013 Share Posted March 9, 2013 Ok so i am making a simple rpg gamemode and so i started with a spawner ! I made a simple one! Ok so i made some of the script and i just want to make like when the player pressess the button e.g Spawn Los Santos he spawns at the front of cityhall !! Ok so here is the script.... GUIEditor = { button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(205, 151, 406, 323, "Spawner By Gangsta", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(25, 55, 145, 58, "Spawn In Los Santos", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(236, 55, 161, 60, "Spawn In San Fransisco", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(138, 179, 149, 103, "Spawn in LV", false, GUIEditor.window[1]) end ) Link to comment
Castillo Posted March 9, 2013 Share Posted March 9, 2013 Client side: onClientGUIClick triggerServerEvent Server side: addEvent addEventHandler spawnPlayer Link to comment
waqaarali Posted March 9, 2013 Author Share Posted March 9, 2013 do i add it to the same script? Link to comment
iPrestege Posted March 9, 2013 Share Posted March 9, 2013 Yes And Create New File Server Side . Link to comment
waqaarali Posted March 9, 2013 Author Share Posted March 9, 2013 I tried to do it but it didn't work SERVER SIDE function spawnPlayer () spawnPlayer ( playerValue, 1487, -1744, 14, 90.0, 0 ) end addEvent ( "spawnPlayer", true ) addEventHandler (spawnPlayer, GUIEditor.button[1], onClientGUIClick) Client Side addEventHandler( "onClientResourceStart", getRootElement( ), GUIEditor = { button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(205, 151, 406, 323, "Spawner By Gangsta", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(25, 55, 145, 58, "Spawn In Los Santos", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(236, 55, 161, 60, "Spawn In San Fransisco", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(138, 179, 149, 103, "Spawn in LV", false, GUIEditor.window[1]) end ) function() triggerServerEvent ( "spawnPlayer", getLocalPlayer() ) end Link to comment
iPrestege Posted March 9, 2013 Share Posted March 9, 2013 -- Client -- GUIEditor = { button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(205, 151, 406, 323, "Spawner By Gangsta", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(25, 55, 145, 58, "Spawn In Los Santos", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(236, 55, 161, 60, "Spawn In San Fransisco", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(138, 179, 149, 103, "Spawn in LV", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick",root, function () if ( source == GUIEditor.button[1] ) then triggerServerEvent("Spawn[1]",localPlayer) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("Spawn[2]",localPlayer) elseif ( source == GUIEditor.button[3] ) then triggerServerEvent("Spawn[3]",localPlayer) end end ) -- Server -- addEvent("Spawn[1]",true) addEventHandler("Spawn[1]",root, function () spawnPlayer(source,x,y,z) end ) addEvent("Spawn[2]",true) addEventHandler("Spawn[2]",root, function () spawnPlayer(source,x,y,z) end ) addEvent("Spawn[3]",true) addEventHandler("Spawn[3]",root, function () spawnPlayer(source,x,y,z) end ) Replace : x,y,z = you're position for : Spawn[1] = GUIEditor.button[1] Spawn[2] = GUIEditor.button[2] Spawn[3] = GUIEditor.button[3] Try it. Link to comment
waqaarali Posted March 9, 2013 Author Share Posted March 9, 2013 Also i made a button GUIEditor.button[4] = guiCreateButton(15, 178, 50, 25, "Quit", false, GUIEditor.window[1]) When the player presses the button the gui Closes how can i do this? Link to comment
waqaarali Posted March 9, 2013 Author Share Posted March 9, 2013 but where do i add it? GUIEditor = { button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(205, 151, 406, 323, "Spawner By Gangsta", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(25, 55, 145, 58, "Spawn In Los Santos", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(236, 55, 161, 60, "Spawn In San Fransisco", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(138, 179, 149, 103, "Spawn in LV", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(15, 178, 50, 25, "Quit", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick",root, function () if ( source == GUIEditor.button[1] ) then triggerServerEvent("Spawn[1]",localPlayer) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("Spawn[2]",localPlayer) elseif ( source == GUIEditor.button[3] ) then triggerServerEvent("Spawn[3]",localPlayer) end end ) showCursor ( true ) Do i put it at the end of showCursor..... guiSetVisible showCursor Link to comment
iPrestege Posted March 9, 2013 Share Posted March 9, 2013 GUIEditor = { button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(205, 151, 406, 323, "Spawner By Gangsta", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(25, 55, 145, 58, "Spawn In Los Santos", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(236, 55, 161, 60, "Spawn In San Fransisco", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(138, 179, 149, 103, "Spawn in LV", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(15, 178, 50, 25, "Quit", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick",root, function () if ( source == GUIEditor.button[1] ) then triggerServerEvent("Spawn[1]",localPlayer) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent("Spawn[2]",localPlayer) elseif ( source == GUIEditor.button[3] ) then triggerServerEvent("Spawn[3]",localPlayer) elseif ( source == GUIEditor.button[4] ) then guiSetVisible(GUIEditor.window[1],false) showCursor ( true ) end end ) Try it. 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