.:HyPeX:. Posted March 27, 2014 Share Posted March 27, 2014 (edited) well loadstring is not doing anything, and color returned is just crazy values, like -168586 outputChatBox("#00aaffdxDrawRectangle Script by HyPeX Started", 255,255,255,true) function TurnRectangle(cmd,shit) if DxRectangleDraw then outputChatBox("#00aaffPlease finish the steps or restart the script.", 255,255,255,true) return end DxRectangleDraw = true outputChatBox("#00aaffPlease Do '/color R G B A' now", 255,255,255,true) end addCommandHandler("dxRec", TurnRectangle) function SetRecColour(cmd,valA, valB, valC, valD) if not valD then outputChatBox("#00aaffPlease Do '/color R G B A' -> You're missing R G B A", 255,255,255,true) return end if not DxRectangleDraw then outputChatBox("#00aaffPlease Do '/dxRec' first!", 255,255,255,true) return else outputChatBox("#00aaffPlease Draw an Area now. (Press and hold)", 255,255,255,true) color = tocolor(valA, valB, valC, valD) showCursor(true) end end addCommandHandler("color", SetRecColour) function OnClientCursorClick(button, state) if not DxRectangleDraw then outputChatBox("#00aaffPlease Do '/dxRec' first!", 255,255,255,true) return end if not color then outputChatBox("#00aaffPlease Do '/color R G B A' first!", 255,255,255,true) return end if state == "down" then CursorTable = {} CursorTable.X1, CursorTable.Y1 = getCursorPosition() outputChatBox("#00aaffPlease Hold and Drag the cursor.", 255,255,255,true) addEventHandler("onClientRender", getRootElement(), DrawExampleRec) end if state == "up" then CursorTable.X2, CursorTable.Y2 = getCursorPosition() removeEventHandler("onClientRender", getRootElement(), DrawExampleRec) showCursor(false) outputChatBox("#00aaffRectangle Selection is over, Please do '/CopyRec' to copy to clipboard", 255,255,255,true) end end addEventHandler("onClientClick", getRootElement(), OnClientCursorClick) function DrawExampleRec() if not CursorTable then return end if not color then outputChatBox("#00aaffColor error, please check the setps.", 255,255,255,true) removeEventHandler("onClientRender", getRootElement(), DrawExampleRec) return end local x,y = guiGetScreenSize() EndX, EndY = getCursorPosition() dxDrawRectangle(CursorTable.X1 * x, CursorTable.Y1 * y,( EndX * x ) - ( CursorTable.X1 * x ), ( EndY * y - CursorTable.Y1 * y ), color) end function CopyRec(cmd) if not color then outputChatBox("#00aaffPlease check the function, color missing", 255,255,255,true) return end if not CursorTable.X2 then outputChatBox("#00aaffPlease check the function, end corner of rectangle is missing.", 255,255,255,true) return end DrawString = "function DrawRectangle()".."\r\n".."local x,y = guiGetScreenSize()".."\r\n".."local color = "..color.."".."\r\n".."local EndY = "..EndY.."".."\r\n".."local EndX = "..EndX.."".."\r\n".."local CursorTableY1 = "..CursorTable.Y1.."".."\r\n".."local CursorTableX1 = "..CursorTable.X1.." ".."\r\n".."dxDrawRectangle(CursorTableX1 * x, CursorTableY1 * y,( EndX * x ) - ( CursorTableX1 * x ), ( EndY * y - CursorTableY1 * y ), color)".."\r\n".."end ".."\r\n".."addEventHandler('onClientRender', getRootElement(), DrawRectangle)" setClipboard(DrawString) outputConsole(DrawString) outputChatBox("#00aaffDraw string was saved, you can now test it with '/TestRec'.", 255,255,255,true) end addCommandHandler("CopyRec", CopyRec) function TestRec() if not DrawString then outputChatBox("#00aaffPlease do the function first, Draw string doesnt exist.", 255,255,255,true) return loadstring(DrawString) end end addCommandHandler("TestRec", TestRec) Random test: function DrawRectangle() local x,y = guiGetScreenSize() local color = 1677721600 local EndY = 0.40234375 local EndX = 0.6860294342041 local CursorTableY1 = 0.25260415673256 local CursorTableX1 = 0.28529411554337 dxDrawRectangle(CursorTableX1 * x, CursorTableY1 * y,( EndX * x ) - ( CursorTableX1 * x ), ( EndY * y - CursorTableY1 * y ), color) end addEventHandler('onClientRender', getRootElement(), DrawRectangle) PD: Somehow, that crazy number colour, works as if tocolor, lol. Edited March 27, 2014 by Guest Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 loadstring doesn't work because you put it after 'return'. Link to comment
.:HyPeX:. Posted March 27, 2014 Author Share Posted March 27, 2014 (edited) loadstring doesn't work because you put it after 'return'. Moved it down, with no result. function TestRec() if not DrawString then outputChatBox("#00aaffPlease do the function first, Draw string doesnt exist.", 255,255,255,true) return end loadstring(DrawString) outputChatBox("#00aaffRunning the string.", 255,255,255,true) end addCommandHandler("TestRec", TestRec) i get the output thought.. (running) Edited March 27, 2014 by Guest Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 outputConsole(DrawString) Does it output correct stuff? Link to comment
.:HyPeX:. Posted March 27, 2014 Author Share Posted March 27, 2014 outputConsole(DrawString) Does it output correct stuff? Yes. (Read the first post: Random test.) Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 Everything looks fine, hmm. Any errors? Put outputChatBox after loadstring to check if script gets there. Link to comment
.:HyPeX:. Posted March 27, 2014 Author Share Posted March 27, 2014 Yes: http://i.imgur.com/ivrp2va.png http://i.imgur.com/WEbpQpC.png http://i.imgur.com/NWUYZ2j.png Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 Well I can't see an error, maybe someone with more experience would help you. Link to comment
.:HyPeX:. Posted March 27, 2014 Author Share Posted March 27, 2014 Bump still need help, tried to use runcode with crun and got this.. Executing client-side command: function DrawRectangle() local x,y = guiGetScreenSize() dxDrawRectangle(0.26397058367729 * x, 0.24869792163372 * y,( 0.80588233470917 * x ) - ( 0.26397058367729 * x ), ( 0.43098959326744 * y - 0.24869792163372 * y ), -1275068416) end addEventHandler( Error: [string "function DrawRectangle() local x,y = guiGetScreenSize() dxDrawR..."]:1: unexpected symbol near '<eof> To make it work i did string like this: TestString = "function DrawRectangle() local x,y = guiGetScreenSize() dxDrawRectangle("..CursorTable.X1.." * x, "..CursorTable.Y1.." * y,( "..EndX.." * x ) - ( "..CursorTable.X1.." * x ), ( "..EndY.." * y - "..CursorTable.Y1.." * y ), "..color..") end addEventHandler('onClientRender', getRootElement(), DrawRectangle)" Gives same result as original string try.. Link to comment
Castillo Posted March 27, 2014 Share Posted March 27, 2014 TestString = [[function DrawRectangle() local x,y = guiGetScreenSize() dxDrawRectangle("..CursorTable.X1.." * x, "..CursorTable.Y1.." * y,( "..EndX.." * x ) - ( "..CursorTable.X1.." * x ), ( "..EndY.." * y - "..CursorTable.Y1.." * y ), "..color..") end addEventHandler('onClientRender', getRootElement(), DrawRectangle)]] Try that string instead. Link to comment
Castillo Posted March 28, 2014 Share Posted March 28, 2014 Do you get any errors? can you post the current code? Link to comment
.:HyPeX:. Posted March 28, 2014 Author Share Posted March 28, 2014 the whole code is @first post. Link to comment
Castillo Posted March 28, 2014 Share Posted March 28, 2014 Try with this function: function runString ( commandstring ) local notReturned local commandFunction, errorMsg = loadstring ( "return ".. commandstring ) if ( errorMsg ) then notReturned = true commandFunction, errorMsg = loadstring ( commandstring ) end if ( errorMsg ) then return false end local results = { pcall ( commandFunction ) } if ( not results [ 1 ] ) then return false end end function TestRec ( ) if ( not DrawString ) then outputChatBox ( "#00aaffPlease do the function first, Draw string doesnt exist.", 255, 255, 255, true ) return end runString ( DrawString ) end addCommandHandler ( "TestRec", TestRec ) Link to comment
.:HyPeX:. Posted March 29, 2014 Author Share Posted March 29, 2014 Worked, but how can i turn off the test? 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