my plugin is crashing cooldown on mapchange idk what is worng but maybe you guy can help my
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <morecolors>
#include <autoexecconfig>
#define PLUGIN_VERSION "3.0"
new Handle:g_hPluginEnabled = INVALID_HANDLE;
new bool:g_bPluginEnabled;
new Handle:g_hCoolDown = INVALID_HANDLE;
new g_iCoolDown;
new Handle:g_hSpeedBoostTime = INVALID_HANDLE;
new Float:g_fSpeedBoostTime;
new g_iTime;
new bool:canUseSpeedBoost[MAXPLAYERS+1] = {true, ...};
public Plugin myinfo =
{
name = "[TF2] Call",
author = "John",
description = "Medic call for speed",
version = PLUGIN_VERSION,
url = " http://www.sourcemod.net"
};
public OnPluginStart()
{
AutoExecConfig_SetFile("sm_call");
AutoExecConfig_SetCreateFile(true);
AutoExecConfig_CreateConVar("sm_call_version", PLUGIN_VERSION, "TF2 Call Plugin Version", FCVAR_PLUGIN|FCVAR_DONTRECORD|FCVAR_NOTIFY);
g_hPluginEnabled = AutoExecConfig_CreateConVar("sm_call_enable", "1", "Enables and disables the tf2 call plugin", FCVAR_NOTIFY, true, 0.0, true, 1.0);
HookConVarChange(g_hPluginEnabled, OnCVarChange);
g_bPluginEnabled = GetConVarBool(g_hPluginEnabled);
g_hCoolDown = AutoExecConfig_CreateConVar("sm_call_cooldown_time", "60.0", "URL to validate", FCVAR_NOTIFY);
HookConVarChange(g_hCoolDown, OnCVarChange);
g_iCoolDown = GetConVarInt(g_hCoolDown);
g_hSpeedBoostTime = AutoExecConfig_CreateConVar("sm_call_speedboost_time", "5.0", "Ammount of time the speedboost lasts", FCVAR_NOTIFY);
HookConVarChange(g_hSpeedBoostTime, OnCVarChange);
g_fSpeedBoostTime = GetConVarFloat(g_hSpeedBoostTime);
AddCommandListener(MedicCall, "voicemenu");
}
public OnCVarChange(Handle:hCVar, const String:sOldValue[], const String:sNewValue[])
{
if(hCVar == g_hPluginEnabled)
{
g_bPluginEnabled = GetConVarBool(g_hPluginEnabled);
}
if(hCVar == g_hCoolDown)
{
g_iCoolDown = GetConVarInt(g_hCoolDown);
}
if(hCVar == g_hSpeedBoostTime)
{
g_fSpeedBoostTime = GetConVarFloat(g_hSpeedBoostTime);
}
}
public Action:MedicCall(client, String:command[], args)
{
if (!g_bPluginEnabled)
{
PrintToChat(client, "\x04[Speed boost] \x01The TF2 Call plugin is disabled!");
return Plugin_Handled;
}
if (!canUseSpeedBoost[client])
{
PrintToChat(client, "\x04[Speed boost] \x01You have \x03%i\x01 seconds left of the cooldown !", g_iTime)
}
decl String:sBuffer[2];
GetCmdArg(1, sBuffer, sizeof(sBuffer));
if (StringToInt(sBuffer) == 0)
{
GetCmdArg(2, sBuffer, sizeof(sBuffer));
if (StringToInt(sBuffer) == 0)
{
if(canUseSpeedBoost[client] == true)
{
TF2_AddCondition(client, TFCond_SpeedBuffAlly, g_fSpeedBoostTime);
canUseSpeedBoost[client] = false;
g_iTime = g_iCoolDown;
CreateTimer(1.0, Timer_CoolDown, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
public Action:Timer_CoolDown(Handle:hTimer, any:client)
{
if (g_iTime == 0)
{
canUseSpeedBoost[client] = true;
return Plugin_Stop;
}
g_iTime--;
return Plugin_Continue;
}