How to make button and make something execute 'on click' you must find by yourself.
This is code you must execute to make player walk north 5 times per second (every 0.2 sec):
PHP:
myLoopEventId = 0
function myLoop()
local dashWalk = true
g_game.walk(Directions.North, dashWalk)
-- execute same function after 0.2 sec, function call itself = we good loop (but with delay)
myLoopEventId = scheduleEvent(myLoop, 200)
end
-- this will start event
myLoop()
-- to stop execution of event you must call:
removeEvent(myLoopEventId)
There is also code you need to call to 'stop' this event.
You can't use 'for' or 'while', because normal 'loop' will execute in 0.001 sec (and for time of execution it will freez client).
You can't use any 'sleep' command, because it will freez whole client for time of 'sleep'.
For your kind of problems there is 'scheduleEvent' function which execute your function with some delay. In OTSes is same function, but under name 'addEvent'.