iFoReX Posted April 27, 2012 Share Posted April 27, 2012 mi archivo .txt no se crea al presionar el boton GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Window[1] = guiCreateWindow(0.3425,0.45,0.3562,0.325,"",true) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Edit[1] = guiCreateEdit(78,39,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[1],true) GUIEditor_Edit[2] = guiCreateEdit(78,77,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[2],true) GUIEditor_Edit[3] = guiCreateEdit(78,115,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[3],true) GUIEditor_Label[1] = guiCreateLabel(47,38,28,28,"PosX",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Label[2] = guiCreateLabel(47,80,28,28,"PosY",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[2],255,0,0) guiSetFont(GUIEditor_Label[2],"default-bold-small") GUIEditor_Label[3] = guiCreateLabel(47,121,28,28,"PosZ",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[3],255,0,0) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Button[1] = guiCreateButton(9,157,102,29,"ObtenerPosicion",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(219,158,57,26,"Limpiar",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Button[2],false) showCursor(false) bindKey("F6","down", function() guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(guiGetVisible(GUIEditor_Window[1])) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " ") guiSetText(GUIEditor_Edit[2], " ") guiSetText(GUIEditor_Edit[3], " ") guiSetVisible(GUIEditor_Button[2],false) elseif source == GUIEditor_Button[1] then local x,y,z = getElementPosition( getLocalPlayer() ) guiSetText(GUIEditor_Edit[1], x) guiSetText(GUIEditor_Edit[2], y) guiSetText(GUIEditor_Edit[3], z) guiSetVisible(GUIEditor_Button[2],true) local newFile = fileCreate("poss.txt") if (newFile) then fileWrite(newFile, "Tus Posiciones son "..x", "..y", "..z"") fileClose(newFile) end end end ) Link to comment
Castillo Posted April 27, 2012 Share Posted April 27, 2012 Mira que el archivo se va a crear en la carpeta de los recursos descargados, no en la carpeta del servidor. Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " ") guiSetText(GUIEditor_Edit[2], " ") guiSetText(GUIEditor_Edit[3], " ") guiSetVisible(GUIEditor_Button[2],false) elseif source == GUIEditor_Button[1] then local x,y,z = getElementPosition( getLocalPlayer() ) guiSetText(GUIEditor_Edit[1], x) guiSetText(GUIEditor_Edit[2], y) guiSetText(GUIEditor_Edit[3], z) guiSetVisible(GUIEditor_Button[2],true) local newFile = fileCreate("poss.txt") if (newFile) then fileWrite(newFile, "Tus Posiciones son "..x", "..y", "..z"") fileClose(newFile) end end end ) me dice bad argument ( a number value ) como puedo arreglar eso ? Link to comment
Castillo Posted April 27, 2012 Share Posted April 27, 2012 Te faltaban los dos puntos despues de cada valor. addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == GUIEditor_Button[2] ) then guiSetText ( GUIEditor_Edit[1], " " ) guiSetText ( GUIEditor_Edit[2], " " ) guiSetText ( GUIEditor_Edit[3], " " ) guiSetVisible ( GUIEditor_Button[2], false ) elseif ( source == GUIEditor_Button[1] ) then local x, y, z = getElementPosition ( localPlayer ) guiSetText ( GUIEditor_Edit[1], x ) guiSetText ( GUIEditor_Edit[2], y ) guiSetText ( GUIEditor_Edit[3], z ) guiSetVisible ( GUIEditor_Button[2], true ) local newFile = fileCreate ( "poss.txt" ) if ( newFile ) then fileWrite ( newFile, "Tus Posicion es: ".. x ..", ".. y ..", ".. z ) -- Aca. fileClose ( newFile ) end end end ) Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 y como lo ago para crearlo en el resource ? tendria que ser server para crearlo en el resource ? Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 ok lo ise asi pero ahora me dice attempt dont conactate global z ( a nil value ) cl-side GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Window[1] = guiCreateWindow(0.3425,0.45,0.3562,0.325,"",true) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Edit[1] = guiCreateEdit(78,39,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[1],true) GUIEditor_Edit[2] = guiCreateEdit(78,77,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[2],true) GUIEditor_Edit[3] = guiCreateEdit(78,115,181,29,"",false,GUIEditor_Window[1]) guiEditSetReadOnly(GUIEditor_Edit[3],true) GUIEditor_Label[1] = guiCreateLabel(47,38,28,28,"PosX",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Label[2] = guiCreateLabel(47,80,28,28,"PosY",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[2],255,0,0) guiSetFont(GUIEditor_Label[2],"default-bold-small") GUIEditor_Label[3] = guiCreateLabel(47,121,28,28,"PosZ",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[3],255,0,0) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Button[1] = guiCreateButton(9,157,102,29,"ObtenerPosicion",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(219,158,57,26,"Limpiar",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1],false) guiSetVisible(GUIEditor_Button[2],false) showCursor(false) bindKey("F6","down", function() guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(guiGetVisible(GUIEditor_Window[1])) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " ") guiSetText(GUIEditor_Edit[2], " ") guiSetText(GUIEditor_Edit[3], " ") guiSetVisible(GUIEditor_Button[2],false) elseif source == GUIEditor_Button[1] then local x,y,z = getElementPosition( getLocalPlayer() ) guiSetText(GUIEditor_Edit[1], x) guiSetText(GUIEditor_Edit[2], y) guiSetText(GUIEditor_Edit[3], z) guiSetVisible(GUIEditor_Button[2],true) triggerServerEvent("onSavePos", getLocalPlayer()) end end ) sv-side addEvent("onSavePos", true) addEventHandler("onSavePos", getRootElement(), function() local newFile = fileCreate("poss.txt") if (newFile) then fileWrite(newFile, "Tus Posiciones son ".. x ..", ".. y ..", ".. z .."") fileClose(newFile) end end ) Link to comment
Castillo Posted April 27, 2012 Share Posted April 27, 2012 Te olvidaste de enviar la posicion. -- client side: addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == GUIEditor_Button[2] ) then guiSetText ( GUIEditor_Edit[1], " " ) guiSetText ( GUIEditor_Edit[2], " " ) guiSetText ( GUIEditor_Edit[3], " " ) guiSetVisible ( GUIEditor_Button[2], false ) elseif ( source == GUIEditor_Button[1] ) then local x, y, z = getElementPosition ( localPlayer ) guiSetText ( GUIEditor_Edit[1], x ) guiSetText ( GUIEditor_Edit[2], y ) guiSetText ( GUIEditor_Edit[3], z ) guiSetVisible ( GUIEditor_Button[2], true ) triggerServerEvent ( "onSavePos", localPlayer, x, y, z ) end end ) -- server side: addEvent ( "onSavePos", true ) addEventHandler ( "onSavePos", root, function ( x, y, z ) local newFile = fileCreate ( "poss.txt" ) if ( newFile ) then fileWrite ( newFile, "Tus Posicion es: ".. x ..", ".. y ..", ".. z ) fileClose ( newFile ) end end ) Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 me aparece expected element triggerServerEvent y unas cordenaadas como se podria solucionar eso ? Link to comment
Castillo Posted April 27, 2012 Share Posted April 27, 2012 No entiendo a que te referis, te aparece un error en el debug? si es asi, entonces copialo EXACTAMENTE como aparece. Link to comment
Renkon Posted April 27, 2012 Share Posted April 27, 2012 agregá en el function (x, y, z) que quede: function ( localPlayer, x, y,z ) Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 en q function ? cl-side o sv-side ? Link to comment
Renkon Posted April 27, 2012 Share Posted April 27, 2012 svrside addEvent ( "onSavePos", true ) addEventHandler ( "onSavePos", root, function ( localPlayer, x, y, z ) local newFile = fileCreate ( "poss.txt" ) if ( newFile ) then fileWrite ( newFile, "Tus Posicion es: ".. x ..", ".. y ..", ".. z ) fileClose ( newFile ) end end ) Link to comment
Castillo Posted April 28, 2012 Share Posted April 28, 2012 aqui una IMG Copiaste el client side mal, ese error no deberia aparecer con mi script. Link to comment
iFoReX Posted April 28, 2012 Author Share Posted April 28, 2012 Solid ya me di cuenta tenia algo malo ya lo copie denuevo tu codigo y no me dio error y se creo en el archivo .txt muchas gracias solid Link to comment
Recommended Posts