yMassai Posted April 27, 2012 Author Share Posted April 27, 2012 this? function carrosCreateVehicle ( ) carrosCreateVehicles = createVehicle ( ??, 4, 0, 3 ) warpPedIntoVehicle ( carrosCreateVehicles ) end how can I configure to create the car selected in the list? Link to comment
Castillo Posted April 28, 2012 Share Posted April 28, 2012 guiGridListGetSelectedItem -- Get selected grid list item. guiGridListGetItemText -- Get the item text. Link to comment
yMassai Posted April 28, 2012 Author Share Posted April 28, 2012 Server local carrosCreate = { } function carrosCreateVehicle ( ) carrosCreateVehicles = createVehicle ( ??, 1543.98962 , -1670.46398 , 13.0213 ) warpPedIntoVehicle ( carrosCreateVehicles ) if ( isElement ( carrosCreateVehicle[ source ] ) ) destroyElement ( carrosCreateVehicle[ source ] ) end end this? with i put? guiGridListGetSelectedItem guiGridListGetItemText Link to comment
Stanley Sathler Posted April 28, 2012 Share Posted April 28, 2012 Creating a car list: • Create a table (vector) with the car names (you can use also the vehicle id's) • Use the functions guiCreateGridList(), guiGridListAddColumn(), guiGridListAddRow() and guiGridListSetItemText() for create a list • Create a loop (for i, v in ipairs(table_name) do) and insert (inside loop) the function guiGridListAddRow() and guiGridListSetItemText(). If you putted names on table, use getElementModel() for get the car id. If you need more help, go to my profile and get my messenger address. I'm from Brazil too, and I can help you better. Link to comment
yMassai Posted April 28, 2012 Author Share Posted April 28, 2012 Server local carrosCreateVehicle = { } function carrosCreateClick ( ) if ( source == carrosCreateVehicle ) then triggerServerEvent ( "testCreateTest", localPlayer ) testDestroyTestGUI ( ) if ( isElement ( carrosVehicle[ source ] ) ) destroyElement ( carrosVehicle[ source ] ) carrosCreateVehicle = createVehicle ( ??, 1543,98962 , -1670,46398 , 13,0213 ) warpPedIntoVehicle ( carrosVehicle ) end addEventHandler ( "onClientGUIClick", root, carrosCreateClick ) This? Link to comment
Castillo Posted April 28, 2012 Share Posted April 28, 2012 That is just a mess, I suggest you start again, you still don't understand that events/functions can't be used on both sides ( client and server ). Link to comment
yMassai Posted April 28, 2012 Author Share Posted April 28, 2012 carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) guiWindowSetSizable( carrosWindow,false) guiSetVisible( carrosWindow, false ) carrosVis = { 440, 320 } for index, model in ipairs ( carrosVis ) do local row = guiGridListAddRow ( carrosList ) guiGridListSetItemText ( carrosList, row, column, tostring ( getVehicleNameFromModel ( model ) ), false, true ) end carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) createCarrosVehicle = createVehicle (??,0,0,0) warpPedIntoVehicle ( carrosCreateVehicles ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if ( hitElement == localPlayer ) then if ( source == carrosMarker ) then guiSetVisible ( carrosWindow, true ) end end end ) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == carrosClose ) then guiSetVisible ( carrosWindow, false ) end end ) This? Please help me, I have no time to start the script again. Link to comment
iFoReX Posted April 28, 2012 Share Posted April 28, 2012 Ninguem , WarpPedIntoVehicle is server-side ad the components of the GUI are client-side , this code never work, u need trigger with a triggerServerEvent Link to comment
Absence2 Posted April 28, 2012 Share Posted April 28, 2012 Clientside and Serverside scriptsYou may have already noticed these or similiar terms (Server/Client) somewhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside. Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside. https://wiki.multitheftauto.com/wiki/TriggerServerEvent https://wiki.multitheftauto.com/wiki/TriggerClientEvent you can use this part serverside: but you'll have to edit it slightly. As in remove the GUI functions and the player argument and marker event carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) createCarrosVehicle = createVehicle (??,0,0,0) warpPedIntoVehicle ( carrosCreateVehicles ) addEventHandler ( "onMarkerHit", root, function ( hitElement ) if ( hitElement == source ) then if ( source == carrosMarker ) then -- trigger client event here end end end ) then use something like this on clientside, you have to trigger it from serverside though, look comments above. function iHitMarker() guiSetVisible ( carrosWindow, false ) -- your gui function(s) -- this event should be triggered from server end addEvent( "iHitMarkerC", true ) addEventHandler( "iHitMarkerC", root, iHitMarker ) Link to comment
iFoReX Posted April 28, 2012 Share Posted April 28, 2012 is more easy it cl-side carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) guiWindowSetSizable( carrosWindow,false) guiSetVisible( carrosWindow, false ) row = guiGridListAddRow( carrosList ) row2 = guiGridListAddRow( carrosList ) guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) function elMarker( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible ( carrosWindow, true ) end end addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == carrosClose ) then guiSetVisible ( carrosWindow, false ) elseif ( source == carrosCreate ) then triggerServerEvent("CreateCarros", getLocalPlayer()) end end ) sv-side addEvent("CreateCarros", true) addEventHandler("CreateCarros", getRootElement(), function() carros = createVehicle ( 440,0,0,0) warpPedIntoVehicle ( carros ) end ) Link to comment
yMassai Posted April 29, 2012 Author Share Posted April 29, 2012 Client carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) guiWindowSetSizable( carrosWindow,false) guiSetVisible( carrosWindow, false ) row = guiGridListAddRow( carrosList ) row2 = guiGridListAddRow( carrosList ) guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) function elMarker( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible ( carrosWindow, true ) end end addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == carrosClose ) then guiSetVisible ( carrosWindow, false ) elseif ( source == carrosCreate ) then triggerServerEvent("CreateCarros", getLocalPlayer()) end end ) Server addEvent("CreateCarros", true) addEventHandler("CreateCarros", getRootElement(), function() carros = createVehicle ( 440,1543.98962, -1670.46398, 13.300, 0,0,90) warpPedIntoVehicle ( carros ) end ) The warpPedIntoVehicle dont work! Link to comment
Castillo Posted April 29, 2012 Share Posted April 29, 2012 Maybe because you forgot about the first argument? Link to comment
Castillo Posted April 29, 2012 Share Posted April 29, 2012 Required ArgumentsthePed: The ped which you wish to force inside the vehicle ( First ) theVehicle: The vehicle you wish to force the ped into ( Second ) Link to comment
yMassai Posted April 29, 2012 Author Share Posted April 29, 2012 Sorry but i do not understand very well. This part you could create this for me? Sorry for not knowing everything. Link to comment
jeremaniak Posted April 29, 2012 Share Posted April 29, 2012 carros = createVehicle ( 440,1543.98962, -1670.46398, 13.300, 0,0,90) warpPedIntoVehicle ( thePed, carros ) --make sure you define theped end ) Link to comment
iFoReX Posted April 29, 2012 Share Posted April 29, 2012 is it , I think carros = createVehicle ( 440,1543.98962, -1670.46398, 13.300, 0,0,90) warpPedIntoVehicle ( source, carros ) --make sure you define theped end ) Link to comment
jeremaniak Posted April 29, 2012 Share Posted April 29, 2012 Yeah because its server sided Link to comment
yMassai Posted April 29, 2012 Author Share Posted April 29, 2012 Client carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) guiWindowSetSizable( carrosWindow,false) guiSetVisible( carrosWindow, false ) row = guiGridListAddRow( carrosList ) row2 = guiGridListAddRow( carrosList ) guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) function elMarker( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible ( carrosWindow, true ) end end addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == carrosClose ) then guiSetVisible ( carrosWindow, false ) elseif ( source == carrosCreate ) then triggerServerEvent("CreateCarros", getLocalPlayer()) end end ) Server local carros = { } addEvent("CreateCarros", true) addEventHandler("CreateCarros", getRootElement(), function() carros = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0,0,90) warpPedIntoVehicle ( source, carros ) if ( isElement ( carrosVehicle[ source ] ) ) destroyElement ( carrosVehicle[ source ] ) end end ) to the server * this way go create only a car? Link to comment
Castillo Posted April 29, 2012 Share Posted April 29, 2012 (edited) local carros = { } addEvent ( "CreateCarros", true ) addEventHandler ( "CreateCarros", getRootElement(), function ( ) if ( isElement ( carros [ source ] ) ) then destroyElement ( carros [ source ] ) end carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) warpPedIntoVehicle ( source, carros [ source ] ) end ) Edited April 30, 2012 by Guest Link to comment
yMassai Posted April 30, 2012 Author Share Posted April 30, 2012 SCRIPT ERROR: CarrosTest\server.lua:7: 'then' expected near 'destroyElement' WARNING: Loading script failed: CarrosTest\server.lua:7: 'then' expected near 'destroyElement' Link to comment
yMassai Posted April 30, 2012 Author Share Posted April 30, 2012 local carros = { } addEvent ( "CreateCarros", true ) addEventHandler ( "CreateCarros", getRootElement(), function ( ) if ( isElement ( carros [ source ] ) ) destroyElement ( carros [ source ] ) end carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) warpPedIntoVehicle ( source, carros [ source ] ) end ) local carros = { } addEvent ( "CreateCarros", true ) addEventHandler ( "CreateCarros", getRootElement(), function ( ) if ( isElement ( carros [ source ] ) ) then destroyElement ( carros [ source ] ) end carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) warpPedIntoVehicle ( source, carros [ source ] ) end ) you do not recalled the "then" Link to comment
Castillo Posted April 30, 2012 Share Posted April 30, 2012 I noticed, edited my post . Link to comment
yMassai Posted April 30, 2012 Author Share Posted April 30, 2012 again i will ask for a help. again, how can i configure to create the selected car? Link to comment
Castillo Posted April 30, 2012 Share Posted April 30, 2012 You must trigger the selected item name to server side then get the vehicle model from the name received. 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