But my plugin is for HL2DM not for CSS.
I compile it fine but when I started the server with it in the plugins it threw this at me
L 03/18/2009 - 17:46:11: [SM] Native "HookEvent" reported: Game event "player_activeweapon" does not exist
L 03/18/2009 - 17:46:11: [SM] Displaying call stack trace for plugin "Rof_beta.smx":
Code:
/**
* ====================
*
* Rate of Fire
*
* ====================
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_sound>
#define VERSION "0.9"
// activeWeapon uses the same weapon to integer representations as enum WeaponType
// i.e. The weapon pistol = 1; the smg1 = 2; ect.
new activeWeapon[MAXPLAYERS+1];
// Modes: 0 = no mode --- 1 = auto --- 2 = semi-auto --- 3 = burst
new primWeaponMode[MAXPLAYERS+1];
new secWeaponMode[MAXPLAYERS+1];
// 0 = Active Weapon Switched --- 1 = Change Rof command used
new bool:weaponChanged[MAXPLAYERS+1];
static const String:bindAuto[] = "bind z +auto";
static const String:bindSemi[] = "bind z semi";
static const String:bindBurst[] = "bind z burst";
static const String:xBurst[] = "+attack2; w5; -attack2";
//static const String:crosshair[] = "cl_crosshairscale";
static const String:soundFile[] = "weapons/RoF.wav";
static const Float:soundVolume = 1.0;
new Handle:WeaponTrie;
enum WeaponType
{
Weapon_None = 0,
Weapon_pistol = 1,
Weapon_smg1 = 2,
Weapon_ar2 = 3,
Weapon_shotgun = 4,
Weapon_crossbow = 5,
Weapon_357 = 6,
Weapon_frag = 7,
};
public OnPluginStart()player_activeweapon
{
// ======================================================================
RegConsoleCmd("rof", RateOfFire, "Changes weapons rate of fire");
// ======================================================================
HookEvent("player_activeweapon", WeaponChange);
HookEvent("player_drop", WeaponDrop);
HookEvent("player_spawn", PlayerSpawn);
// ======================================================================
PrecacheSound((soundFile), true);
// ======================================================================
//
// Inactive
//
//enum WeaponType
//{
// Weapon_None = 0,
// Weapon_pistol = 1,
// Weapon_smg1 = 2,
// Weapon_ar2 = 3,
// Weapon_shotgun = 4,
// Weapon_crossbow = 5,
// Weapon_357 = 6,
// Weapon_frag = 7,
//};
//---------------------------------------------------
WeaponTrie = CreateTrie();
// Primary
SetTrieValue(WeaponTrie, "none", Weapon_None);
SetTrieValue(WeaponTrie, "pistol", Weapon_pistol);
SetTrieValue(WeaponTrie, "smg1", Weapon_smg1);
SetTrieValue(WeaponTrie, "ar2", Weapon_ar2);
SetTrieValue(WeaponTrie, "shotgun", Weapon_shotgun);
SetTrieValue(WeaponTrie, "crossbow", Weapon_crossbow);
SetTrieValue(WeaponTrie, "357", Weapon_357);
SetTrieValue(WeaponTrie, "frag", Weapon_frag);
//---------------------------------------------------------------------
CreateConVar("gs_selective_fire_version",VERSION,"[SelectiveFire] Current version of this plugin",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
//---------------------------------------------------------------------
}
public Action:WeaponChange(Handle:event, const String:name[], bool:dontBroadcast)
{
new index = GetClientOfUserId(GetEventInt(event, "userid"));
weaponChanged[index] = true;
decl String:weapon[24];
GetEventString(event, "weapon", weapon, sizeof(weapon));
GetTrieValue(WeaponTrie, weapon, activeWeapon[index]);
ChangeRateOfFire(index);
}
public Action:WeaponDrop(Handle:event, const String:name[], bool:dontBroadcast)
{
new index = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:weapon[24];
GetEventString(event, "weapon", weapon, sizeof(weapon));
new weaponDropped;
GetTrieValue(WeaponTrie, weapon, weaponDropped);
switch (weaponDropped)
{
case 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16:
{
// No primary weapon mode now
primWeaponMode[index] = 0;
}
case 17, 18, 19, 20, 21, 22, 23, 24:
{
// No secondary weapon mode now
secWeaponMode[index] = 0;
}
}
}
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new index = GetClientOfUserId(GetEventInt(event, "userid"));
// Resets rate of fire to automatic
primWeaponMode[index] = 1;
secWeaponMode[index] = 1;
weaponChanged[index] = true;
ChangeRateOfFire(index);
}
public Action:RateOfFire(client, args)
{
if (IsPlayerAlive(client))
{
new index = client;
weaponChanged[index] = false;
ChangeRateOfFire(client);
}
return Plugin_Handled;
}
ChangeRateOfFire(client)
{
switch (activeWeapon[client])
{
case 1:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, bindAuto);
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, bindSemi);
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, bindSemi);
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, bindAuto);
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 2:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, bindAuto);
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, bindSemi);
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, bindSemi);
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, bindAuto);
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 3:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(cl_crosshairscale, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 4:
{
if (weaponChanged[client])
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
else
{
playRofSound(client);
}
}
case 5:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 6:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 7:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 8:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
// if burst
case 3:
{
// Set to burst
ClientCommand(client, (bindBurst));
//SetConVarInt(crosshair, 1500, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to burst
ClientCommand(client, (bindBurst));
//SetConVarInt(crosshair, 1500, false, false);
primWeaponMode[client] = 3;
}
// if burst
case 3:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 9:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
// if burst
case 3:
{
// Set to burst
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 1500, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to burst
ClientCommand(client, (bindAuto));
ClientCommand(client, (xBurst));
//SetConVarInt(crosshair, 1500, false, false);
primWeaponMode[client] = 3;
}
// if burst
case 3:
{
// Set to auto
ClientCommand(client, (bindAuto));
ClientCommand(client, (xBurst));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 10:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 11:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 12:
{
if (weaponChanged[client])
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
else
{
playRofSound(client);
}
}
case 13:
{
if (weaponChanged[client])
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
else
{
playRofSound(client);
}
}
case 14:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 15:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
case 16:
{
if (weaponChanged[client])
{
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (primWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
primWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
primWeaponMode[client] = 1;
}
}
}
}
// Secondary
case 17:
{
if (weaponChanged[client])
{
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
secWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
secWeaponMode[client] = 1;
}
}
}
}
case 18:
{
if (weaponChanged[client])
{
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if semi-auto
case 2:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to semi-auto
ClientCommand(client, (bindSemi));
//SetConVarInt(crosshair, 1750, false, false);
secWeaponMode[client] = 2;
}
// if semi-auto
case 2:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
secWeaponMode[client] = 1;
}
}
}
}
case 19:
{
if (weaponChanged[client])
{
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
// if burst
case 3:
{
// Set to burst
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 1500, false, false);
}
}
}
// Rof Command used
//elseif (rofCommandUsed)
else
{
playRofSound(client);
switch (secWeaponMode[client])
{
// if auto
case 1:
{
// Set to burst
ClientCommand(client, (bindAuto));
ClientCommand(client, (xBurst));
//SetConVarInt(crosshair, 1500, false, false);
secWeaponMode[client] = 3;
}
// if burst
case 3:
{
// Set to auto
ClientCommand(client, (bindAuto));
ClientCommand(client, (xBurst));
//SetConVarInt(crosshair, 0, false, false);
secWeaponMode[client] = 1;
}
}
}
}
case 20, 21, 22, 23, 24:
{
if (weaponChanged[client])
{
// set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
secWeaponMode[client] = 1;
}
else
{
playRofSound(client);
}
}
// Accessories
case 25, 26, 27, 28, 29:
{
if (weaponChanged[client])
{
// set to auto
ClientCommand(client, (bindAuto));
//SetConVarInt(crosshair, 0, false, false);
}
}
}
}
playRofSound(client)
{
EmitSoundToClient(client, (soundFile), _, _, _, _, (soundVolume));
}
// End