Junior Member
|
10-16-2021
, 18:50
TFC Stopwatch Plugin
|
#1
|
Doing a stop watch plugin.. basically you start at one part and say !start, and itll do a stopwatch until you get to the next part and do !time
problem is coming when I am doing a 1/0 switch on timerBool and that seems to not be carrying over to other functions.. pretty sure I properly made it a global? The minutes, seconds, and ticks arent carrying over to the stopTimer function and are returning 0:00.0 when i get rid of the timerBool just to allow it to function.
*I could* get away with not using the timerBool, but then I wouldnt be able to, in the future, allow them to reset their time. But ya, even without the timerBool there, the minutes, seconds and ticks are still returning 0:00.0 on stopTimer()
Did I do something wrong with setting globals???
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include < fakemeta >
#include < hamsandwich >
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Mark"
new ticks[33]
new seconds[33]
new minutes[33]
new timerBool[33]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say !start", "startTimer", 4, "", -1);
register_clcmd("say !time", "stopTimer", 4, "", -1);
//register_clcmd("say !origin", "stopTimer", 4, "", -1);
}
public startTimer(id){
if(timerBool[id] == 0){
new origin[33][3]
pev(id, pev_origin, origin[id]);
client_print(0, print_chat, "x:%f y:%f z:%f", origin[id][0], origin[id][1], origin[id][2]);
new lowerX = floatcmp(origin[id][0], -3504.0)
new upperX = floatcmp(origin[id][0], -2500.0)
new lowerY = floatcmp(origin[id][1], 3180.0)
new upperY = floatcmp(origin[id][1], 3850.0)
new equalZ = floatcmp(origin[id][2], -187.968750)
if((lowerX == 1) && (upperX == -1) && (lowerY == 1) && (upperY == -1) && (equalZ == 0)){
timerBool[id] = 1
set_task(0.1, "tickUpdate", 0, "", 0, "b", 0);
}
}
}
public stopTimer(id){
if(timerBool[id] == 0){
new origin[33][3]
pev(id, pev_origin, origin[id]);
client_print(0, print_chat, "x:%f y:%f z:%f", origin[id][0], origin[id][1], origin[id][2]);
new lowerX = floatcmp(origin[id][0], -1967.0)
new upperX = floatcmp(origin[id][0], -1681.0)
new lowerY = floatcmp(origin[id][1], -3824.0)
new upperY = floatcmp(origin[id][1], -2833.0)
new equalZ = floatcmp(origin[id][2], 2020.031250)
if((lowerX == 1) && (upperX == -1) && (lowerY == 1) && (upperY == -1) && (equalZ == 0)){
server_cmd("say You have finshed the course in %d:0%d.%d", minutes[id], seconds[id], ticks[id]);
timerBool[id] == 0
}
}
}
public tickUpdate(id){
if(timerBool[id] == 1){
ticks[id]++
if(ticks[id] > 9){
seconds[id]++
ticks[id] = 0
}
if(seconds[id] > 59){
minutes[id]++
seconds[id] = 0
}
if(seconds[id] < 10){
//client_print(0, print_chat, "%d:0%d.%d", minutes, seconds, ticks);
set_hudmessage(255, 255,255, -1.0, 0.3, 0, 6, 12.0, 0.0, 0.0, -1)
show_hudmessage(id, "%d:0%d.%d", minutes[id], seconds[id], ticks[id]);
}
else{
//client_print(0, print_chat, "%d:%d.%d", minutes, seconds, ticks);
set_hudmessage(255, 255,255, -1.0, 0.3, 0, 6, 12.0, 0.0, 0.0, -1)
show_hudmessage(id, "%d:%d.%d", minutes[id], seconds[id], ticks[id]);
}
}
}
Last edited by 12Toastie; 10-16-2021 at 18:51.
|
|