darhal Posted August 31, 2013 Share Posted August 31, 2013 hi i make a vehicle spawner for police team only but it's dont work the gui open to evry one and the gridlist , the label aand the buttons don t shown i know that the problem is in the Client side : Code client side GUIEditor = { gridlist = {}, window = {}, button = {}, label = {} } car = { {569}, {597}, {598}, {599} } local teamName = "police" local marker = createMarker( -1604, 650, 7, "cylinder", 1.5, 0, 0, 255, 150 ) local marker2 = createMarker( -1629, 651, 7, "cylinder", 1.5, 0, 0, 255, 150 ) local marker3 = createMarker( -1600, 752, -5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker4 = createMarker( 1598, -1609, 13, "cylinder", 1.5, 0, 0, 255, 150 ) local marker5 = createMarker( 1604, -1688, 5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker6 = createMarker( 1583, -1410, 5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker7 = createMarker( 2274, 2242, 10, "cylinder", 1.5, 0, 0, 255, 150 ) local marker8 = createMarker( 2272, 2478, 10, "cylinder", 1.5, 0, 0, 255, 150 ) GUIEditor_Window[1] = guiCreateWindow(251,166,290,342,"Job vehicle", false) guiSetVisible(GUIEditor_Window[1],false) GUIEditor_label[1] = guiCreateLabel(10,23,262,26,"Choose a car then click Spawn vehicle .", false, GUIEditor.window[1]) GUIEditor_Grid[1] = guiCreateGridList(9,49,263,227, false, GUIEditor.window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"vehicle name",60) GUIEditor_Button[1] = guiCreateButton(9,296,69,34,"Spawn Vehicle",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(152,291,129,41,"Close",false,GUIEditor_Window[1]) for i,v in ipairs (car) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (GUIEditor_Grid[1]) guiGridListSetItemText (GUIEditor_Grid[1], row, 1, carName, false, true) end function onClientClick (button, state, absoluteX, absoluteYe) if (source == GUIEditor_Button[1]) then if (guiGridListGetSelectedItem (GUIEditor_Grid[1])) then local cars = guiGridListGetItemText (GUIEditor_Grid[1], guiGridListGetSelectedItem (GUIEditor_Grid[1]), 1) triggerServerEvent ("cars", getLocalPlayer(), cars) end end end addEventHandler ("onClientGUIClick", GUIEditor_Button[1], onClientClick) function onClientClick (button, state, absoluteX, absoluteYe) if (source == GUIEditor_Button[2]) then guiSetVisible(GUIEditor_Window[1],true) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor_Button[2], onClientClick) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker2, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker2) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker3, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker3) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker4, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker4) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker5, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker5) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else warnText("You are not police to have vehicle !!!",source,0,255,0) end end end ) addEventHandler("onClientMarkerHit", marker6, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker6) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker7, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker7) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker8, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker8) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor_Window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) server side addEvent ("cars", true) addEventHandler ("cars", getRootElement(), function(cars) if isElement( veh ) then destroyElement( veh ) end local cn = getVehicleModelFromName (cars) local x,y,z = getElementPosition(source) local cn2 = getVehicleNameFromModel (cn) veh = createVehicle(cn, x,y,z) setVehicleColor(veh, 23, 75, 4) warpPedIntoVehicle(source, veh) outputChatBox ( "* "..cn2.." was created!" ) end ) plz help me to fix it and ty here what debugscript 1 say : ERROR : PD-c.lua:27: attempt to index global 'GUIEditor_Window' a nil value . Link to comment
Castillo Posted August 31, 2013 Share Posted August 31, 2013 The problem is that you should check if the hit player is the local player. And the problem with the buttons not showing is that you are using the wrong tables. GUIEditor = { gridlist = {}, window = {}, button = {}, label = {} } car = { {569}, {597}, {598}, {599} } local teamName = "police" local marker = createMarker( -1604, 650, 7, "cylinder", 1.5, 0, 0, 255, 150 ) local marker2 = createMarker( -1629, 651, 7, "cylinder", 1.5, 0, 0, 255, 150 ) local marker3 = createMarker( -1600, 752, -5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker4 = createMarker( 1598, -1609, 13, "cylinder", 1.5, 0, 0, 255, 150 ) local marker5 = createMarker( 1604, -1688, 5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker6 = createMarker( 1583, -1410, 5, "cylinder", 1.5, 0, 0, 255, 150 ) local marker7 = createMarker( 2274, 2242, 10, "cylinder", 1.5, 0, 0, 255, 150 ) local marker8 = createMarker( 2272, 2478, 10, "cylinder", 1.5, 0, 0, 255, 150 ) GUIEditor.window[1] = guiCreateWindow(251,166,290,342,"Job vehicle", false) guiSetVisible(GUIEditor.window[1],false) GUIEditor.label[1] = guiCreateLabel(10,23,262,26,"Choose a car then click Spawn vehicle .", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(9,49,263,227, false, GUIEditor.window[1]) guiGridListSetSelectionMode(GUIEditor.gridlist[1],2) guiGridListAddColumn(GUIEditor.gridlist[1],"vehicle name",60) GUIEditor.button[1] = guiCreateButton(9,296,69,34,"Spawn Vehicle",false,GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(152,291,129,41,"Close",false,GUIEditor.window[1]) for i,v in ipairs (car) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, carName, false, true) end function onClientClick (button, state, absoluteX, absoluteYe) if (source == GUIEditor.button[1]) then if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then local cars = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 1) triggerServerEvent ("cars", getLocalPlayer(), cars) end end end addEventHandler ("onClientGUIClick", GUIEditor.button[1], onClientClick) function onClientClick (button, state, absoluteX, absoluteYe) if (source == GUIEditor.button[2]) then guiSetVisible(GUIEditor.window[1],true) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor.button[2], onClientClick) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker2, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker2) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker3, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker3) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker4, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker4) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker5, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker5) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else warnText("You are not police to have vehicle !!!",source,0,255,0) end end end ) addEventHandler("onClientMarkerHit", marker6, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker6) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker7, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker7) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) addEventHandler("onClientMarkerHit", marker8, function ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker8) ) then if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then if getElementType(hitPlayer) == "player" then guiSetVisible ( GUIEditor.window[1], true ) showCursor(false) end else outputChatBox ( "you are not in the team", player, 255, 0, 0, true ) end end end ) Link to comment
darhal Posted August 31, 2013 Author Share Posted August 31, 2013 ty castilo u are the best !!! it s work now but see this shown at debugscript 1 Error : Client (darhal) triggered serverside event cars , but event is not added serverside help plz ! Link to comment
darhal Posted August 31, 2013 Author Share Posted August 31, 2013 yes i thik there is a problem in server side line 2 or 13 mear end ... Link to comment
Castillo Posted August 31, 2013 Share Posted August 31, 2013 I don't see any problem on the server side. Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 When the gui open , I select a vehicle THEN I CLICK SPAWN but the car dont spawn i dk why ???? and the ERROR appear Link to comment
TAPL Posted September 1, 2013 Share Posted September 1, 2013 I guess the problem from the meta. But anyway you will need to use table in server side if you want every police player able to get his own vehicle. Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 here is the meta file "darhal" name="police job" version="5.0" type="script"/> "jail.map" /> Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 the fllowing error appear in debugscript 1 WARNING:loading script failed: PD-s.lua:13:') expected (toclose '('atline 2) near 'end' Link to comment
Castillo Posted September 1, 2013 Share Posted September 1, 2013 Post the content of that script. Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 here is the full script : https://community.multitheftauto.com/in ... ls&id=7847 Link to comment
Castillo Posted September 1, 2013 Share Posted September 1, 2013 addEvent ( "cars", true ) addEventHandler ( "cars", getRootElement(), function ( cars ) if isElement ( veh ) then destroyElement ( veh ) end local cn = getVehicleModelFromName ( cars ) local x,y,z = getElementPosition ( source ) local cn2 = getVehicleNameFromModel ( cn ) veh = createVehicle ( cn, x, y, z ) setVehicleColor ( veh, 238, 180, 34 ) warpPedIntoVehicle ( source, veh ) outputChatBox ( "* "..cn2.." was created!" ) end ) Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 ty very much it s work now but the close button dont work ?? how to fix it ? Link to comment
Castillo Posted September 1, 2013 Share Posted September 1, 2013 That's because is set to show it. function onClientClick (button, state, absoluteX, absoluteYe) if (source == GUIEditor.button[2]) then guiSetVisible(GUIEditor.window[1],true) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor.button[2], onClientClick) guiSetVisible(GUIEditor.window[1],true) Change that true to false. Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 (edited) it spawn 3 vehicle now !! Edited September 1, 2013 by Guest Link to comment
darhal Posted September 1, 2013 Author Share Posted September 1, 2013 it spawn 3 vehicle instead of 1 Link to comment
Castillo Posted September 1, 2013 Share Posted September 1, 2013 Make sure that no other script is using the same event "cars". Link to comment
darhal Posted September 2, 2013 Author Share Posted September 2, 2013 oh ok ty very much castilo 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