Booo Posted April 21, 2012 Share Posted April 21, 2012 client win = guiCreateWindow(140,69,596,460,"save carr",false) save = guiCreateButton(474,417,113,34,"save",false,win) GetPositon = guiCreateButton(495,132,83,26,"GetPositon",false,win) x = guiCreateEdit(9,80,96,27,"",false,win) guiSetAlpha(x,0.5) z = guiCreateEdit(11,155,96,27,"",false,win) guiSetAlpha(z,0.5) y = guiCreateEdit(10,119,96,27,"",false,win) guiSetAlpha(y,0.5) function GetPositionzer(button,state) local thisPlayer = getLocalPlayer() local xp, yp, zp = getElementPosition(thisPlayer) guiSetText ( x, xp ) guiSetText ( y, yp ) guiSetText ( z, zp ) end addEventHandler("onClientGUIClick", GetPositon, GetPositionzer, false) function saveer(button,state) -- local root = xmlLoadFile ("car.xml") p_x5 = guiGetText(x) -- x p_y5 = guiGetText(y) -- y p_z5 = guiGetText(z) -- z if carRoot then else local carRoot = xmlCreateFile("car.xml","newcar") local newCar = xmlCreateChild (carRoot,"cars") xmlNodeSetAttribute (newCar,"x",p_x5) xmlNodeSetAttribute (newCar,"y",p_y5) xmlNodeSetAttribute (newCar,"z",p_z5) xmlSaveFile(carRoot) end end addEventHandler("onClientGUIClick", save, saveer, false) Link to comment
Michael# Posted April 21, 2012 Share Posted April 21, 2012 Your script is totally messed up. Learn: viewtopic.php?f=148&t=40809 Link to comment
Booo Posted April 21, 2012 Author Share Posted April 21, 2012 Your script is totally messed up.Learn: viewtopic.php?f=148&t=40809 Can you tell me what is wrong Link to comment
Michael# Posted April 21, 2012 Share Posted April 21, 2012 client -- why is that here? win = guiCreateWindow(140,69,596,460,"save carr",false) save = guiCreateButton(474,417,113,34,"save",false,win) GetPositon = guiCreateButton(495,132,83,26,"GetPositon",false,win) x = guiCreateEdit(9,80,96,27,"",false,win) guiSetAlpha(x,0.5) z = guiCreateEdit(11,155,96,27,"",false,win) guiSetAlpha(z,0.5) y = guiCreateEdit(10,119,96,27,"",false,win) guiSetAlpha(y,0.5) function GetPositionzer(button,state) local thisPlayer = getLocalPlayer() -- why you need this? local xp, yp, zp = getElementPosition(thisPlayer) guiSetText ( x, xp ) guiSetText ( y, yp ) guiSetText ( z, zp ) end addEventHandler("onClientGUIClick", GetPositon, GetPositionzer, false) function saveer(button,state) -- local root = xmlLoadFile ("car.xml") -- why you commented this? p_x5 = guiGetText(x) -- why you make it global p_y5 = guiGetText(y) -- y p_z5 = guiGetText(z) -- z if carRoot then -- what? what is carRoot? -- Nothing here? Cool. else local carRoot = xmlCreateFile("car.xml","newcar") local newCar = xmlCreateChild (carRoot,"cars") xmlNodeSetAttribute (newCar,"x",p_x5) -- where is x subnode created? xmlNodeSetAttribute (newCar,"y",p_y5) -- where is y subnode created? xmlNodeSetAttribute (newCar,"z",p_z5) -- where is z subnode created? xmlSaveFile(carRoot) end end addEventHandler("onClientGUIClick", save, saveer, false) Read comments. -- Correct: win = guiCreateWindow(140,69,596,460,"save carr",false) save = guiCreateButton(474,417,113,34,"save",false,win) GetPositon = guiCreateButton(495,132,83,26,"GetPositon",false,win) x = guiCreateEdit(9,80,96,27,"",false,win) guiSetAlpha(x,0.5) z = guiCreateEdit(11,155,96,27,"",false,win) guiSetAlpha(z,0.5) y = guiCreateEdit(10,119,96,27,"",false,win) guiSetAlpha(y,0.5) addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == GetPosition ) then -- if clicked element is GetPosition local nX, nY, nZ = getElementPosition ( localPlayer ) -- get player position guiSetText ( x, nX ) -- set text guiSetText ( y, nY ) -- set text guiSetText ( z, nZ ) -- set tet elseif ( source == save ) then -- else, if clicked element is save local x5, y5, z5 = guiGetText ( x ), guiGetText ( y ), guiGetText ( z ) -- get edit text local carRoot = xmlLoadFile ( 'car.xml' ) -- load file if ( carRoot ) then -- if file is loaded -- Something here, no? else carRoot = xmlCreateFile ( 'car.xml', 'newcar' ) -- create a file called car.xml local newCar = xmlCreateChild ( carRoot, 'cars' ) -- create a child cars inside newCar local nodeX, nodeY, nodeZ = xmlCreateChild ( newCar, 'x' ), xmlCreateChild ( newCar, 'y' ), xmlCreateChild ( newCar, 'z' ) -- create child x, y, z xmlNodeSetAttribute ( newCar, 'x', tonumber ( x5 ) ) -- set x value xmlnodeSetAttribute ( newCar, 'y', tonumber ( y5 ) ) -- set y value xmlNodeSetAttribute ( newCar, 'z', tonumber ( z5 ) ) -- set z value end end end ) If is there something wrong, please say. Link to comment
Booo Posted April 21, 2012 Author Share Posted April 21, 2012 client -- why is that here? win = guiCreateWindow(140,69,596,460,"save carr",false) save = guiCreateButton(474,417,113,34,"save",false,win) GetPositon = guiCreateButton(495,132,83,26,"GetPositon",false,win) x = guiCreateEdit(9,80,96,27,"",false,win) guiSetAlpha(x,0.5) z = guiCreateEdit(11,155,96,27,"",false,win) guiSetAlpha(z,0.5) y = guiCreateEdit(10,119,96,27,"",false,win) guiSetAlpha(y,0.5) function GetPositionzer(button,state) local thisPlayer = getLocalPlayer() -- why you need this? local xp, yp, zp = getElementPosition(thisPlayer) guiSetText ( x, xp ) guiSetText ( y, yp ) guiSetText ( z, zp ) end addEventHandler("onClientGUIClick", GetPositon, GetPositionzer, false) function saveer(button,state) -- local root = xmlLoadFile ("car.xml") -- why you commented this? p_x5 = guiGetText(x) -- why you make it global p_y5 = guiGetText(y) -- y p_z5 = guiGetText(z) -- z if carRoot then -- what? what is carRoot? -- Nothing here? Cool. else local carRoot = xmlCreateFile("car.xml","newcar") local newCar = xmlCreateChild (carRoot,"cars") xmlNodeSetAttribute (newCar,"x",p_x5) -- where is x subnode created? xmlNodeSetAttribute (newCar,"y",p_y5) -- where is y subnode created? xmlNodeSetAttribute (newCar,"z",p_z5) -- where is z subnode created? xmlSaveFile(carRoot) end end addEventHandler("onClientGUIClick", save, saveer, false) Read comments. -- Correct: win = guiCreateWindow(140,69,596,460,"save carr",false) save = guiCreateButton(474,417,113,34,"save",false,win) GetPositon = guiCreateButton(495,132,83,26,"GetPositon",false,win) x = guiCreateEdit(9,80,96,27,"",false,win) guiSetAlpha(x,0.5) z = guiCreateEdit(11,155,96,27,"",false,win) guiSetAlpha(z,0.5) y = guiCreateEdit(10,119,96,27,"",false,win) guiSetAlpha(y,0.5) addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == GetPosition ) then -- if clicked element is GetPosition local nX, nY, nZ = getElementPosition ( localPlayer ) -- get player position guiSetText ( x, nX ) -- set text guiSetText ( y, nY ) -- set text guiSetText ( z, nZ ) -- set tet elseif ( source == save ) then -- else, if clicked element is save local x5, y5, z5 = guiGetText ( x ), guiGetText ( y ), guiGetText ( z ) -- get edit text local carRoot = xmlLoadFile ( 'car.xml' ) -- load file if ( carRoot ) then -- if file is loaded -- Something here, no? else carRoot = xmlCreateFile ( 'car.xml', 'newcar' ) -- create a file called car.xml local newCar = xmlCreateChild ( carRoot, 'cars' ) -- create a child cars inside newCar local nodeX, nodeY, nodeZ = xmlCreateChild ( newCar, 'x' ), xmlCreateChild ( newCar, 'y' ), xmlCreateChild ( newCar, 'z' ) -- create child x, y, z xmlNodeSetAttribute ( newCar, 'x', tonumber ( x5 ) ) -- set x value xmlnodeSetAttribute ( newCar, 'y', tonumber ( y5 ) ) -- set y value xmlNodeSetAttribute ( newCar, 'z', tonumber ( z5 ) ) -- set z value end end end ) If is there something wrong, please say. Big Thank you Jayz, you're the best Link to comment
Michael# Posted April 21, 2012 Share Posted April 21, 2012 No problem And I'm not the best Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now