Jump to content

problem con fileCreate


iFoReX

Recommended Posts

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

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

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

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

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
  • Recently Browsing   0 members

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