ertlflorian1 Posted February 19, 2013 Share Posted February 19, 2013 Hi please help me my script don't work?? for index, node in ipairs(children) do local xx = tonumber(xmlNodeGetAttribute(node, "x")) local yy = tonumber(xmlNodeGetAttribute(node, "y")) local zz = tonumber(xmlNodeGetAttribute(node, "z")) triggerClientEvent (getRootElement(), "guittf", xx, yy, zz) [/][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2385.53515625'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2342.5126953125'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2342.841796875'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2341.5732421875'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2341.49609375'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2342.712890625'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2340.861328125'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2342.4248046875'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2341.888671875'][14:54:25] WARNING: pos\server.lua:103: Bad argument @ 'triggerClientEvent' [Expected element at argument 3, got number '2343.8037109375'] Link to comment
Vision Posted February 19, 2013 Share Posted February 19, 2013 for index, node in ipairs(children) do local xx = tonumber(xmlNodeGetAttribute(node, "x")) local yy = tonumber(xmlNodeGetAttribute(node, "y")) local zz = tonumber(xmlNodeGetAttribute(node, "z")) triggerClientEvent ("guittf", root, xx, yy, zz) Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 Thanks another Question how i can set that such every koordinates a new line will beginn? this ist the memo: tff = guiCreateMemo(20, 145, 478, 368, "\n", false, OutputFenster) function newertext (xx, yy, zz) guiSetText (tff, xx..", "..yy..", "..zz) end addEvent ("guittf", true) addEventHandler ("guittf", getRootElement(), newertext) Link to comment
csiguusz Posted February 19, 2013 Share Posted February 19, 2013 guiSetText (tff, xx.."\n"..yy.."\n"..zz) Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 I dont mean this Link to comment
csiguusz Posted February 19, 2013 Share Posted February 19, 2013 I dont mean this Then do you want a new line after every three cordinates? guiSetText (tff, xx..", "..yy..", "..zz.."\n") Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 I mean like this guiSetText (tff, xx..", "..yy..", "..zz.."\n") But ther will only be shown the first entry of the xml. Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 You need to set "tff" element's text to this: "current text + new coordinates": local text = string.format ( "%s \n%d, %d, %d", guiGetText ( tff ), xx, yy, zz ); guiSetText ( tff, text ); Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 Thank you so much but i will that it dont look so -2434, -596, 132 but so -2434.854156414, -596.56486, 132.486421884 sorry for really bad english Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 I didn't understand what you said, can you explain better? Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 I will that it dont look like -2434, -596, 132 but rather -2434.854156414, -596.56486, 132.486421884 Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 How do you get the coordinates? Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 Thank you I have solved it now local text = string.format ( "%s %s, %s, %s", guiGetText ( tff ), xx, yy, zz ); guiSetText ( tff, text ); Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 That doesn't make sense, removing the '\n' wouldn't solve the problem, unless you're talking about a completely different thing and you just didn't explain it well. Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 Another Question how can i make that (where number??) that that will numbered consecutively guiSetText ( tff, '[number??]="'..text..'",' ); Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 Why it dont work? local text = string.format ("%s %s, %s, %s", guiGetText ( tff ), xx, yy, zz ); guiSetText ( tff, '['..index..']="'..text..'",' ); Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 Because 'index' isn't declared. Link to comment
ertlflorian1 Posted February 19, 2013 Author Share Posted February 19, 2013 How i can declare index? Link to comment
Anderl Posted February 19, 2013 Share Posted February 19, 2013 http://lua.gts-stolberg.de/en/Variablen.php Anyway, that question is wrong. You should ask how to do it instead. From the server-side, when you do an iteration through the whole XML file, you declared an "index" variable. Pass it to the client event and you're done. Link to comment
ertlflorian1 Posted February 20, 2013 Author Share Posted February 20, 2013 My code now seems like : server: function outputcode (gme) local pname = getPlayerName (gme) if (fileExists ("koordinaten.xml") ) then local rootnode = xmlLoadFile("koordinaten.xml") local children = xmlNodeGetChildren(rootnode) for index, node in ipairs(children) do local xx = tonumber(xmlNodeGetAttribute(node, "x")) local yy = tonumber(xmlNodeGetAttribute(node, "y")) local zz = tonumber(xmlNodeGetAttribute(node, "z")) triggerClientEvent ("guittf", root, index,xx, yy, zz) end end end addEvent ("on1", true) addEventHandler("on1", getRootElement(), outputcode) client: ........... tff = guiCreateMemo(10, 81, 489, 443, "Klicke auf eine Zahl!", false, OutputFenster) ............ function newertext (index,xx, yy, zz) local text = string.format ("%s %d, %d, %d", guiGetText ( tff ), xx, yy, zz ); guiSetText ( tff, '['..index..']="'..text..'",' ); end addEvent ("guittf", true) addEventHandler ("guittf", getRootElement(), newertext) in the EditBox it seems so: [3]=[2]=[1]= -751.2763671875, 1008.7109375, 16.795833587646, -754.0029296875, 1010.09375, 17.559013366699, -756.8203125, 1011.521484375, 18.040607452393, How i can make that it seems so: [1]="-751.2763671875, 1008.7109375, 16.795833587646", [2]="-754.0029296875, 1010.09375, 17.559013366699", [3]="-756.8203125, 1011.521484375, 18.040607452393", Link to comment
ertlflorian1 Posted February 20, 2013 Author Share Posted February 20, 2013 Nobody an idea? Link to comment
csiguusz Posted February 20, 2013 Share Posted February 20, 2013 try this: ........... tff = guiCreateMemo(10, 81, 489, 443, "", false, OutputFenster) ............ function newertext (index,xx, yy, zz) local text = string.format ("%s [%s]=\"%s, %s, %s\"", guiGetText ( tff ),index, xx, yy, zz ); guiSetText ( tff, text ); end addEvent ("guittf", true) addEventHandler ("guittf", getRootElement(), newertext) Link to comment
Anderl Posted February 20, 2013 Share Posted February 20, 2013 My code now seems like :server: function outputcode (gme) local pname = getPlayerName (gme) if (fileExists ("koordinaten.xml") ) then local rootnode = xmlLoadFile("koordinaten.xml") local children = xmlNodeGetChildren(rootnode) for index, node in ipairs(children) do local xx = tonumber(xmlNodeGetAttribute(node, "x")) local yy = tonumber(xmlNodeGetAttribute(node, "y")) local zz = tonumber(xmlNodeGetAttribute(node, "z")) triggerClientEvent ("guittf", root, index,xx, yy, zz) end end end addEvent ("on1", true) addEventHandler("on1", getRootElement(), outputcode) client: ........... tff = guiCreateMemo(10, 81, 489, 443, "Klicke auf eine Zahl!", false, OutputFenster) ............ function newertext (index,xx, yy, zz) local text = string.format ("%s %d, %d, %d", guiGetText ( tff ), xx, yy, zz ); guiSetText ( tff, '['..index..']="'..text..'",' ); end addEvent ("guittf", true) addEventHandler ("guittf", getRootElement(), newertext) in the EditBox it seems so: [3]=[2]=[1]= -751.2763671875, 1008.7109375, 16.795833587646, -754.0029296875, 1010.09375, 17.559013366699, -756.8203125, 1011.521484375, 18.040607452393, How i can make that it seems so: [1]="-751.2763671875, 1008.7109375, 16.795833587646", [2]="-754.0029296875, 1010.09375, 17.559013366699", [3]="-756.8203125, 1011.521484375, 18.040607452393", If you read the code, you'll understand that all you're doing is "[index] = all text from the memo + new coordinates". Link to comment
csiguusz Posted February 20, 2013 Share Posted February 20, 2013 If you read the code, you'll understand that all you're doing is "[index] = all text from the memo + new coordinates". +1 Dont' just copy, try to understand. 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