Thanks guys I wasn't thinking right
I re-wrote the function and it works just fine
here it is
function RTS_Camera()
RTSCX=camera position x(RTSCamera)
RTSCY=camera position y(RTSCamera)
RTSCZ=camera position z(RTSCamera)
if mousey()=>(screen height()-20)
position camera RTSCamera,RTSCX,RTSCY,RTSCZ-2
endif
if mousey()<5
position camera RTSCamera,RTSCX,RTSCY,RTSCZ+2
endif
if mousex()=>(screen width()-20)
position camera RTSCamera,RTSCX+2,RTSCY,RTSCZ
endif
if mousex()<5
position camera RTSCamera,RTSCX-2,RTSCY,RTSCZ
endif
if mousez()<0
position camera RTSCamera,RTSCX,RTSCY-2,RTSCZ
endif
if mousez()>0
position camera RTSCamera,RTSCX,RTSCY+2,RTSCZ
endif
endfunction