addtimer issues

evilpuncker

vai se tratar garota
Messages
2,178
Points
0
Age
109
Location
bronzil
Github
EPuncker
Emulator
Client Version
2019-05-30a MAIN
I tried creating a command that will execute different actions on different intervals, and using the command will turn them ON/OFF, but it is just not working, what am I doing wrong?

Code:
-	script	test	FAKE_NPC,{
OnInit:
	bindatcmd("test", strnpcinfo(NPC_NAME)+"::OnAtcommand", 0, 99);
	end;

OnAtcommand:
	atcommand("@test"); // executes the "test" command ON/OFF
	if (.@on == 1) {
		.@on = 0;
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	} else {
		.@on = 1;
		// 1000 = 1 second | 60000 = 1 min | 3600000 = 1 hour
		addtimer(10000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		addtimer(300, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	}
	end;

OnEvent1:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		end;
	}
	// do something X
	addtimer(10000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
	end;

OnEvent2:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		end;
	}
	// do something Y
	addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
	end;

OnEvent3:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	}
	// do something Z
	addtimer(300, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
	end;
}
 
Back
Top