Jump to content

problem con fileCreate


iFoReX

Recommended Posts

Posted

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 
) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

Mira que el archivo se va a crear en la carpeta de los recursos descargados, no en la carpeta del servidor.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 ?

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
    ) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No entiendo a que te referis, te aparece un error en el debug? si es asi, entonces copialo EXACTAMENTE como aparece.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
) 

Posted
aqui una IMG

mtascreen20120428070326.png

Copiaste el client side mal, ese error no deberia aparecer con mi script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No hay de que.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...