Xwad Posted August 24, 2016 Share Posted August 24, 2016 Why is ths code not working? i got it from the wiki: https://wiki.multitheftauto.com/wiki/GetCursorMoveOn debugscript: ERROR: attempt to concatenate global 'moveOn (a nil value) bad Argumentum outpuChatBox expected number at argument 2, got player code client side function getCursorMoveOn() if ( isCursorShowing() ) then left = "left" right = "right" up = "up" down = "down" zero = "nil" if getElementData(localPlayer,"movew") == right then return right elseif getElementData(localPlayer,"movew") == left then return left elseif getElementData(localPlayer,"movew") == up then return up elseif getElementData(localPlayer,"movew") == down then return down elseif getElementData(localPlayer,"movew") == zero then return false end end end function executeMoveOn(cursorX,cursorY) if ( isCursorShowing() ) then setElementData(localPlayer,"moveX",cursorX) setElementData(localPlayer,"moveY",cursorY) if cursorX > cX then setElementData(localPlayer,"movew",right) elseif cursorX < cX then setElementData(localPlayer,"movew",left) elseif cursorY > cY then setElementData(localPlayer,"movew",down) elseif cursorY < cY then setElementData(localPlayer,"movew",up) end end end addEventHandler("onClientCursorMove",root,executeMoveOn) setTimer( function() if ( isCursorShowing() ) then local curX = getElementData(localPlayer,"moveX") local curY = getElementData(localPlayer,"moveY") if cursorX == cX then setElementData(localPlayer,"movew",zero) elseif cursorY == cY then setElementData(localPlayer,"movew",zero) end end end ,50,0) function previousM() if ( isCursorShowing() ) then cX = getElementData(localPlayer,"moveX") cY = getElementData(localPlayer,"moveY") end end setTimer(previousM,50,0) bindKey ("m", "down", function() showCursor( not isCursorShowing() ) end ) addEventHandler("onClientCursorMove",root, function() if ( isCursorShowing() ) then moveOn = getCursorMoveOn() outputChatBox("cursor is moving on : " .. moveOn, localPlayer) end end ) Link to comment
novo Posted August 25, 2016 Share Posted August 25, 2016 First error is caused by the function getCursorMoveOn, as it does not return any value in case isCursorShowing() returns false at line 2. Second error is because outputChatBox only accepts a player as second argument server-side (visibleTo), whilst client does not and thus expects a number (r). Link to comment
Xwad Posted August 26, 2016 Author Share Posted August 26, 2016 i dont really understansd this now:/ so what do i have to do to fix that? 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