JasperRieken Posted January 22, 2011 Share Posted January 22, 2011 i made my first gui it opens and it sais bad event handler line 13 can't find out what's wrong somebody see somting? ClietSide marker = createMarker(2327.27,-3083.64,60.25,"cylinder",2,255,0,0,255) function gui() if ( guiGetVisible (window) == true ) then -- check if the gui element is visible showCursor(false) guiSetVisible (window, false ) -- if it is, we hide it else guiSetVisible (window, false ) -- if not, we make it visible showCursor(true) window = guiCreateWindow(471,278,366,401,"Xuju Vechile's",false) but1 = guiCreateButton(100,42,158,45,"BXM",false,window) addEventHandler("onClientGUIClick", but1, bmxBike, false) but2 = guiCreateButton(100,114,158,45,"Mountain Bike",false,window) but3 = guiCreateButton(101,192,158,45,"Bike",false,window) but4 = guiCreateButton(83,138,5,5,"",false,window) but5 = guiCreateButton(101,267,158,45,"Sanchez",false,window) but6 = guiCreateButton(26,362,82,30,"Close",false,window) end end addEventHandler("onClientMarkerHit", marker, gui) function bxmBike() guiSetVisible(window, false) showCursor(false) triggerServerEvent( "spawnBmx", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end ServerSide addEvent("spawnBmx", true) function bikeQ(playerName) local guy = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( guy ) local r = getPedRotation ( guy ) vehicle = createVehicle ( 481, x, y, z, 0, 0, r ) warpPedIntoVehicle ( guy, vehicle ) outputChatBox("Bmx spawned!", guy, 0, 255, 0) end addEventHandler ( "spawnBmx", getRootElement(), bikeQ ) Link to comment
SDK Posted January 22, 2011 Share Posted January 22, 2011 Please use [ lua][ /lua] tags. You're function name is wrong, you really can detect that error yourself! About the script, your window doesn't need to be created if it already exists, check for the window variable before checking it's visible. (And the last guiSetVisible is wrong) function gui() if not window then --if the window doesn't exist, create it window = guiCreateWindow(471,278,366,401,"Xuju Vechile's",false) but1 = guiCreateButton(100,42,158,45,"BXM",false,window) addEventHandler("onClientGUIClick", but1, bmxBike, false) but2 = guiCreateButton(100,114,158,45,"Mountain Bike",false,window) but3 = guiCreateButton(101,192,158,45,"Bike",false,window) but4 = guiCreateButton(83,138,5,5,"",false,window) but5 = guiCreateButton(101,267,158,45,"Sanchez",false,window) but6 = guiCreateButton(26,362,82,30,"Close",false,window) elseif ( guiGetVisible (window) == true ) then -- check if the gui element is visible showCursor(false) guiSetVisible (window, false ) -- if it is, we hide it else guiSetVisible (window, true ) -- if not, we make it visible showCursor(true) end end Link to comment
Castillo Posted January 22, 2011 Share Posted January 22, 2011 if i'm right the addEventHandler error is because you put "bmxBike" and in function you use "bxmBike" Link to comment
JasperRieken Posted January 22, 2011 Author Share Posted January 22, 2011 it works now but if one person steps in everybody get's the gui what can i do? Link to comment
proracer Posted January 22, 2011 Share Posted January 22, 2011 Than probably you shouldn't use getRootElement for the servided script.Use your brain and think what argument you should use for the 2nd arg. Link to comment
SDK Posted January 22, 2011 Share Posted January 22, 2011 put the marker serverside and attacht the event to that marker Link to comment
JasperRieken Posted January 22, 2011 Author Share Posted January 22, 2011 No need This scriped is Solved ClientSide marker = createMarker(2327.27,-3083.64,59.25,"cylinder",2,255,255,255,255) function gui(hitElement) if getElementType( hitElement ) == "player" and hitElement == getLocalPlayer() then if ( guiGetVisible (window) == true ) then -- check if the gui element is visible showCursor(false) guiSetVisible (window, false ) -- if it is, we hide it else guiSetVisible (window, false ) -- if not, we make it visible showCursor(true) end window = guiCreateWindow(471,278,366,401,"Xuju Vechile's",false) but1 = guiCreateButton(100,42,158,45,"BXM",false,window) addEventHandler("onClientGUIClick", but1, bmxBike, false) but2 = guiCreateButton(100,114,158,45,"Mountain Bike",false,window) addEventHandler("onClientGUIClick", but2, mountainBike, false) but3 = guiCreateButton(101,192,158,45,"Bike",false,window) addEventHandler("onClientGUIClick", but3, Bike, false) but4 = guiCreateButton(101,267,158,45,"Sanchez",false,window) addEventHandler("onClientGUIClick", but4, Sanchez, false) but5 = guiCreateButton(26,362,82,30,"Close",false,window) addEventHandler("onClientGUIClick", but5, hideWindow, false) end end addEventHandler("onClientMarkerHit", marker, gui) function bmxBike() guiSetVisible(window, false) showCursor(false) triggerServerEvent( "spawnBmx", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end function mountainBike() guiSetVisible(window, false) showCursor(false) triggerServerEvent( "spawnMountainbike", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end function Bike() guiSetVisible(window, false) showCursor(false) triggerServerEvent( "spawnBike", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end function Sanchez() guiSetVisible(window, false) showCursor(false) triggerServerEvent( "spawnSanchez", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end function hideWindow() guiSetVisible(window, false) showCursor(false) end ServerSide addEvent("spawnBmx", true) function bikeQ(playerName) local guy = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( guy ) local r = getPedRotation ( guy ) vehicle = createVehicle ( 481, x, y, z, 0, 0, r ) warpPedIntoVehicle ( guy, vehicle ) outputChatBox("Bmx spawned!", guy, 0, 255, 0) end addEventHandler ( "spawnBmx", getRootElement(), bikeQ ) addEvent("spawnMountainbike", true) function bikeQ(playerName) local guy = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( guy ) local r = getPedRotation ( guy ) vehicle = createVehicle ( 510, x, y, z, 0, 0, r ) warpPedIntoVehicle ( guy, vehicle ) outputChatBox("MountainBike spawned!", guy, 0, 255, 0) end addEventHandler ( "spawnMountainbike", getRootElement(), bikeQ ) addEvent("spawnBike", true) function bikeQ(playerName) local guy = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( guy ) local r = getPedRotation ( guy ) vehicle = createVehicle ( 509, x, y, z, 0, 0, r ) warpPedIntoVehicle ( guy, vehicle ) outputChatBox("Bike spawned!", guy, 0, 255, 0) end addEventHandler ( "spawnBike", getRootElement(), bikeQ ) addEvent("spawnSanchez", true) function bikeQ(playerName) local guy = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( guy ) local r = getPedRotation ( guy ) vehicle = createVehicle ( 468, x, y, z, 0, 0, r ) warpPedIntoVehicle ( guy, vehicle ) outputChatBox("Sanchez spawned!", guy, 0, 255, 0) end addEventHandler ( "spawnSanchez", getRootElement(), bikeQ ) 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