Arsilex Posted June 15, 2012 Share Posted June 15, 2012 Gui = {} Repair = {} Gui = guiCreateWindow(842,237,474,438,"GUI de mecanico",false) Repair = guiCreateButton(11,30,121,30,"Reparar",false,Gui) Paint = guiCreateButton(158,31,117,28,"Paintjob1",false,Gui) function changeVisibility() if guiGetVisible( Gui ) == true then guiSetVisible( Gui, false ) showCursor( false ) else guiSetVisible( Gui, true ) showCursor( true ) end end function Paintjob1 () setVehiclePaintjob ( vehicle ) paintjob = getVehiclePaintjob ( vehicle ) if ( paintjob == 2 ) then outputChatBox ( "the paintjob was successfully set" ) end end addEventHandler( "onClientGUIClick", Paintjob1, Paint, false) function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then server.fixVehicle(vehicle) end end addEventHandler( "onClientGUIClick", repairVehicle, Repair, false) addCommandHandler ( "guimecanico", changeVisibility ) Link to comment
Castillo Posted June 15, 2012 Share Posted June 15, 2012 1: Quita: Gui = {} Repair = {} 2: Que es esto? server.fixVehicle(vehicle) Eso parece ser del Freeroam. Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 si lo es quero que cuando le de al boton se arregle el coche es para mi GUI de mecanico de un RP Entonces uso fixvehicle nada mas o me dijeron también que es bueno setElementHealth Cual es mejor y mas simple? Link to comment
Castillo Posted June 15, 2012 Share Posted June 15, 2012 Pero el Freeroam tiene un sistema que puedas ejecutar funciones server side en el client side, para usar fixVehicle tenes que hacerlo server side, osea triggerServerEvent. Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Y como podria hacerlo sin usar el server-side¿ Link to comment
Castillo Posted June 15, 2012 Share Posted June 15, 2012 Si reparas el vehiculo client side, solo vos lo vas a poder ver que yo sepa. Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Entonces paso todo el script a server-side? Link to comment
iFoReX Posted June 15, 2012 Share Posted June 15, 2012 pekio haz una funcion en client-side con evento onClientGUIClick, entonces agregas eventos y funciones en server-side en donde se obtendra el vehiculo del jugador y lo reparas por ejemplo cl-side addEventHandler("onClientGUIClick", root, function() if source == TUBOTON then triggerServerEvent("TUEVENTO", getLocalPlayer()) end end ) sv-side addEvent("TUEVENTO",true) addEventHandler("TUEVENTO", root, function() ---Tus funciones--- end ) puse --Tus funciones--- devido a que no se como obtener el auto del player Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Mira Mota ize esto antes de que me dijeras pero no me funciona aun asi Client-Side Gui = guiCreateWindow(842,237,474,438,"GUI de mecanico",false) Repair = guiCreateButton(11,30,121,30,"Reparar",false,Gui) Paintjob1 = guiCreateButton(158,31,117,28,"Paintjob1",false,Gui) function changeVisibility() if guiGetVisible( Gui ) == true then guiSetVisible( Gui, false ) showCursor( false ) else guiSetVisible( Gui, true ) showCursor( true ) end end function Paintjob1 () setVehiclePaintjob ( theVehicle, 2 ) paintjob = getVehiclePaintjob ( theVehicle ) if ( paintjob == 2 ) then outputChatBox ( "the paintjob was successfully set" ) end end addEventHandler( "onClientGUIClick", Paintjob1, Paintjob1, true) function repairVehicle() triggerServerEvent ( "Fix", getLocalPlayer()) end addEventHandler( "onClientGUIClick", repairVehicle, Repair, true) addCommandHandler ( "guimecanico", changeVisibility ) Server-Side function Fix ( Repair ) fixVehicle ( vehicleValue ) end addEvent( "onFix", true ) addEventHandler( "onFix", getRootElement(), Fix ) Link to comment
iFoReX Posted June 15, 2012 Share Posted June 15, 2012 pekio recuerda triggerServerEvent triggea el evento no la funcion asi que seria asi triggerServerEvent("onFix", getLocalPlayer()) Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Pos me sigue saliendo lo de que el evento no fue encontrado en el server-side Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Esta todo en orden Server-Side function Reparar ( Repair ) fixVehicle ( vehicle ) end addEvent( "onFix", true ) addEventHandler( "onFix", getRootElement(), Reparar ) Client-side Gui = guiCreateWindow(842,237,474,438,"GUI de mecanico",false) Repair = guiCreateButton(11,30,121,30,"Reparar",false,Gui) Paintjob1 = guiCreateButton(158,31,117,28,"Paintjob1",false,Gui) function changeVisibility() if guiGetVisible( Gui ) == true then guiSetVisible( Gui, false ) showCursor( false ) else guiSetVisible( Gui, true ) showCursor( true ) end end function repairVehicle() triggerServerEvent("onFix", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", Repair, repairVehicle, false ) function Paintjob () setVehiclePaintjob ( theVehicle, 2 ) paintjob = getVehiclePaintjob ( theVehicle ) if ( paintjob == 2 ) then outputChatBox ( "the paintjob was successfully set" ) end end addEventHandler ( "onClientGUIClick", Paintjob1, Paintjob, false ) addCommandHandler ( "guimecanico", changeVisibility ) Link to comment
iFoReX Posted June 15, 2012 Share Posted June 15, 2012 pruebalo y dinos que tal yo lo veo bien Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 ya dije que me sale error Link to comment
Arsilex Posted June 15, 2012 Author Share Posted June 15, 2012 Miren http://imageshack.us/photo/my-images/13 ... louqu.png/ Link to comment
iFoReX Posted June 15, 2012 Share Posted June 15, 2012 mm tienes el server-side en el meta.xml ? Link to comment
Arsilex Posted June 16, 2012 Author Share Posted June 16, 2012 ya me funciona pero me sale que lo de fixvehicle es un argumento invalido Link to comment
iFoReX Posted June 16, 2012 Share Posted June 16, 2012 si, suponia que te iba a salir eso ya que tienes que obtener el vehiculo del jugador Link to comment
Arsilex Posted June 16, 2012 Author Share Posted June 16, 2012 y como podría hacer eso para el paradise RP? Link to comment
iFoReX Posted June 16, 2012 Share Posted June 16, 2012 Nose mm.. y si usas getVehicleID( source ) Link to comment
Arsilex Posted June 16, 2012 Author Share Posted June 16, 2012 Mire probe hacerlo asi pero no entiendo por que no va function Reparar ( Repair ) local vehicle = getPedOccupiedVehicle( player ) if vehicle then fixVehicle( vehicle ) end end addEvent( "onFix", true ) addEventHandler( "onFix", getRootElement(), Reparar ) Link to comment
iFoReX Posted June 16, 2012 Share Posted June 16, 2012 lol, prueba con reemplazar source por player, ademas, para que es el argumento Repair en la linea de function Reparar ? Link to comment
Recommended Posts