.:HyPeX:. Posted March 29, 2014 Posted March 29, 2014 how can this return "Error, expected number at argument 2, returned none" dxDrawRectangle(v) But outputChatbox(v) returns: 0.14191175997257 * x, 0.15364582836628 * y,( 0.37794119119644 * x ) - ( 0.14191175997257 * x ), ( 0.62109375 * y - 0.15364582836628 * y ), -1275068416 My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Castillo Posted March 29, 2014 Posted March 29, 2014 How can outputChatBox return that? and if it does, then 'v' is a string. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 How can outputChatBox return that? and if it does, then 'v' is a string. This is basically the add, how could it NOT be a string? table.insert(DrawStringTable,CursorTable.X1.." * x, "..CursorTable.Y1.." * y,( "..EndX.." * x ) - ( "..CursorTable.X1.." * x ), ( "..EndY.." * y - "..CursorTable.Y1.." * y ), "..color) My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Castillo Posted March 29, 2014 Posted March 29, 2014 So, you are passing a string to dxDrawRectangle. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Saml1er Posted March 29, 2014 Posted March 29, 2014 Just like SN said, this is how it looks like: dxDrawRectangle (" 1.0.14191175997257 * x, 0.15364582836628 * y,( 0.37794119119644 * x ) - ( 0.14191175997257 * x ), ( 0.62109375 * y - 0.15364582836628 * y ), -1275068416" ) Do you really think this will work with quotation marks ?
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 Yeah,i get it, but i want to remove the string, make it back usable. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Gallardo9944 Posted March 29, 2014 Posted March 29, 2014 use string.split to get arguments from a string. function string.split(s,d) local t = {} local i = 0 local f local match = '(.-)' .. d .. '()' if string.find(s, d) == nil then return {s} end for sub, j in string.gfind(s, match) do i = i + 1 t[i] = sub f = j end if i~= 0 then t[i+1]=string.sub(s,f) end return t end An example: local str = "a,b,c" local vals = string.split(str,",") for i,v in ipairs(vals) do outputChatBox(v) end You also need to tonumber the arguments to get your desired values. But this method... Oh gosh, someone, throw his keyboard out Code Debugger - Minimalistic MTA debug line replacement
Saml1er Posted March 29, 2014 Posted March 29, 2014 Try removing quotation marks with this: function escapeCSV (s) if string.find(s, '[,"]') then s = string.gsub(s, '"', '""') end return s end I still doubt this will work but anyway if this doesn't work then you can use galladros code.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 use string.split to get arguments from a string. function string.split(s,d) local t = {} local i = 0 local f local match = '(.-)' .. d .. '()' if string.find(s, d) == nil then return {s} end for sub, j in string.gfind(s, match) do i = i + 1 t[i] = sub f = j end if i~= 0 then t[i+1]=string.sub(s,f) end return t end An example: local str = "a,b,c" local vals = string.split(str,",") for i,v in ipairs(vals) do outputChatBox(v) end You also need to tonumber the arguments to get your desired values. But this method... Oh gosh, someone, throw his keyboard out i dont understand what str = "a,b,c" does. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Saml1er Posted March 29, 2014 Posted March 29, 2014 use string.split to get arguments from a string. function string.split(s,d) local t = {} local i = 0 local f local match = '(.-)' .. d .. '()' if string.find(s, d) == nil then return {s} end for sub, j in string.gfind(s, match) do i = i + 1 t[i] = sub f = j end if i~= 0 then t[i+1]=string.sub(s,f) end return t end An example: local str = "a,b,c" local vals = string.split(str,",") for i,v in ipairs(vals) do outputChatBox(v) end You also need to tonumber the arguments to get your desired values. But this method... Oh gosh, someone, throw his keyboard out i dont understand what str = "a,b,c" does. Its just an example. Suppose ab is a string and has commas so we need to split the values from the string so we'll use split function. local ab = "x * 0.3, y +1,x*y + 5, z - 12" local vals = string.split(str,",") for i,v in ipairs(vals) do outputChatBox(v) end Test it and you'll see.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 ah, so ab was the string, i get it now, thanks! My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 dxDrawRectangle(vals) vals is a table, how can i split the table into numbers, like the string was? else dxDrawRectangle cant do it. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Castillo Posted March 29, 2014 Posted March 29, 2014 unpack San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 unpack Tried this, but nothing is drawn. function DrawTableString() local x,y = guiGetScreenSize() for i,v in ipairs(DrawStringTable) do local str = v local vals = string.split(str,",") local a,b,c,d,e = unpack(vals) dxDrawRectangle(a,b,c,d,e) outputChatBox(a..","..b..","..c..","..d..","..e) end end addEventHandler("onClientRender", getRootElement(), DrawTableString) Output: 0.19117647409439 * x, 0.15885417163372 * y,( 0.64191174507141 * x ) - ( 0.19117647409439 * x ), ( 0.421875 * y - 0.15885417163372 * y ), -1275068416 PD: no errors in debug My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Castillo Posted March 29, 2014 Posted March 29, 2014 Well, the thing is, they'll be strings now, not numbers. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 So we're again at the start of the topic.. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 tonumber ( .. ) Returns nil.. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Castillo Posted March 29, 2014 Posted March 29, 2014 function DrawTableString ( ) local x,y = guiGetScreenSize ( ) for _, v in ipairs ( DrawStringTable ) do local vals = { } for _, value in ipairs ( string.split ( v, "," ) ) do table.insert ( vals, tonumber ( value ) ) end dxDrawRectangle ( unpack ( vals ) ) end end addEventHandler ( "onClientRender", getRootElement(), DrawTableString ) P.S: Why are you using a custom function to split it? MTA has "split" function which does the same. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
.:HyPeX:. Posted March 29, 2014 Author Posted March 29, 2014 Expected number at argument 2, got none... My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
.:HyPeX:. Posted March 30, 2014 Author Posted March 30, 2014 Why are you storing it as a string anyway? Not sure, i'll probably switch to a table.. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
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