最初のクラスです:ブールはいつもここに真
package Chatter;
public class Timer
{
private long period;
private long start;
private long CurrentTime = System.currentTimeMillis();
public Timer(long period)
{
this.period = period;
start = System.currentTimeMillis();
}
public long getElapsed()
{
return System.currentTimeMillis() - start;
}
public long getRemaining()
{
return period - getElapsed();
}
public boolean isRunning()
{
return getElapsed() <= period;
}
public long TimetoExcucte(int Seconds){
return CurrentTime + (Seconds * 1000);
}
public boolean Reached(int Seconds){
return System.currentTimeMillis() > TimetoExcucte(Seconds);
keyboard.typeString("Test", true);
}
public void reset()
{
start = System.currentTimeMillis();
}
public void stop()
{
period = 0;
}
public static String format(long milliSeconds)
{
long secs = milliSeconds/1000L;
return String.format("%02d:%02d:%02d", new Object[] {
Long.valueOf(secs/3600L), Long.valueOf((secs % 3600L)/60L), Long.valueOf(secs % 60L)
});
}
}
、ここでは、第二のクラスです:
package Chatter;
import java.util.List;
import Chatter.Timer;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(name="Chatter", author="Chatter", version=1, info="Chatter", logo="")
public class Chatter extends Script{
private static long Lastime = 0;
private Dialogue Dialogue;
boolean said;
int Index;
Timer runTimer;
public void onStart() throws InterruptedException {
runTimer = new Timer(0);
}
public int onLoop() throws InterruptedException {
if(runTimer.Reached(5)){
keyboard.typeString("Hoi", true);
}else{
log("Waiting");
}
return 500;
}
private void Respond() throws InterruptedException {
//Message sending method
if(said == true){
sleep(random(2000,4500));
Dialogue = new Dialogue();
List<String> RespondSpeach = Dialogue.getNumberList1();
keyboard.typeString(RespondSpeach.get(Index) , true);
said = false;
}
}
public void onMessage(Message m) throws InterruptedException {
//Message recieveing method
if(m.getUsername().equalsIgnoreCase(""))
Dialogue = new Dialogue();
List<String> ReceivedSpeach = Dialogue.getNumberList();
for (String word : ReceivedSpeach){
if (m.getMessage().contains(word)){
Index = ReceivedSpeach.indexOf(word);
said = true;
}
}
}
}
ので、最初のクラスはそれの名前として機能タイマーはタイマーと何が生成されます私がしたいのは、スクリプトが5秒ごとにアクションを実行するようにすることです
このスクリプトはOsbot http://osbot.org/で実行されます。実行したいアクションは、スクリプトにTest
5秒ごとにスクリプトが迷惑メールを維持するTest
スパムの代わりに5秒ごとにブール値を使用するにはどうすればよいですか?
実際のコードを表示してください。そのコードはコンパイルされないので、実際のコードではありません。 – Kayaman
このコードはコンパイルできません。 'keyboard.typeString(" Test ");'に到達できません。 – davidxxx
フル・クラスを追加 –