I have this code that pulls the remaining time from a timestamp in the database, I am unable to remove the icon after the time is up, the icon count becomes negative..
OnPCLoginEvent:
set @player_char_id, getcharid(0);
// Obtém o horário atual do servidor como um tick de tempo
set .@current_time_tick, gettimetick(2);
// Obtém o tick de tempo de expiração de 'bossnia_free' da tabela
query_sql("SELECT UNIX_TIMESTAMP(`bossnia_free`) FROM `char` WHERE `char_id` = " + getcharid(0), .@bossnia_free_time_tick);
// Calcula a diferença de tempo em segundos
set .@time_difference_seconds, (.@bossnia_free_time_tick - .@current_time_tick);
// Verifica se o tempo restante é maior que zero
if (.@time_difference_seconds > 0) {
// Iniciar ou reiniciar o cronômetro
set .@cronometer, .@time_difference_seconds;
// Iniciar o ícone falso com o tempo em milissegundos
set .@fake_icon_time_ms, .@cronometer * 1000;
fakeIcon(getcharid(0), 981, .@fake_icon_time_ms, 1);
addtimer 5000, "CheckBossniasMicroChip::OnCheckTimer";
} else {
// Remove o ícone se o tempo já tiver expirado
fakeIcon(getcharid(0), 981, 0, 0);
}
end;
OnCheckTimer:
// Calcula o tempo restante
// Verifica se ainda há tempo restante
if (.@fake_icon_time_ms = 0) {
fakeIcon(@player_char_id, 981, 0, 0);
// Outras ações quando o tempo expira, se necessário
}
end;
}
Question
Westin
I have this code that pulls the remaining time from a timestamp in the database, I am unable to remove the icon after the time is up, the icon count becomes negative..
OnPCLoginEvent: set @player_char_id, getcharid(0); // Obtém o horário atual do servidor como um tick de tempo set .@current_time_tick, gettimetick(2); // Obtém o tick de tempo de expiração de 'bossnia_free' da tabela query_sql("SELECT UNIX_TIMESTAMP(`bossnia_free`) FROM `char` WHERE `char_id` = " + getcharid(0), .@bossnia_free_time_tick); // Calcula a diferença de tempo em segundos set .@time_difference_seconds, (.@bossnia_free_time_tick - .@current_time_tick); // Verifica se o tempo restante é maior que zero if (.@time_difference_seconds > 0) { // Iniciar ou reiniciar o cronômetro set .@cronometer, .@time_difference_seconds; // Iniciar o ícone falso com o tempo em milissegundos set .@fake_icon_time_ms, .@cronometer * 1000; fakeIcon(getcharid(0), 981, .@fake_icon_time_ms, 1); addtimer 5000, "CheckBossniasMicroChip::OnCheckTimer"; } else { // Remove o ícone se o tempo já tiver expirado fakeIcon(getcharid(0), 981, 0, 0); } end; OnCheckTimer: // Calcula o tempo restante // Verifica se ainda há tempo restante if (.@fake_icon_time_ms = 0) { fakeIcon(@player_char_id, 981, 0, 0); // Outras ações quando o tempo expira, se necessário } end; }
any helps?
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.