vallejo Posted August 13, 2016 Share Posted August 13, 2016 Buenas noches, lo que pasa es que quiero crear el coche cuando selecciono alguno del listado y mi cod, por parte del client: tblCoches={"Admiral","BMX","Faggio"} for i, valor in pairs(tblCoches) do guiGridListAddRow(listado) -- Agregamos items a la columas guiGridListSetItemText(listado,i-1,a,i,false,false) guiGridListSetItemText(listado,i-1,b,valor,false,false) end function Abrir() local filas,columnas = guiGridListGetSelectedItem(listado) if source == listado then if(filas == 0) and (columnas == 1) then playSoundFrontEnd (2) outputChatBox("Prueba 111") elseif (filas == 1) and (columnas == 1) then playSoundFrontEnd (2) outputChatBox("Prueba 222") elseif (filas == 2) and (columnas == 1) then playSoundFrontEnd (2) triggerServerEvent ( "onWarp", source, filas, columnas ) end end end addEventHandler('onClientGUIClick',root, Abrir) addEventHandler("onClientGUIClick", Obtener, Abrir, false) -- Boton cerrar server: function vehicle(veh) if getElementType(source) == "player" then if not getPedOccupiedVehicle( source ) then vehID = getVehicleModelFromName(veh) getVehicleNameFromModel(veh) local x,y,z = getElementPosition(source) vehiculo = createVehicle(vehID, x,y,z) warpPedIntoVehicle(source, vehiculo) end if isElement( vehiculo ) then destroyElement( vehiculo ) end end end addEvent("onWarp", true) addEventHandler("onWarp", root,vehicle) Link to comment
Anzo Posted August 13, 2016 Share Posted August 13, 2016 --Client tblCoches={ {445}, {481}, } for i,v in pairs (tblCoches) do local vehicle = getVehicleNameFromID(v[1]) local row = guiGridListAddRow (TUGRID) guiGridListSetItemText (TUGRID, row, 1, vehicle, false, true) end local player = getLocalPlayer() addEventHandler("onClientGUIDoubleClick", root, function() if source == TUGRID then --Puedes cambiarlo a un boton, pero recuerda cambiar el onClientDoubleClick por onClientGUIClick si vas a usar botones local row, column = guiGridListGetSelectedItem(TUGRID) if ( row ~= guiGridListGetRowCount ( TUGRID ) and column ~= 0 ) then local vehicleID = guiGridListGetItemText ( TUGRID, row, 1 ) triggerServerEvent("onVehicle", player, vehicleID) --outputChatBox("Vehiculo:"..vehicleID.."") end end end) --Server car = {} function vehicle(vehicle) if car[source] then destroyElement(car[source]) end local vehicleID = getVehicleIDFromName(vehicle) local x,y,z = getElementPosition( source ); x = x + 5 car[source] = createVehicle( vehicleID, x, y, z ); return true; end addEvent("onVehicle", true) addEventHandler("onVehicle", root,vehicle) Link to comment
Recommended Posts