AD4M
Участник
- Сообщения
- 373
- Реакции
- 58
Ребята, здравствуйте, хотелось бы спросить кое-чего по поводу кода.
Решил сделать плагин на отсчёт до взрыва бомбы к себе на паблик, но возникли большие проблемы:
Показывается это и всё, таймер утихает, хотя я вроде бы сделал его в милисекундах и каждую милисекунду обновления.
Решил сделать плагин на отсчёт до взрыва бомбы к себе на паблик, но возникли большие проблемы:
Показывается это и всё, таймер утихает, хотя я вроде бы сделал его в милисекундах и каждую милисекунду обновления.
#include <sourcemod>
#pragma newdecls required
public Plugin myinfo ={
name = "TimerBomb",
author = "D3vil",
description = "This plugin allows know that how much time to defuse the bomb",
version = "1.0",
url = "vk.com/adamia3"
};
Handle g_hTimer = INVALID_HANDLE;
float g_fExplosionTime;
float g_fCount;
public void OnPluginStart(){
if(GetEngineVersion() != Engine_CSGO){
SetFailState("This plugin only for CS:GO");
}
g_fCount = 0.01;
HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre);
HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Post);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public Action Event_BombPlanted(Event hEvent, const char[] name, bool bDontBroadcast){
g_fExplosionTime = 40.0;
g_hTimer = CreateTimer((g_fCount), TimerCountDown, TIMER_REPEAT);
return Plugin_Continue;
}
public Action Event_BombDefused(Event hEvent, const char[] name, bool bDontBroadcast){
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "Бомба разминирована!");
}
}
if(g_hTimer){
KillTimer(g_hTimer);
g_hTimer = null;
}
}
public Action TimerCountDown(Handle hTimer, any data){
g_fExplosionTime -= g_fCount;
if(g_fExplosionTime <= 0.0){
KillTimer(g_hTimer);
g_hTimer = null;
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "Бомба взорвалась!");
}
}
}
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "До взрыва бомбы осталось: [%2f]", g_fExplosionTime);
}
}
}
public Action Event_RoundStart(Event hEvent, const char[] name, bool bDontBroadcast){
if(g_hTimer){
KillTimer(g_hTimer);
g_hTimer = null;
}
}
#pragma newdecls required
public Plugin myinfo ={
name = "TimerBomb",
author = "D3vil",
description = "This plugin allows know that how much time to defuse the bomb",
version = "1.0",
url = "vk.com/adamia3"
};
Handle g_hTimer = INVALID_HANDLE;
float g_fExplosionTime;
float g_fCount;
public void OnPluginStart(){
if(GetEngineVersion() != Engine_CSGO){
SetFailState("This plugin only for CS:GO");
}
g_fCount = 0.01;
HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre);
HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Post);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public Action Event_BombPlanted(Event hEvent, const char[] name, bool bDontBroadcast){
g_fExplosionTime = 40.0;
g_hTimer = CreateTimer((g_fCount), TimerCountDown, TIMER_REPEAT);
return Plugin_Continue;
}
public Action Event_BombDefused(Event hEvent, const char[] name, bool bDontBroadcast){
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "Бомба разминирована!");
}
}
if(g_hTimer){
KillTimer(g_hTimer);
g_hTimer = null;
}
}
public Action TimerCountDown(Handle hTimer, any data){
g_fExplosionTime -= g_fCount;
if(g_fExplosionTime <= 0.0){
KillTimer(g_hTimer);
g_hTimer = null;
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "Бомба взорвалась!");
}
}
}
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i)){
PrintCenterText(i, "До взрыва бомбы осталось: [%2f]", g_fExplosionTime);
}
}
}
public Action Event_RoundStart(Event hEvent, const char[] name, bool bDontBroadcast){
if(g_hTimer){
KillTimer(g_hTimer);
g_hTimer = null;
}
}