hey, i'm having some trouble compiling my plugin and i was wondering if anyone could give me some insight on how to fix it.
I am able to compile this:
Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <tf2_stocks>
#define PLUGIN_VERSION "0.3"
public Plugin:myinfo =
{
name = "Glass Attack",
author = "Fenderic",
description = "Sniper-only deathmatch with tons of breakable glass!",
version = PLUGIN_VERSION,
url = "http://www.moddb.com/mods/glass-attack"
};
//CVars
new Handle:g_Cvar_GlassEnabled;
public Event_PlayerClass(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarBool(g_Cvar_GlassEnabled))
{
return;
}
new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
new glass_user_class = GetEventInt(event, "class");
if(glass_user_class != 2)
{
TF2_SetPlayerClass(glass_user, TFClassType:2);
}
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarBool(g_Cvar_GlassEnabled))
{
return;
}
new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
if(TF2_GetPlayerClass(glass_user) != TFClassType:7)
{
TF2_SetPlayerClass(glass_user, TFClassType:2);
if(IsPlayerAlive(glass_user))
{
TF2_RespawnPlayer(glass_user);
}
}
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}
public Action:OnWeaponSwitch(client, weapon)
{
decl String:sWeapon[32];
GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
if(StrEqual(sWeapon, "tf_weapon_smg"))
return Plugin_Handled;
return Plugin_Continue;
}
but i am not able to compile this:
Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <tf2_stocks>
#define PLUGIN_VERSION "0.3"
public Plugin:myinfo =
{
name = "Glass Attack",
author = "Fenderic",
description = "Sniper-only deathmatch with tons of breakable glass!",
version = PLUGIN_VERSION,
url = "http://www.moddb.com/mods/glass-attack"
};
//CVars
new Handle:g_Cvar_GlassEnabled;
new Handle:checkmapname = INVALID_HANDLE;
public OnPluginStart()
{
CreateConVar("sm_glass_version", PLUGIN_VERSION, "Glass Attack version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
g_Cvar_GlassEnabled = CreateConVar("sm_glass_enabled", "1", "Enables the Glass Attack plugin", 0, false, 0.0, false, 0.0);
checkmapname = CreateConVar("glass_checkmapname", "1", "Disables Glass Attack on maps that do not start with 'glass_'.", FCVAR_PLUGIN);
enabled = GetConVarBool(enabled_cvar);
// Check map name (if necessary).
if (enabled && GetConVarBool(checkmapname)) {
decl String:prefix[6];
GetCurrentMap(prefix, sizeof(prefix));
enabled = StrEqual(prefix, "glass_", false);
}
if(GetConVarBool(g_Cvar_GlassEnabled))
{
HookEvent("player_changeclass", Event_PlayerClass);
HookEvent("player_spawn", Event_PlayerSpawn);
}
}
public Event_PlayerClass(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarBool(g_Cvar_GlassEnabled))
{
return;
}
new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
new glass_user_class = GetEventInt(event, "class");
if(glass_user_class != 2)
{
TF2_SetPlayerClass(glass_user, TFClassType:2);
}
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarBool(g_Cvar_GlassEnabled))
{
return;
}
new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
if(TF2_GetPlayerClass(glass_user) != TFClassType:7)
{
TF2_SetPlayerClass(glass_user, TFClassType:2);
if(IsPlayerAlive(glass_user))
{
TF2_RespawnPlayer(glass_user);
}
}
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}
public Action:OnWeaponSwitch(client, weapon)
{
decl String:sWeapon[32];
GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
if(StrEqual(sWeapon, "tf_weapon_smg"))
return Plugin_Handled;
return Plugin_Continue;
The second one is the same code, except it has the added ability to turn the plugin on/off depending on map prefix.
The reason I am posting this here though is because the second code was able to compile before I added in the last part that uses SDKHooks to remove the sniper's smg. Now when I do try to compile the whole thing, I get this error in the compiler.
Code:
////glassattack.sp
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<25> :error 017: undefined symbol "enabled"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<25> :error 017: undefined symbol "enabled_cvar"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<27> :error 017: undefined symbol "enabled"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<30> :error 017: undefined symbol "enabled"
//
// 4 Errors.
I'm a bit confused as to why it doesn't recognize enabled when it did before.
If anyone has some insight into why it is doing this and how I can change the code to make it compile I would greatly appreciate it!
Thanks!