Jump to content

[Solucionado] un archivo? Vacio? Que coño pasa


Recommended Posts

Bien, vuelvo de nuevo con el mismo problema que tenia, con el sound system de mi anterior post, esta vez es con las funciones de File (Recomentado por CiBeR), pero el problema es que no me "reconoce el texto" o algo por el estilo, a que se puede deber el error? :/

Solo me devuelve valor en el primer "envio", el resto, devuelve strings vacias del todo aunque le ponga texto

saveToDisk("link.1", "Hola") 

------------------------------------------------

function saveToDisk(string_file, string_text) 
local sDhand = fileOpen(string_file, false) 
fileWrite(sDhand, string_text) 
fileFlush(sDhand) 
local x = fileRead(sDhand, fileGetSize(sDhand)) 
fileClose(sDhand) 
outputChatBox(tostring(x)) 
return x 
end 

function bmanager () 
    if source == GUIEditor.button[1] then 
        if not creado then 
        triggerServerEvent("f5:create", root, localPlayer, guiGetText(GUIEditor.edit[1])) 
        creado = true 
        else 
        outputChatBox("#FF5000[TrosNos.F5] #FF0000Ya tienes un altavoz colocado", 0,0,0,true) 
        end 
    elseif source == GUIEditor.button[2] then 
        if creado then 
        triggerServerEvent("f5:destroy", root, localPlayer, guiGetText(GUIEditor.edit[1])) 
        creado = false 
        else 
        outputChatBox("#FF5000[TrosNos.F5] #FFFF00No tienes un altavoz colocado!", 0,0,0,true) 
        end 
    elseif source == GUIEditor.button[3] then --Save1 
    local ret = saveToDisk("link.1", tostring(guiGetText(GUIEditor.edit[1]))) 
    guiSetText(GUIEditor.edit[2], tostring(ret)) 
    elseif source == GUIEditor.button[4] then --Save2 
    local ret = saveToDisk("link.2", tostring(guiGetText(GUIEditor.edit[1]))) 
    guiSetText(GUIEditor.edit[3], tostring(ret)) 
    elseif source == GUIEditor.button[5] then --Save3 
    saveToDisk("link.3", tostring(guiGetText(GUIEditor.edit[1]))) 
    elseif source == GUIEditor.button[6] then --Save4 
    saveToDisk("link.4", tostring(guiGetText(GUIEditor.edit[1]))) 
    elseif source == GUIEditor.button[7] then --Save5 
    saveToDisk("link.5", tostring(guiGetText(GUIEditor.edit[1]))) 
    elseif source == GUIEditor.button[8] then --Save6 
    saveToDisk("link.6", tostring(guiGetText(GUIEditor.edit[1]))) 
    elseif source == GUIEditor.button[9] then --Save7 
    saveToDisk("link.7", tostring(guiGetText(GUIEditor.edit[1]))) 
    elseif source == GUIEditor.button[10] then --Save8 
    saveToDisk("link.8", tostring(guiGetText(GUIEditor.edit[1]))) 
    end 
end 

Edited by Guest
Link to comment
<meta> 
    <info author="venadHD" version="1.0.0" type="script" /> 
    <script src="client.luac" type="client"/> 
    <script src="server.lua"/> 
</meta> 
  

function checker () 
    for file=1, 8 do 
        if not fileExists("link."..tostring(file)) then 
        local S = fileCreate("link."..tostring(file)) 
        fileClose(S) 
        end 
    end 
end 
addEventHandler("onClientResourceStart", resourceRoot, checker) 

y esta verificado que realmente los crea esa parte del script

Link to comment
Hidden
function saveToDisk(string_file, string_text) 
local sDhand = fileOpen(string_file, false) 
local size = fileGetSize(string_file) 
local pos = fileSetPos(sDhand,size) 
fileWrite(sDhand, string_text) 
fileFlush(sDhand) 
fileSetPos(sDhand,0) 
local x = fileRead(sDhand, size) 
fileClose(sDhand) 
outputChatBox(tostring(x)) 
return x 
end 

Link to comment
function saveToDisk(string_file, string_text) 
local sDhand = fileOpen(string_file, false) 
local size = fileGetSize(string_file) 
local pos = fileSetPos(sDhand,size) 
fileWrite(sDhand, string_text) 
fileFlush(sDhand) 
fileSetPos(sDhand,0) 
local x = fileRead(sDhand, size) 
fileClose(sDhand) 
outputChatBox(tostring(x)) 
return x 
end 

La cosa es que quiero que sobreescriba lo que ya tiene, por eso el fileWrite de nuevo :/.

Tendria que enviar un fileDelete para eso? y otra vez la creacion del archivo?

fileSetPos(sDhand,0) 
local x = fileRead(sDhand, size) 
--Esta parte ya me empezo a funcionar 

Link to comment
Hidden
Solo me devuelve valor en el primer "envio", el resto, devuelve strings vacias del todo aunque le ponga texto

No entiendo para que pides entonces cosas que no necesitas.

Sí, podrías utilizar esa función y re-crear tu archivo.

Link to comment
Solo me devuelve valor en el primer "envio", el resto, devuelve strings vacias del todo aunque le ponga texto

No entiendo para que pides entonces cosas que no necesitas.

Sí, podrías utilizar esa función y re-crear tu archivo.

Porque no siempre se re-crea el archivo, por tanto, necesita ser leido una o mas veces

Link to comment
  • Recently Browsing   0 members

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