[Tutorial] How to make a stopwatch
Started by Fatalis
09/06/2008 23:17
Page 1 of 1
Fatalis09/06/2008 23:17(edited 09/06/2008 23:36)
http://fatalis.ampaste.net/f197be2e1
kielorz06/03/2009 17:45
and how to make a stopwatch with an accuracy of thousandths?
tolsty02/04/2009 01:51(edited 02/04/2009 02:01)
#include
new bool:timer_started[32]
new Float:timer[32]
public plugin_init() {
register_plugin("Stopwatch", "Tolsty", "1.0");
set_task(0.1,"timer_task",20000,"",0,"ab")
register_clcmd("start","startcmd")
register_clcmd("stop","stopcmd")
register_clcmd("say /start","startcmd")
register_clcmd("say /stop","stopcmd")
}
public timer_task() {
for(new i=1;i<=get_maxplayers();i++) {
if(is_user_alive(i) && timer_started[i-1]) {
new Float:sec = get_gametime() - timer[i-1], min
if((sec / 60.0) >= 1) {
min = floatround(sec / 60.0,floatround_floor)
sec -= min * 60
}
client_print(i, print_center , "%d : %f",min ,sec)
}
}
}
public startcmd(id) {
timer_started[id-1] = true
timer[id-1] = get_gametime()
}
public stopcmd(id) {
new min
new Float:sec = get_gametime() - timer[id-1]
if((sec / 60.0) >= 1) {
min = floatround(sec / 60.0,floatround_floor)
sec -= min * 60
}
timer_started[id-1] = false
client_print(id, print_center, "%d : %f",min ,sec)
}Page 1 of 1
Please log in to post replies.