DeathMta Posted July 31, 2016 Share Posted July 31, 2016 HOLA amigos quiero que me ayuden con este error , no guarda el traje que eligi al cj SERVER local root = getRootElement() tryToLoginPlayer = function(username, password) local account = getAccount(username, password) if account then local accountName = getAccountName(account) logIn(source, account, password) triggerClientEvent(source, "onPlayerDoneLogin", source, accountName, password) triggerEvent("onPlayerDayZLogin", getRootElement(), username, pass, source) else outputChatBox("[Login]#FF9900 Error en Contraseña o Cuenta", source, 255, 255, 255, true) end end addEvent("onClientSendLoginDataToServer", true) addEventHandler("onClientSendLoginDataToServer", root, tryToLoginPlayer) tryToRegsiterPlayer = function(username, pass) if not getAccount(username) then theAccount = addAccount(username, pass) if theAccount then logIn(source, theAccount, pass) outputChatBox("Usted se registro" .. username .. "' Nombre de Jugador '" .. getPlayerName(source) .. "'#FFFFFF Su Contraseña '" .. pass .. "'!", source, 255, 255, 255, true) triggerClientEvent(source, "onPlayerDoneLogin", source, username, pass) triggerEvent("onPlayerDayZRegister", getRootElement(), username, pass, source) else outputChatBox("[Login]#FF9900 Error Desconocido!", source, 255, 255, 255, true) end else outputChatBox("[Login]#FF9900 Contraseña No Son Iguales!", source, 255, 255, 255, true) end end addEvent("onClientSendRegisterDataToServer", true) addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer) function updateSkinn(texture,model,typex,number) if number == 1 then addPedClothes(client,texture,model,typex) elseif number == 0 then removePedClothes(client,texture,model,typex) end end addEvent("updateSkin",true) addEventHandler("updateSkin",getRootElement(),updateSkinn) function LoginJoin() fadeCamera (source,true) setCameraMatrix(source,858.76477050781,-1399.6383056641,16.550140380859) end addEventHandler("onPlayerJoin",getRootElement(),LoginJoin) addEventHandler("onPlayerJoin", getRootElement(), function() local account = getAccount(username, password) if #pl_acc ~= 0 then local cloth0 = getAccountData ( pl_acc[1], "cloth0" ) or 0 local cloth1 = getAccountData ( pl_acc[1], "cloth1" ) or 0 local cloth2 = getAccountData ( pl_acc[1], "cloth2" ) or 0 local cloth3 = getAccountData ( pl_acc[1], "cloth3" ) or 0 local cloth15 = getAccountData ( pl_acc[1], "cloth15" ) or 0 local cloth16 = getAccountData ( pl_acc[1], "cloth16" ) or 0 setElementData ( source, "cloth0", cloth0 ) setElementData ( source, "cloth1", cloth1 ) setElementData ( source, "cloth2", cloth2 ) setElementData ( source, "cloth3", cloth3 ) setElementData ( source, "cloth15", cloth15 ) setElementData ( source, "cloth16", cloth16 ) end -- source:setData ( "LastTime", true ) fadeCamera(source, true) setCameraMatrix(source, 3620.4724121094, -3022.470703125, 33.641231536865, 3708.5283203125, -2975.9663085938, 24.501970291138) end ) CLIENTE resourceRoot = getResourceRootElement(getThisResource()) localPlayer = getLocalPlayer() marwinButtons = {} font = {} font[1] = guiCreateFont( "images/button_standart.png", 12 ) function createMarwinButton(x,y,widht,height,text,bool,parent,info) button = guiCreateStaticImage(x,y,widht,height,"images/button_standart.png", bool,parent or nil) table.insert(marwinButtons,button) guiBringToFront(button) label = guiCreateLabel(0,0,1,1,text,bool,button) guiBringToFront(label) setElementData(label,"parent",button) setElementData(button,"info",info) guiSetFont(label,font[1]) guiLabelSetVerticalAlign (label, "center") guiLabelSetHorizontalAlign (label, "center") addEventHandler("onClientMouseEnter",label,markButton,false) addEventHandler("onClientMouseLeave",label,unmarkButton,false) return label end function markButton () parent = getElementData(source,"parent") guiStaticImageLoadImage (parent,"images/button_mouse.png") setElementData(getLocalPlayer(),"clickedButton",parent) end function unmarkButton (b,s) parent = getElementData(source,"parent") guiStaticImageLoadImage (parent,"images/button_standart.png") setElementData(getLocalPlayer(),"clickedButton",false) end idb = false function loginPanel() showCursor(true,false) screenw,screenh = guiGetScreenSize() login_window = guiCreateStaticImage(0, 0, screenw, screenh, "", false) ---------------------------------------------------------------------------------- charbutton = guiCreateButton(0.10, 0.45, 0.10, 0.03, "Editar CJ", true,login_window) addEventHandler ( "onClientGUIClick", charbutton, function() guiSetVisible(GUIEditor.window[1],true) end) ---------------------------------------------------------------------------------- login_login = guiCreateButton(0.10, 0.40, 0.10, 0.03,"Ingresar",true,login_window,"login") addEventHandler ( "onClientGUIClick", login_login, function() guiSetVisible(login_window2,false) guiSetVisible(register_window,false) createLogin() end, false ) ---------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- login_register = guiCreateButton(0.10, 0.49, 0.10, 0.03,"Registro",true,login_window,"login") addEventHandler ( "onClientGUIClick", login_register, function() guiSetVisible(register_window,false) guiSetVisible(login_window2,false) createRegistration() end, false ) ---------------------------------------------------------------------------------- login_exit = guiCreateButton(0.10, 0.54, 0.10, 0.03,"Cerrar",true,login_window,"quit") addEventHandler ( "onClientGUIClick", login_exit, function() guiSetVisible(GUIEditor.window[1],false) guiSetVisible(login_window2,false) guiSetVisible(register_window,false) end, false ) end function createRegistration() screenw,screenh = guiGetScreenSize() register_window = guiCreateStaticImage(350, 270, 200, 250, "images/button_standart.png", false) infol1 = guiCreateLabel(0.27, 0.05, 0.80, 0.30,"Registro",true,register_window) guiSetFont(infol1,font[1]) infol4 = guiCreateLabel(0.38, 0.16, 0.80, 0.30,"Usuario",true,register_window) guiSetFont(infol4,font[1]) infol5 = guiCreateLabel(0.36, 0.38, 0.80, 0.30,"Contraseña",true,register_window) guiSetFont(infol5,font[1]) register_username = guiCreateEdit(30, 60, 134, 28, "", false, register_window) guiSetAlpha(register_username, 0.60) register_password = guiCreateEdit(30, 120, 134, 28, "", false, register_window) guiSetAlpha(register_password, 0.60) guiEditSetMasked(register_password, true) regbutt = guiCreateButton(0.14,0.695,0.695,0.110,"Registro",true,register_window,"login") addEventHandler ( "onClientGUIClick", regbutt, function() if idb == true then end username = guiGetText(register_username) pass1 = guiGetText(register_password) if username ~= "" and pass1 ~= "" then triggerServerEvent("onClientSendRegisterDataToServer", getLocalPlayer(), username, pass1) end end, false ) end function createLogin() screenw,screenh = guiGetScreenSize() login_window2 = guiCreateStaticImage(350, 270, 200, 250, "images/menu.png", false) infol = guiCreateLabel(0.27, 0.05, 0.80, 0.30,"Ingresa",true,login_window2) guiSetFont(infol,font[1]) infol2 = guiCreateLabel(0.38, 0.16, 0.80, 0.30,"Usuario",true,login_window2) guiSetFont(infol2,font[1]) infol3 = guiCreateLabel(0.36, 0.38, 0.80, 0.30,"Contraseña",true,login_window2) guiSetFont(infol3,font[1]) login_username = guiCreateEdit(30, 60, 134, 28, "", false, login_window2) guiSetAlpha(login_username, 0.60) login_password = guiCreateEdit(30, 120, 134, 28, "", false, login_window2) guiSetAlpha(login_password, 0.60) guiEditSetMasked(login_password, true) loginbutt = guiCreateButton(0.14,0.695,0.695,0.110,"Login",true,login_window2,"login") addEventHandler ( "onClientGUIClick", loginbutt, function() if idb == true then end username = guiGetText(login_username) password = guiGetText(login_password) if username ~= "" and password ~= "" then triggerServerEvent("onClientSendLoginDataToServer", getLocalPlayer(), username, password) end end, false ) config = xmlLoadFile("fragconf.xml") if config then uname = xmlNodeGetAttribute(config,"username") pass = xmlNodeGetAttribute(config,"pass") guiSetText(login_username,uname) guiSetText(login_password,pass) else config = xmlCreateFile("fragconf.xml","account") xmlNodeSetAttribute(config, "username", "") xmlNodeSetAttribute(config, "pass", "") xmlSaveFile(config) end end addEventHandler("onClientResourceStart", resourceRoot, function () loginPanel() setPlayerHudComponentVisible ("radar", false ) setTimer(function() ped = createPed ( 0,862.5757,-1391.8000488281,13.49999961853 ) setCameraMatrix(864.5232,-1395.6383056641,14.550140380859) end,1000,1) guiSetInputMode("no_binds_when_editing") fadeCamera (true) end) player = getLocalPlayer() local k = 0 function rotatepedd(key,state,arg) if arg == "up" then if k+15 <= 360 then k = k + 15 else k = 0 end local rx,ry,rz = getElementRotation(ped) setElementRotation(ped,rx,ry,k) else if k+15 <= 360 then --setElementVelocity(myPed,1,1,1) k = k - 15 else k = 0 end local rx,ry,rz = getElementRotation(ped) setElementRotation(ped,rx,ry,k) end end bindKey("mouse_wheel_up","down",rotatepedd,"up") bindKey("mouse_wheel_down","down",rotatepedd) bindKey("1","down",rotatepedd,"up") bindKey("2","down",rotatepedd) ---------------------------------------------- ---------------------------------------------------------------------------------- function finishlogin() destroyElement(ped) destroyElement(GUIEditor.window[1]) destroyElement(login_login) destroyElement(charbutton) destroyElement(login_cj) destroyElement(login_exit) destroyElement(login_register) config = xmlLoadFile("fragconf.xml") if config then config = xmlLoadFile("fragconf.xml") xmlNodeSetAttribute(config, "username",guiGetText(login_username)) xmlNodeSetAttribute(config, "pass",guiGetText(login_password)) xmlSaveFile(config) guiSetVisible(login_bg,false) guiSetVisible(login_window,false) showCursor(false) guiSetVisible(register_window,false) guiSetVisible(login_window2,false) unbindKey("mouse_wheel_up","down",rotatepedd,"up") unbindKey("mouse_wheel_down","down",rotatepedd) unbindKey("1","down",rotatepedd,"up") unbindKey("2","down",rotatepedd) end end addEvent("onPlayerDoneLogin", true) addEventHandler("onPlayerDoneLogin", getRootElement(), finishlogin) ---------------------------------------------------------------------------------- function wear(textures, models, i) addPedClothes(ped, textures, models, i) end addEvent("wearit",true) addEventHandler("wearit",getRootElement(),wear) GUIEditor = { button = {}, window = {}, label = {} } GUIEditor.window[1] = guiCreateStaticImage(600, 270, 199, 258, "images/menu.png", false) guiSetVisible(GUIEditor.window[1],false) label11 = guiCreateLabel(0.34, 0.055, 0.80, 0.30,"Personaje",true,GUIEditor.window[1]) guiSetFont(label11,font[1]) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFF0000") -- Glasses GUIEditor.label[1] = guiCreateLabel(0, 0, 0, 0, "", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(0, 0, 0, 0, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(0, 0, 0, 0, "", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "center") GUIEditor.button[2] = guiCreateButton(0, 0, 0, 0, "", false, GUIEditor.window[1]) -- Hats GUIEditor.label[3] = guiCreateLabel(0, 0, 0, 0, "", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(0, 0, 0, 0, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(0, 0, 0, 0, "", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[4], "center") GUIEditor.button[4] = guiCreateButton(0, 0, 0, 0, "", false, GUIEditor.window[1]) -- Shirts GUIEditor.label[5] = guiCreateLabel(10, 88, 42, 17, "Poleras:", false, GUIEditor.window[1]) GUIEditor.button[5] = guiCreateButton(72, 88, 30, 23, "<-", false, GUIEditor.window[1]) GUIEditor.label[8] = guiCreateLabel(112, 88, 36, 23, "OFF", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[8], "default-bold-small") guiLabelSetHorizontalAlign(GUIEditor.label[8], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[8], "center") GUIEditor.button[8] = guiCreateButton(156, 88, 30, 23, "->", false, GUIEditor.window[1]) -- Trousers GUIEditor.label[6] = guiCreateLabel(10, 115, 52, 19, "Pantalones:", false, GUIEditor.window[1]) GUIEditor.button[6] = guiCreateButton(72, 115, 30, 23, "<-", false, GUIEditor.window[1]) GUIEditor.label[9] = Link to comment
DBY Posted July 31, 2016 Share Posted July 31, 2016 Te he hecho este script, con esto estarás seguro de que siempre se guardará y cargará la ropa del CJ. function saveClothes(account) local account = not isElement(account) and getPlayerAccount(source) or account if account then local _table = {} for i = 0, 17 do local texture, model = getPedClothes(source, i) if texture and model then table.insert(_table, {texture, model, i}) end end setAccountData(account, "cjclothes", toJSON(_table)) end end addEventHandler("onPlayerWasted", root, saveClothes) addEventHandler("onPlayerQuit", root, saveClothes) addEventHandler("onPlayerLogout", root, saveClothes) function loadClothes() local account = not account and getPlayerAccount(source) or account if account then local clothes = getAccountData(account, "cjclothes") if clothes then local clothes = fromJSON(clothes) setElementModel(source, 0) for i = 1, #clothes do local data = clothes[i] addPedClothes(source, data[1], data[2], data[3]) end end end end addEventHandler("onPlayerLogin", root, loadClothes) addEventHandler("onPlayerSpawn", root, loadClothes) Link to comment
DeathMta Posted July 31, 2016 Author Share Posted July 31, 2016 Gracias lo probare , pero lo que digo es que al editar mi cj solo guarda el collar menos la ropas Link to comment
aka Blue Posted July 31, 2016 Share Posted July 31, 2016 El código de @Dannys deberia funcionarte correctamente. Link to comment
DeathMta Posted July 31, 2016 Author Share Posted July 31, 2016 ME SALE ESTO: addEventHandler ( "onClientGUIClick", saveCJ, function() xmlsave = xmlCreateFile("clothes.xml","root") xmlNodeSetValue(xmlCreateChild(xmlsave,"Name"), getPlayerName(player)) for i, all in ipairs(tbl2) do if guiGetText(all[2]) ~= "OFF" then itemID = all[1] quant = guiGetText(all[2]) xmlNodeSetValue(xmlCreateChild(xmlsave, "id"..itemID), tonumber(quant)) end end xmlSaveFile(xmlsave) xmlUnloadFile(xmlsave) end) Link to comment
aka Blue Posted July 31, 2016 Share Posted July 31, 2016 Que tu entiendas tu código no significa que los demás seamos adivinos, no entiendo nada. Link to comment
DeathMta Posted July 31, 2016 Author Share Posted July 31, 2016 como te explico lo que mande ese la funcion de un boton llamado "GUARDA CJ" que guarda los clothes sin otro script, pero me da ese error de xmlNodeSetValue(xmlCreateChild(xmlsave,"Name"), getPlayerName(player)) Link to comment
Tomas Posted July 31, 2016 Share Posted July 31, 2016 como te explico lo que mande ese la funcion de un boton llamado "GUARDA CJ" que guarda los clothes sin otro script, pero me da ese error de xmlNodeSetValue(xmlCreateChild(xmlsave,"Name"), getPlayerName(player)) xmlNodeSetValue(xmlCreateChild(xmlsave,"Name"), getPlayerName(localPlayer)) Link to comment
DeathMta Posted July 31, 2016 Author Share Posted July 31, 2016 ahora me sale este error: Bad Argument: @"xmlNodeSetValue" [Expected string at argument 2,got nil] xmlNodeSetValue(xmlCreateChild(xmlsave, "id"..itemID), tonumber(quant)) Link to comment
Recommended Posts