Hi, i am making new plugin name WeaponFight 1 vs 1 in the end of round.
The plugin compile successfuly but when i run the plugin in my server in console he give me error
PHP Code:
#pragma semicolon 1
#pragma tabsize 0
#include <sourcemod>
#include <sdktools>
#include <morecolors>
#include <clientprefs>
#include <cstrike>
#include <sdkhooks>
#define MAX_WEAPONS 32 // max weapons
#define TEAM_T 2
#define TEAM_CT 3
#define SLAYER_WEAPONFIGHT_VERSION "1.6.8.7"
#define MAX_FILE_LEN 256
#define SOUND_EXPLODE "ambient/explosions/explode_8.wav"
#define SOUND_TIMER "ambient/tones/floor1.wav"
// Colors
#define YELLOW "\x01"
#define NAME_TEAMCOLOR "\x02"
#define TEAMCOLOR "\x03"
#define GREEN "\x04"
EngineVersion g_Game;
public Plugin myinfo =
{
name = "$L@YER Weapon Fight",
author = "$L@YER",
description = "1 vs 1 at the end of round with weapons.",
version = SLAYER_WEAPONFIGHT_VERSION,
url = ""
};
float teleloc[3];
float g_winnerspeed;
char ctname[MAX_NAME_LENGTH];
char tname[MAX_NAME_LENGTH];
char ctitems[8][64];
char titems[8][64];
char winnername[MAX_NAME_LENGTH];
char g_declinesound[MAX_FILE_LEN];
char g_beaconsound[MAX_FILE_LEN];
char song[256];
char itemswon[256];
bool g_winnereffects;
bool g_losereffects;
bool g_forcefight;
bool g_enabled;
bool g_alltalk;
bool g_alltalkenabled = false;
bool g_block;
bool g_blockenabled = false;
bool g_randomkill;
bool g_useteleport;
bool g_restorehealth;
bool g_locatorbeam;
bool g_stopmusic;
bool g_intermission;
bool isFighting = false;
bool bombplanted = false;
int ctid, tid, winner, loser, alivect, alivet;
int g_winnerid = 0;
int ctagree = -1;
int tagree = -1;
int songsfound = 0;
int timesrepeated;
int g_iMyWeapons, g_iHealth, g_iAccount, g_iSpeed, g_iArmorOffset;
int g_beamsprite, g_halosprite, g_lightning, g_locatebeam, g_locatehalo;
int g_countdowntimer, g_winnerhealth, g_winnermoney, g_minplayers;
int g_fighttimer, fighttimer;
float g_beaconragius;
//Convar
Handle g_Cvarenabled = INVALID_HANDLE;
Handle g_Cvaralltalk = INVALID_HANDLE;
Handle g_Cvarblock = INVALID_HANDLE;
Handle g_Cvarrandomkill = INVALID_HANDLE;
Handle g_Cvarminplayers = INVALID_HANDLE;
Handle g_Cvardeclinesound = INVALID_HANDLE;
Handle g_Cvarbeaconsound = INVALID_HANDLE;
Handle g_Cvaruseteleport = INVALID_HANDLE;
Handle g_Cvarrestorehealth = INVALID_HANDLE;
Handle g_Cvarwinnerspeed = INVALID_HANDLE;
Handle g_Cvarwinnerhealth = INVALID_HANDLE;
Handle g_Cvarwinnermoney = INVALID_HANDLE;
Handle g_Cvarwinnereffects = INVALID_HANDLE;
Handle g_Cvarlosereffects = INVALID_HANDLE;
Handle g_Cvarlocatorbeam = INVALID_HANDLE;
Handle g_Cvarstopmusic = INVALID_HANDLE;
Handle g_Cvarforcefight = INVALID_HANDLE;
Handle g_Cvarcountdowntimer = INVALID_HANDLE;
Handle g_Cvarfighttimer = INVALID_HANDLE;
Handle g_Cvarbeaconradius = INVALID_HANDLE;
Handle g_WeaponSlots = INVALID_HANDLE;
new Handle:g_hWeaponsTrie;
new Handle:g_hWeaponsArray;
new Handle:g_hSoundsArray;
new g_iWeaponsArray = -1;
int g_bFightRoundNoZoom[MAX_WEAPONS];
int g_bFightRoundAutoSwitch[MAX_WEAPONS];
new g_iRandomInt;
new String:g_sWeaponsArray[64];
char g_WeaponNames[MAX_WEAPONS][ ] =
{
"primammo", "secammo", "vest", "vesthelm",
"defuser", "nvgs", "galil", "ak47",
"scout",
"sg552", "awp", "g3sg1", "famas",
"m4a1", "aug", "sg550", "glock",
"usp", "p228", "deagle", "elite",
"fiveseven", "m3", "xm1014", "mac10",
"tmp", "mp5navy", "ump45", "p90",
"m249", "c4", "knife"
};
new Handle:sv_alltalk = INVALID_HANDLE;
new Handle:sm_noblock = INVALID_HANDLE;
new Handle:sm_noblock_nades;
new g_WeaponParent;
new g_iCollisionGroupOffs;
new Handle:g_Cvar_SoundPrefDefault = INVALID_HANDLE;
new Handle:g_Cookie_SoundPref = INVALID_HANDLE;
new g_soundPrefs[MAXPLAYERS+1];
new Handle:g_Cookie_FightPref = INVALID_HANDLE;
new g_fightPrefs[MAXPLAYERS+1];
new Handle:g_Cvar_IsBotFightAllowed = INVALID_HANDLE;
new bool:g_isBotFightAllowed = false;
new g_showWinner;
new g_removeNewPlayer;
new Handle:g_Cvar_ShowWinner = INVALID_HANDLE;
new Handle:g_Cvar_RemoveNewPlayer = INVALID_HANDLE;
new g_iActiveWeapon[66];
new g_iFOVOffs;
new bool:g_bSetRestrict;
new Handle:g_Cvar_Restrict = INVALID_HANDLE;
new g_iActiveWeaponOffset = -1;
new bool:g_bSDKHooksLoaded;
new bool:g_bOnTakeDamage;
public __ext_sdkhooks_SetNTVOptional()
{
MarkNativeAsOptional("SDKHook");
MarkNativeAsOptional("SDKHookEx");
MarkNativeAsOptional("SDKUnhook");
MarkNativeAsOptional("SDKHooks_TakeDamage");
MarkNativeAsOptional("SDKHooks_DropWeapon");
return 0;
}
public void OnPluginStart()
{
g_Game = GetEngineVersion();
if (g_Game != Engine_CSGO && g_Game != Engine_CSS)
SetFailState("This plugin is for CSGO/CSS only.");
sv_alltalk = FindConVar("sv_alltalk");
if (!sv_alltalk)
{
SetFailState("[WeaponFight] Cannot find sv_alltalk cvar.");
}
LoadTranslations("weaponfight.phrases");
CreateConVar("SLAYER_WeaponFight_version",SLAYER_WEAPONFIGHT_VERSION,"Plugin version",FCVAR_NOTIFY|FCVAR_REPLICATED);
g_Cvarenabled = CreateConVar("sm_weaponfight_enabled", "1", "Enable this plugin. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvaralltalk = CreateConVar("sm_weaponfight_alltalk", "1", "Enable alltalk while weapon fight. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarblock = CreateConVar("sm_weaponfight_block", "0", "Enable player blocking (disable sm_noblock) if sm_noblock is enabled while weapon fight. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarrandomkill = CreateConVar("sm_weaponfight_randomkill", "0", "Enable random kill after weapon fight time end. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarminplayers = CreateConVar("sm_weaponfight_minplayers", "4", "Minimum number of players before weapon fights will trigger.", 0, false, 0.0, false, 0.0);
g_Cvaruseteleport = CreateConVar("sm_weaponfight_useteleport", "1", "Use smart teleport system prior to weapon fight. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarrestorehealth = CreateConVar("sm_weaponfight_restorehealth", "1", "Give players full health before weapon fight. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarforcefight = CreateConVar("sm_weaponfight_forcefight", "0", "Force weapon fight at end of round instead of prompting with menus. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarwinnerhealth = CreateConVar("sm_weaponfight_winnerhealth", "0", "Total health to give the winner. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarwinnerspeed = CreateConVar("sm_weaponfight_winnerspeed", "0", "Total speed given to the winner. 0 = Disabled (1.0 is normal speed, 2.0 is twice normal)", 0, false, 0.0, false, 0.0);
g_Cvarwinnermoney = CreateConVar("sm_weaponfight_winnermoney", "0", "Total extra money given to the winner. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarwinnereffects = CreateConVar("sm_weaponfight_winnereffects", "1", "Enable special effects on the winner. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarlosereffects = CreateConVar("sm_weaponfight_losereffects", "1", "Dissolve loser body using special effects. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarlocatorbeam = CreateConVar("sm_weaponfight_locatorbeam", "1", "Use locator beam between players if they are far apart. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvarstopmusic = CreateConVar("sm_weaponfight_stopmusic", "0", "Stop music when fight is over. Useful when used with gungame. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_Cvardeclinesound = CreateConVar("sm_weaponfight_declinesound", "weaponfight/chicken.wav", "The sound to play when player declines to weapon.", 0, false, 0.0, false, 0.0);
g_Cvarbeaconsound = CreateConVar("sm_weaponfight_beaconsound", "buttons/blip1.wav", "The sound to play when beacon ring shows.", 0, false, 0.0, false, 0.0);
g_Cvarcountdowntimer = CreateConVar("sm_weaponfight_countdowntimer", "3", "Number of seconds to count down before a weapon fight.", 0, false, 0.0, false, 0.0);
g_Cvarfighttimer = CreateConVar("sm_weaponfight_fighttimer", "30", "Number of seconds to allow for knifing. Players get slayed after this time limit expires.", 0, false, 0.0, false, 0.0);
g_Cvarbeaconradius = CreateConVar("sm_weaponfight_beaconradius", "800", "Beacon radius.", 0, false, 0.0, false, 0.0);
g_Cvar_IsBotFightAllowed = CreateConVar("sm_weaponfight_botfight", "0", "Allow bot to weapon fight with bot. 0 = Disabled", 0, false, 0.0, false, 0.0);
g_isBotFightAllowed = GetConVarBool(g_Cvar_IsBotFightAllowed);
g_Cvar_ShowWinner = CreateConVar("sm_weaponfight_showwinner", "0", "Show winner. (0 - Top left, 1 - Chat)", 0, false, 0.0, false, 0.0);
g_showWinner = GetConVarInt(g_Cvar_ShowWinner);
g_Cvar_RemoveNewPlayer = CreateConVar("sm_weaponfight_removenewplayer", "0", "Remove player connected when fight is started. (0 - Slay, 1 - Move to spec)", 0, false, 0.0, false, 0.0);
g_removeNewPlayer = GetConVarInt(g_Cvar_RemoveNewPlayer);
new f_WeaponSlots[32] = {-1,-1,-1,-1,-1,-1,3,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,4,2};
g_WeaponSlots = CreateTrie();
new i;
while (i < 32)
{
SetTrieValue(g_WeaponSlots, g_WeaponNames[i], f_WeaponSlots[i], true);
i++;
}
HookEvent("player_spawn", EventPlayerSpawn, EventHookMode:1);
HookEvent("player_death", EventPlayerDeath, EventHookMode:1);
HookEvent("item_pickup", EventItemPickup, EventHookMode:1);
HookEvent("weapon_zoom", EventWeaponZoom, EventHookMode:1);
HookEvent("weapon_fire", EventWeaponFire, EventHookMode:1);
HookEvent("bomb_planted", EventBombPlanted, EventHookMode:2);
HookEvent("round_end", EventBombPlanted, EventHookMode:2);
HookEvent("round_start", EventRoundStart, EventHookMode:2);
HookConVarChange(g_Cvarenabled, OnSettingChanged);
HookConVarChange(g_Cvaralltalk, OnSettingChanged);
HookConVarChange(g_Cvarblock, OnSettingChanged);
HookConVarChange(g_Cvarrandomkill, OnSettingChanged);
HookConVarChange(g_Cvarminplayers, OnSettingChanged);
HookConVarChange(g_Cvaruseteleport, OnSettingChanged);
HookConVarChange(g_Cvarrestorehealth, OnSettingChanged);
HookConVarChange(g_Cvarwinnerhealth, OnSettingChanged);
HookConVarChange(g_Cvarwinnerspeed, OnSettingChanged);
HookConVarChange(g_Cvarwinnermoney, OnSettingChanged);
HookConVarChange(g_Cvarwinnereffects, OnSettingChanged);
HookConVarChange(g_Cvarlosereffects, OnSettingChanged);
HookConVarChange(g_Cvarlocatorbeam, OnSettingChanged);
HookConVarChange(g_Cvarstopmusic, OnSettingChanged);
HookConVarChange(g_Cvarforcefight, OnSettingChanged);
HookConVarChange(g_Cvarcountdowntimer, OnSettingChanged);
HookConVarChange(g_Cvarfighttimer, OnSettingChanged);
HookConVarChange(g_Cvarbeaconradius, OnSettingChanged);
HookConVarChange(g_Cvar_IsBotFightAllowed, OnSettingChanged);
HookConVarChange(g_Cvar_ShowWinner, OnSettingChanged);
HookConVarChange(g_Cvar_RemoveNewPlayer, OnSettingChanged);
g_Cvar_SoundPrefDefault = CreateConVar("sm_weaponfight_soundprefdefault", "1", "Default sound setting for new users.", 0, false, 0.0, false, 0.0);
g_Cookie_SoundPref = RegClientCookie("sm_weaponfight_soundpref", "WeaponFight Sound Pref", CookieAccess:2);
g_Cookie_FightPref = RegClientCookie("sm_weaponfight_fightpref", "WeaponFight Fight Pref", CookieAccess:2);
RegConsoleCmd("wfmenu", MenuKnifeFight, "Show Weapon fight settings menu.", 0);
i = 1;
while (i <= MaxClients)
{
g_soundPrefs[i] = GetConVarInt(g_Cvar_SoundPrefDefault);
g_fightPrefs[i] = 0;
i++;
}
g_hWeaponsTrie = CreateTrie();
SetTrieValue(g_hWeaponsTrie, "galil", any:1, true);
SetTrieValue(g_hWeaponsTrie, "ak47", any:1, true);
SetTrieValue(g_hWeaponsTrie, "scout", any:1, true);
SetTrieValue(g_hWeaponsTrie, "sg552", any:1, true);
SetTrieValue(g_hWeaponsTrie, "awp", any:1, true);
SetTrieValue(g_hWeaponsTrie, "g3sg1", any:1, true);
SetTrieValue(g_hWeaponsTrie, "famas", any:1, true);
SetTrieValue(g_hWeaponsTrie, "m4a1", any:1, true);
SetTrieValue(g_hWeaponsTrie, "aug", any:1, true);
SetTrieValue(g_hWeaponsTrie, "sg550", any:1, true);
SetTrieValue(g_hWeaponsTrie, "glock", any:1, true);
SetTrieValue(g_hWeaponsTrie, "usp", any:1, true);
SetTrieValue(g_hWeaponsTrie, "p228", any:1, true);
SetTrieValue(g_hWeaponsTrie, "deagle", any:1, true);
SetTrieValue(g_hWeaponsTrie, "elite", any:1, true);
SetTrieValue(g_hWeaponsTrie, "fiveseven", any:1, true);
SetTrieValue(g_hWeaponsTrie, "m3", any:1, true);
SetTrieValue(g_hWeaponsTrie, "xm1014", any:1, true);
SetTrieValue(g_hWeaponsTrie, "mac10", any:1, true);
SetTrieValue(g_hWeaponsTrie, "tmp", any:1, true);
SetTrieValue(g_hWeaponsTrie, "mp5navy", any:1, true);
SetTrieValue(g_hWeaponsTrie, "ump45", any:1, true);
SetTrieValue(g_hWeaponsTrie, "p90", any:1, true);
SetTrieValue(g_hWeaponsTrie, "m249", any:1, true);
SetTrieValue(g_hWeaponsTrie, "knife", any:1, true);
g_iMyWeapons = FindSendPropInfo("CBaseCombatCharacter", "m_hMyWeapons");
if (g_iMyWeapons == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CBaseCombatCharacter::m_hMyWeapons");
}
g_iHealth = FindSendPropInfo("CCSPlayer", "m_iHealth");
if (g_iHealth == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CSSPlayer::m_iHealth");
}
g_iArmorOffset = FindSendPropInfo("CCSPlayer", "m_ArmorValue");
if (g_iArmorOffset == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CCSPlayer::m_ArmorValue");
}
g_iAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
if (g_iAccount == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CSSPlayer::m_iAccount");
}
g_iSpeed = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue");
if (g_iSpeed == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CSSPlayer::m_flLaggedMovementValue");
}
g_WeaponParent = FindSendPropInfo("CBaseCombatWeapon", "m_hOwnerEntity");
if (g_WeaponParent == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CBaseCombatWeapon::m_hOwnerEntity");
}
g_iCollisionGroupOffs = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
if (g_iCollisionGroupOffs == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CBaseEntity::m_CollisionGroup");
}
g_iFOVOffs = FindSendPropInfo("CBasePlayer", "m_iFOV");
if (g_iFOVOffs == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CBasePlayer::m_iFOV");
}
g_iActiveWeaponOffset = FindSendPropInfo("CAI_BaseNPC", "m_hActiveWeapon");
if (g_iActiveWeaponOffset == -1)
{
SetFailState("[WeaponFight] Error - Unable to get offset for CAI_BaseNPC::m_hActiveWeapon");
}
g_hWeaponsArray = CreateArray(128, 0);
g_hSoundsArray = CreateArray(128, 0);
AutoExecConfig(true, "weaponfight", "sourcemod");
}
public OnMapStart()
{
songsfound = -1;
ClearArray(g_hSoundsArray);
ParsFile("weaponfight_sounds.ini", false);
}
public OnConfigsExecuted()
{
decl String:buffer[256];
g_beamsprite = PrecacheModel("materials/sprites/lgtning.vmt", false);
g_halosprite = PrecacheModel("materials/sprites/halo01.vmt", false);
g_lightning = PrecacheModel("materials/sprites/tp_beam001.vmt", false);
g_locatebeam = PrecacheModel("materials/sprites/physbeam.vmt", false);
g_locatehalo = PrecacheModel("materials/sprites/plasmahalo.vmt", false);
PrecacheSound("ambient/explosions/explode_8.wav", true);
PrecacheSound("ambient/tones/floor1.wav", true);
g_iWeaponsArray = -1;
g_iRandomInt = 0;
ClearArray(g_hWeaponsArray);
ParsFile("weaponfight_list.ini", true);
GetConVarString(g_Cvardeclinesound, g_declinesound, 256);
if (!PrecacheSound(g_declinesound, true))
{
LogError("[WeaponFight] Could not pre-cache sound: %s", g_declinesound);
}
else
{
Format(buffer, 256, "sound/%s", g_declinesound);
AddFileToDownloadsTable(buffer);
}
GetConVarString(g_Cvarbeaconsound, g_beaconsound, 256);
if (!PrecacheSound(g_beaconsound, true))
{
LogError("[WeaponFight] Could not pre-cache sound: %s", g_beaconsound);
}
else
{
Format(buffer, 256, "sound/%s", g_beaconsound);
AddFileToDownloadsTable(buffer);
}
g_enabled = GetConVarBool(g_Cvarenabled);
g_alltalk = GetConVarBool(g_Cvaralltalk);
g_block = GetConVarBool(g_Cvarblock);
g_randomkill = GetConVarBool(g_Cvarrandomkill);
g_minplayers = GetConVarInt(g_Cvarminplayers);
g_useteleport = GetConVarBool(g_Cvaruseteleport);
g_restorehealth = GetConVarBool(g_Cvarrestorehealth);
g_winnerhealth = GetConVarInt(g_Cvarwinnerhealth);
g_winnerspeed = GetConVarFloat(g_Cvarwinnerspeed);
g_winnereffects = GetConVarBool(g_Cvarwinnereffects);
g_losereffects = GetConVarBool(g_Cvarlosereffects);
g_locatorbeam = GetConVarBool(g_Cvarlocatorbeam);
g_stopmusic = GetConVarBool(g_Cvarstopmusic);
g_forcefight = GetConVarBool(g_Cvarforcefight);
g_countdowntimer = GetConVarInt(g_Cvarcountdowntimer);
g_fighttimer = GetConVarInt(g_Cvarfighttimer);
g_beaconragius = GetConVarFloat(g_Cvarbeaconradius);
}
public OnAutoConfigsBuffered()
{
g_intermission = false;
}
public OnSettingChanged(Handle:convar, String:oldValue[], String:newValue[])
{
if (g_Cvarenabled == convar)
{
g_enabled = newValue[0] == 49;
}
else
{
if (g_Cvaralltalk == convar)
{
g_alltalk = newValue[0] == 49;
}
if (g_Cvarblock == convar)
{
g_block = newValue[0] == 49;
}
if (g_Cvarrandomkill == convar)
{
g_randomkill = newValue[0] == 49;
}
if (g_Cvaruseteleport == convar)
{
g_useteleport = newValue[0] == 49;
}
if (g_Cvarrestorehealth == convar)
{
g_restorehealth = newValue[0] == 49;
}
if (g_Cvarwinnereffects == convar)
{
g_winnereffects = newValue[0] == 49;
}
if (g_Cvarlosereffects == convar)
{
g_losereffects = newValue[0] == 49;
}
if (g_Cvarlocatorbeam == convar)
{
g_locatorbeam = newValue[0] == 49;
}
if (g_Cvarstopmusic == convar)
{
g_stopmusic = newValue[0] == 49;
}
if (g_Cvarforcefight == convar)
{
g_forcefight = newValue[0] == 49;
}
if (g_Cvarwinnerhealth == convar)
{
g_winnerhealth = StringToInt(newValue, 10);
}
if (g_Cvarwinnerspeed == convar)
{
g_winnerspeed = StringToFloat(newValue);
}
if (g_Cvarwinnermoney == convar)
{
g_winnermoney = StringToInt(newValue, 10);
}
if (g_Cvarcountdowntimer == convar)
{
g_countdowntimer = StringToInt(newValue, 10);
}
if (g_Cvarfighttimer == convar)
{
g_fighttimer = StringToInt(newValue, 10);
}
if (g_Cvarbeaconradius == convar)
{
g_beaconragius = StringToFloat(newValue);
}
if (g_Cvarminplayers == convar)
{
g_minplayers = StringToInt(newValue, 10);
}
if (g_Cvar_IsBotFightAllowed == convar)
{
g_isBotFightAllowed = newValue[0] == 49;
}
if (g_Cvar_ShowWinner == convar)
{
g_showWinner = GetConVarInt(g_Cvar_ShowWinner);
}
if (g_Cvar_RemoveNewPlayer == convar)
{
g_removeNewPlayer = GetConVarInt(g_Cvar_RemoveNewPlayer);
}
}
return 0;
}
WeaponHandler(client, teamid)
{
if (isFighting)
{
new count;
new i;
while (i <= 128)
{
new weaponentity = -1;
new String:weaponname[32];
weaponentity = GetEntDataEnt2(client, i + g_iMyWeapons);
if (IsValidEdict(weaponentity))
{
GetEdictClassname(weaponentity, weaponname, 32);
if (weaponentity != -1 && !StrEqual(weaponname, "worldspawn", false))
{
if (teamid == 3 || teamid == 2)
{
RemovePlayerItem(client, weaponentity);
RemoveEdict(weaponentity);
if (teamid == 3)
{
count++;
}
if (teamid == 2)
{
count++;
}
}
}
}
i += 4;
}
}
else
{
if (g_iWeaponsArray == -1)
{
RemoveWeapon(client, "knife");
}
else
{
decl String:sBuffer[64];
Format(sBuffer, 64, g_sWeaponsArray);
ReplaceString(sBuffer, 64, "weapon_", "", true);
RemoveWeapon(client, sBuffer);
}
new i;
while (i <= 7)
{
if (IsClientInGame(client))
{
if (teamid == 3)
{
if (!StrEqual(ctitems[i], "", false))
{
GivePlayerItem(client, ctitems[i], 0);
}
}
if (teamid == 2)
{
if (!StrEqual(titems[i], "", false))
{
GivePlayerItem(client, titems[i], 0);
}
}
}
i++;
}
}
return 0;
}
public GiveWeapon(client)
{
if (g_iWeaponsArray == -1)
{
GivePlayerItem(client, "weapon_knife", 0);
FakeClientCommand(client, "use weapon_knife");
}
else
{
decl String:sBuffer[64];
decl iBuffer;
Format(sBuffer, 64, "use %s", g_sWeaponsArray);
iBuffer = GivePlayerItem(client, g_sWeaponsArray, 0);
SetEntDataEnt2(client, g_iActiveWeaponOffset, iBuffer, false);
FakeClientCommand(client, sBuffer);
ReplaceString(sBuffer, 64, "use weapon_", "", true);
if (GetTrieValue(g_WeaponSlots, sBuffer, iBuffer))
{
g_iActiveWeapon[client] = GetPlayerWeaponSlot(client, iBuffer);
}
}
return 0;
}
public Action:WinnerEffects()
{
CreateTimer(0.1, LightningTimer, any:0, 1);
CreateTimer(0.6, ExplosionTimer, any:0, 1);
return Action:0;
}
public Action:DelayWeapon(Handle:timer, any:data)
{
new Handle:pack = data;
ResetPack(pack, false);
new client = ReadPackCell(pack);
new String:item[64];
ReadPackString(pack, item, 64);
CloseHandle(pack);
if (!isFighting)
{
return Action:0;
}
RemoveWeapon(client, item);
return Action:0;
}
public Action:LightningTimer(Handle:timer)
{
if (winner)
{
static TimesRepeated;
TimesRepeated += 1;
if (TimesRepeated <= 30)
{
Lightning();
return Action:0;
}
TimesRepeated = 0;
return Action:4;
}
return Action:4;
}
public Action:ExplosionTimer(Handle:timer)
{
if (winner)
{
static TimesRepeated;
TimesRepeated += 1;
if (TimesRepeated <= 3 && IsClientInGame(winner))
{
decl Float:fPos[3];
GetClientAbsOrigin(winner, fPos);
EmitAmbientSound("ambient/explosions/explode_8.wav", fPos, 0, 75, 0, 1.0, 100, 0.0);
return Action:0;
}
TimesRepeated = 0;
}
return Action:4;
}
public Action:KillPlayer(Handle:timer, any:clientid)
{
if (IsClientInGame(clientid) && IsPlayerAlive(clientid))
{
if (!isFighting && ctid != clientid && tid != clientid)
{
return Action:0;
}
if (g_removeNewPlayer == 1 && isFighting && ctid != clientid && tid != clientid)
{
ChangeClientTeam(clientid, 1);
RemoveAllWeapons();
return Action:0;
}
ForcePlayerSuicide(clientid);
}
return Action:0;
}
public Action:SlapTimer(Handle:timer)
{
static TimesRepeated;
if (TimesRepeated <= 1)
{
SlapPlayer(ctid, 0, false);
TimesRepeated += 1;
return Action:0;
}
TimesRepeated = 0;
return Action:4;
}
public Action:TeleportTimer(Handle:timer)
{
TeleportEntity(tid, teleloc, NULL_VECTOR, NULL_VECTOR);
return Action:0;
}
public Action:ItemsWon(Handle:timer, any:client)
{
static TimesRepeated;
if (!IsClientInGame(client))
{
return Action:4;
}
if (TimesRepeated <= 2)
{
PrintHintText(client, itemswon);
TimesRepeated += 1;
return Action:0;
}
TimesRepeated = 0;
return Action:4;
}
public Action:StartFight()
{
if (ctid && tid)
{
return Action:0;
}
alivect = 0;
alivet = 0;
new i = 1;
while (i <= MaxClients)
{
new team;
if (IsClientInGame(i) && IsPlayerAlive(i))
{
team = GetClientTeam(i);
if (team == 3)
{
alivect += 1;
}
if (team == 2)
{
alivet += 1;
}
}
i++;
}
if (alivect == 1 && alivet == 1 && bombplanted)
{
return Action:0;
}
isFighting = true;
if (!IsPlayerAlive(ctid) || !IsPlayerAlive(tid) || GetClientCount(true) < g_minplayers)
{
CancelFight();
return Action:0;
}
RemoveAllWeapons();
if (songsfound != -1)
{
if (songsfound)
{
GetArrayString(g_hSoundsArray, GetRandomInt(0, songsfound), song, 256);
}
else
{
GetArrayString(g_hSoundsArray, 0, song, 256);
}
new clients[MaxClients];
new total;
i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i) && g_soundPrefs[i])
{
total++;
clients[total] = i;
}
i++;
}
if (total)
{
EmitSound(clients, total, song, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
}
CreateTimer(2.0, StartBeacon, ctid, 1);
CreateTimer(1.0, StartBeaconT, tid, 0);
PrintHintTextToAll("%t", "Removing weapons");
WeaponHandler(ctid, 3);
WeaponHandler(tid, 2);
if (g_alltalk)
{
g_alltalkenabled = GetConVarBool(sv_alltalk);
if (!g_alltalkenabled)
{
SetConVarInt(sv_alltalk, 1, false, false);
}
g_alltalkenabled = !g_alltalkenabled;
}
if (g_block)
{
if (!sm_noblock)
{
sm_noblock = FindConVar("sm_noblock");
}
if (sm_noblock)
{
g_blockenabled = !GetConVarBool(sm_noblock);
if (!g_blockenabled)
{
SetConVarInt(sm_noblock, 0, false, false);
}
g_blockenabled = !g_blockenabled;
}
if (!sm_noblock_nades)
{
sm_noblock_nades = FindConVar("sm_noblock_nades");
}
if (sm_noblock_nades)
{
g_blockenabled = !GetConVarBool(sm_noblock_nades);
if (!g_blockenabled)
{
SetConVarInt(sm_noblock_nades, 0, false, false);
}
g_blockenabled = !g_blockenabled;
}
}
g_Cvar_Restrict = FindConVar("sm_allow_restricted_pickup");
if (g_Cvar_Restrict && !GetConVarBool(g_Cvar_Restrict))
{
SetConVarInt(g_Cvar_Restrict, 1, false, false);
g_bSetRestrict = true;
}
if (g_useteleport)
{
if (g_restorehealth)
{
SetEntData(ctid, g_iHealth, any:500, 4, true);
SetEntData(tid, g_iHealth, any:500, 4, true);
}
new Float:ctvec[3] = 0.0;
new Float:tvec[3] = 0.0;
new Float:distance[1] = 0.0;
GetClientAbsOrigin(ctid, ctvec);
GetClientAbsOrigin(tid, tvec);
SetEntData(ctid, g_iCollisionGroupOffs, any:2, 4, true);
SetEntData(tid, g_iCollisionGroupOffs, any:2, 4, true);
distance[0] = GetVectorDistance(ctvec, tvec, true);
if (distance[0] >= 600000.0)
{
teleloc = ctvec;
CreateTimer(0.1, SlapTimer, any:0, 1);
CreateTimer(0.5, TeleportTimer, any:0, 0);
}
else
{
if (g_locatorbeam)
{
CreateTimer(0.1, DrawBeamsTimer, any:0, 1);
}
}
}
else
{
if (g_locatorbeam)
{
CreateTimer(0.1, DrawBeamsTimer, any:0, 1);
}
}
CreateTimer(1.0, Countdown, any:0, 1);
return Action:0;
}
public Action:CancelFight()
{
ctagree = -1;
tagree = -1;
isFighting = false;
if (g_stopmusic && songsfound != -1)
{
new clients[MaxClients];
new total;
new i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i) && g_soundPrefs[i])
{
total++;
clients[total] = i;
}
i++;
}
if (total)
{
EmitSound(clients, total, song, -2, 0, 75, 6, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
}
if (winner)
{
if (IsPlayerAlive(winner))
{
WeaponHandler(winner, GetClientTeam(winner));
new i;
while (i <= 7)
{
i++;
}
}
}
return Action:0;
}
public Action:FightTimer(Handle:timer)
{
if (!isFighting)
{
return Action:4;
}
if (0 <= fighttimer)
{
PrintHintTextToAll("%t: %i", "Time remaining", fighttimer);
if (fighttimer < 6)
{
EmitSoundToAll("ambient/tones/floor1.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
fighttimer -= 1;
return Action:0;
}
new healthCT = GetClientHealth(ctid);
new healthT = GetClientHealth(tid);
if (healthT == healthCT)
{
if (g_randomkill)
{
if (GetRandomInt(0, 1))
{
CreateTimer(0.1, KillPlayer, ctid, 0);
CreateTimer(0.1, KillPlayer, tid, 0);
}
else
{
CreateTimer(0.1, KillPlayer, tid, 0);
CreateTimer(0.1, KillPlayer, ctid, 0);
}
}
else
{
CreateTimer(0.1, KillPlayer, ctid, 0);
CreateTimer(0.1, KillPlayer, tid, 0);
}
}
else
{
if (healthT < healthCT)
{
CreateTimer(0.1, KillPlayer, tid, 0);
}
CreateTimer(0.1, KillPlayer, ctid, 0);
}
PrintHintTextToAll("%t", "Fight draw");
return Action:4;
}
public Action:Countdown(Handle:timer)
{
if (!isFighting)
{
timesrepeated = g_countdowntimer;
return Action:4;
}
SetEntDataFloat(ctid, g_iSpeed, 1.0, true);
SetEntDataFloat(tid, g_iSpeed, 1.0, true);
if (timesrepeated >= 1)
{
PrintHintTextToAll("%t: %i", "Prepare fight", timesrepeated);
timesrepeated -= 1;
return Action:0;
}
else
{
if (g_bSDKHooksLoaded)
{
SDKHook(ctid, SDKHookType:2, OnTakeDamage);
SDKHook(tid, SDKHookType:2, OnTakeDamage);
g_bOnTakeDamage = true;
}
if (g_restorehealth)
{
SetEntData(ctid, g_iHealth, any:100, 4, true);
SetEntData(ctid, g_iArmorOffset, any:100, 4, true);
SetEntData(tid, g_iHealth, any:100, 4, true);
SetEntData(tid, g_iArmorOffset, any:100, 4, true);
}
}
PrintHintTextToAll("%t", "Fight");
GiveWeapon(ctid);
GiveWeapon(tid);
SetEntData(ctid, g_iCollisionGroupOffs, any:5, 4, true);
SetEntData(tid, g_iCollisionGroupOffs, any:5, 4, true);
timesrepeated = g_countdowntimer;
CreateTimer(1.0, FightTimer, any:0, 1);
return Action:4;
}
public Action:DrawBeamsTimer(Handle:timer)
{
if (!isFighting || !IsPlayerAlive(ctid) || !IsPlayerAlive(tid))
{
return Action:4;
}
new Float:ctvec[3] = 0.0;
new Float:tvec[3] = 0.0;
new Float:distance[1] = 0.0;
new color[4] = {255,75,75,255};
GetClientEyePosition(ctid, ctvec);
GetClientEyePosition(tid, tvec);
distance[0] = GetVectorDistance(ctvec, tvec, true);
if (distance[0] < 200000.0)
{
return Action:4;
}
TE_SetupBeamPoints(ctvec, tvec, g_locatebeam, g_locatehalo, 1, 1, 0.1, 5.0, 5.0, 0, 10.0, color, 255);
TE_SendToClient(tid, 0.0);
TE_SetupBeamPoints(tvec, ctvec, g_locatebeam, g_locatehalo, 1, 1, 0.1, 5.0, 5.0, 0, 10.0, color, 255);
TE_SendToClient(ctid, 0.0);
return Action:0;
}
public Action:StartBeaconT(Handle:timer)
{
CreateTimer(2.0, StartBeacon, tid, 1);
return Action:0;
}
public Action:StartBeacon(Handle:timer, any:client)
{
if (!isFighting || !IsClientInGame(ctid) || !IsClientInGame(tid))
{
return Action:4;
}
new redColor[4] = {255,75,75,255};
new blueColor[4] = {75,75,255,255};
new team = GetClientTeam(client);
new Float:vec[3] = 0.0;
GetClientAbsOrigin(client, vec);
vec[2] += 10;
if (team == 2)
{
TE_SetupBeamRingPoint(vec, 10.0, g_beaconragius, g_beamsprite, g_halosprite, 0, 10, 1.0, 10.0, 0.0, redColor, 0, 0);
}
else
{
if (team == 3)
{
TE_SetupBeamRingPoint(vec, 10.0, g_beaconragius, g_beamsprite, g_halosprite, 0, 10, 1.0, 10.0, 0.0, blueColor, 0, 0);
}
}
TE_SendToAll(0.0);
GetClientEyePosition(client, vec);
if (IsSoundPrecached(g_beaconsound))
{
EmitAmbientSound(g_beaconsound, vec, client, 130, 0, 1.0, 100, 0.0);
}
return Action:0;
}
public Action:VerifyConditions(Handle:timer)
{
new Handle:warmup = FindConVar("sm_warmupround_active");
if (warmup)
{
if (GetConVarBool(warmup))
{
return Action:0;
}
}
if (g_intermission)
{
return Action:0;
}
if (ctid && tid)
{
return Action:0;
}
if (GetClientCount(true) < g_minplayers)
{
return Action:0;
}
if (IsClientInGame(ctid) && IsPlayerAlive(ctid) && IsClientInGame(tid) && IsPlayerAlive(tid))
{
if (IsFakeClient(ctid) && IsFakeClient(tid))
{
if (!g_isBotFightAllowed)
{
return Action:0;
}
}
winner = 0;
GetClientName(ctid, ctname, 32);
GetClientName(tid, tname, 32);
PrintHintTextToAll("%t", "1v1 situation");
if (g_forcefight)
{
CreateTimer(0.5, DelayFight, any:0, 0);
}
SendFightMenus(ctid, tid);
}
return Action:0;
}
public Action:DelayFight(Handle:timer)
{
StartFight();
return Action:0;
}
public OnClientDisconnect(client)
{
if (!isFighting)
{
}
if (ctid == client)
{
winner = tid;
loser = tid;
CancelFight();
}
else
{
if (tid == client)
{
winner = ctid;
loser = ctid;
CancelFight();
}
}
}
public EventRoundStart(Handle:event, String:name[], bool:dontBroadcast)
{
if (g_enabled)
{
if (g_alltalk && g_alltalkenabled)
{
g_alltalkenabled = false;
SetConVarInt(sv_alltalk, 0, false, false);
}
if (g_block && g_blockenabled)
{
g_blockenabled = false;
if (!sm_noblock)
{
sm_noblock = FindConVar("sm_noblock");
}
if (sm_noblock)
{
SetConVarInt(sm_noblock, 1, false, false);
}
if (!sm_noblock_nades)
{
sm_noblock_nades = FindConVar("sm_noblock_nades");
}
if (sm_noblock_nades)
{
SetConVarInt(sm_noblock_nades, 1, false, false);
}
}
if (g_Cvar_Restrict && g_bSetRestrict && GetConVarBool(g_Cvar_Restrict))
{
SetConVarInt(g_Cvar_Restrict, 0, false, false);
g_bSetRestrict = false;
}
if (isFighting)
{
CancelFight();
}
alivect = 0;
alivet = 0;
if (g_bSDKHooksLoaded && g_bOnTakeDamage)
{
SDKUnhook(ctid, SDKHookType:2, OnTakeDamage);
SDKUnhook(tid, SDKHookType:2, OnTakeDamage);
g_bOnTakeDamage = false;
}
ctid = 0;
tid = 0;
loser = 0;
bombplanted = false;
timesrepeated = g_countdowntimer;
fighttimer = g_fighttimer;
if (g_iWeaponsArray != -1)
{
if (g_iWeaponsArray)
{
g_iRandomInt = GetRandomInt(0, g_iWeaponsArray);
GetArrayString(g_hWeaponsArray, g_iRandomInt, g_sWeaponsArray, 64);
}
GetArrayString(g_hWeaponsArray, 0, g_sWeaponsArray, 64);
}
}
}
public EventWeaponFire(Handle:event, String:name[], bool:dontBroadcast)
{
if (g_enabled && isFighting && g_iWeaponsArray != -1 && g_bFightRoundAutoSwitch[g_iRandomInt])
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client && IsClientConnected(client) && IsClientInGame(client))
{
decl String:sBuffer[64];
GetClientWeapon(client, sBuffer, 64);
if (strcmp(sBuffer, g_sWeaponsArray, false))
{
}
else
{
if (g_iActiveWeapon[client] > 1 && IsValidEdict(g_iActiveWeapon[client]))
{
new Handle:hDataPack;
CreateDataTimer(0.11, Timer_WeaponFire, hDataPack, 0);
WritePackCell(hDataPack, client);
}
}
}
}
return 0;
}
public Action:Timer_WeaponFire(Handle:timer, Handle:hDataPack)
{
ResetPack(hDataPack, false);
new client = ReadPackCell(hDataPack);
if (IsClientConnected(client) && IsClientInGame(client))
{
decl String:sWeapon[64];
decl slot;
if (IsValidEdict(g_iActiveWeapon[client]))
{
RemovePlayerItem(client, g_iActiveWeapon[client]);
RemoveEdict(g_iActiveWeapon[client]);
GivePlayerItem(client, g_sWeaponsArray, 0);
}
strcopy(sWeapon, 64, g_sWeaponsArray);
ReplaceString(sWeapon, 64, "weapon_", "", true);
if (GetTrieValue(g_WeaponSlots, sWeapon, slot))
{
g_iActiveWeapon[client] = GetPlayerWeaponSlot(client, slot);
}
}
return Action:4;
}
public EventWeaponZoom(Handle:event, String:name[], bool:dontBroadcast)
{
if (g_enabled && isFighting && g_iWeaponsArray != -1 && g_bFightRoundNoZoom[g_iRandomInt])
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client && IsClientConnected(client) && IsClientInGame(client))
{
new weapon = GetPlayerWeaponSlot(client, 0);
if (weapon > 0 && IsValidEdict(weapon))
{
RemovePlayerItem(client, weapon);
RemoveEdict(weapon);
CreateTimer(0.1, Timer_GiveWeapon, client, 0);
PrintHintText(client, "%t", "zoom is disabled");
}
}
}
return 0;
}
public Action:Timer_GiveWeapon(Handle:timer, any:client)
{
if (isFighting && IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
{
GivePlayerItem(client, g_sWeaponsArray, 0);
}
return Action:4;
}
public EventBombPlanted(Handle:event, String:name[], bool:dontBroadcast)
{
if (g_enabled)
{
bombplanted = true;
}
return 0;
}
public Action:EventItemPickup(Handle:event, String:name[], bool:dontBroadcast)
{
if (!g_enabled || !isFighting)
{
return Action:0;
}
new clientid = GetClientOfUserId(GetEventInt(event, "userid"));
if (clientid && IsClientConnected(clientid) && IsClientInGame(clientid) && IsPlayerAlive(clientid))
{
if (ctid != clientid && tid != clientid)
{
new String:item[64];
GetEventString(event, "item", item, 64);
if (g_iWeaponsArray == -1)
{
if (!StrEqual(item, "knife", false))
{
FakeClientCommand(clientid, "use weapon_knife");
new Handle:pack = CreateDataPack();
WritePackCell(pack, clientid);
WritePackString(pack, item);
CreateTimer(0.1, DelayWeapon, pack);
}
}
else
{
decl String:sBuffer[64];
decl slot;
Format(sBuffer, 64, "weapon_%s", item);
if (StrEqual(sBuffer, g_sWeaponsArray, false))
{
strcopy(sBuffer, 64, g_sWeaponsArray);
ReplaceString(sBuffer, 64, "weapon_", "", true);
if (GetTrieValue(g_WeaponSlots, sBuffer, slot))
{
g_iActiveWeapon[clientid] = GetPlayerWeaponSlot(clientid, slot);
}
}
else
{
Format(sBuffer, 64, "use %s", g_sWeaponsArray);
FakeClientCommand(clientid, sBuffer);
new Handle:pack = CreateDataPack();
WritePackCell(pack, clientid);
WritePackString(pack, item);
CreateTimer(0.1, DelayWeapon, pack, 0);
}
}
}
}
return Action:0;
}
public EventPlayerDeath(Handle:event, String:name[], bool:dontBroadcast)
{
alivect = 0;
alivet = 0;
if (g_enabled && isFighting)
{
loser = GetClientOfUserId(GetEventInt(event, "userid"));
if (ctid != loser && tid != loser)
{
winner = GetClientOfUserId(GetEventInt(event, "attacker"));
if (g_iWeaponsArray != -1)
{
if (loser && IsClientConnected(loser) && IsClientInGame(loser) && g_iActiveWeapon[loser] > 1 && IsValidEdict(g_iActiveWeapon[loser]) && IsValidEntity(g_iActiveWeapon[loser]))
{
RemovePlayerItem(loser, g_iActiveWeapon[loser]);
RemoveEdict(g_iActiveWeapon[loser]);
}
if (winner && IsClientConnected(winner) && IsClientInGame(winner) && g_iActiveWeapon[winner] > 1 && IsValidEdict(g_iActiveWeapon[winner]) && IsValidEntity(g_iActiveWeapon[winner]))
{
RemovePlayerItem(winner, g_iActiveWeapon[winner]);
RemoveEdict(g_iActiveWeapon[winner]);
}
}
if (loser != winner && winner)
{
if (g_losereffects)
{
CreateTimer(0.4, DissolveRagdoll, loser, 0);
}
g_winnerid = winner;
GetClientName(winner, winnername, 32);
if (g_showWinner)
{
if (g_showWinner == 1)
{
new String:msg[192];
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', winnername, '\x04', "has won", i);
PrintMsg(i, winner, msg);
}
i++;
}
}
}
else
{
new team = GetClientTeam(winner);
decl r;
new var6;
if (team == 2)
{
var6 = 255;
}
else
{
var6 = 0;
}
r = var6;
decl g;
new var7;
if (team == 3)
{
var7 = 128;
}
else
{
if (team == 2)
{
var7 = 0;
}
var7 = 255;
}
g = var7;
decl b;
new var8;
if (team == 3)
{
var8 = 255;
}
else
{
var8 = 0;
}
b = var8;
decl Handle:hMsg;
decl String:Buffer[64];
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
{
hMsg = CreateKeyValues("msg", "", "");
Format(Buffer, 64, "%s %T", winnername, "has won", i);
KvSetString(hMsg, "title", Buffer);
KvSetColor(hMsg, "color", r, g, b, 255);
KvSetNum(hMsg, "level", 0);
KvSetNum(hMsg, "time", 10);
CreateDialog(i, hMsg, DialogType:0);
CloseHandle(hMsg);
}
i++;
}
}
if (g_winnereffects)
{
WinnerEffects();
}
CancelFight();
}
if (loser == ctid)
{
winner = tid;
CancelFight();
}
if (loser == tid)
{
winner = ctid;
CancelFight();
}
}
}
else
{
if (g_enabled && !isFighting)
{
new i = 1;
while (i <= MaxClients)
{
new team;
if (IsClientInGame(i) && IsPlayerAlive(i))
{
team = GetClientTeam(i);
if (team == 3)
{
ctid = i;
alivect += 1;
}
if (team == 2)
{
tid = i;
alivet += 1;
}
}
i++;
}
if (alivect == 1 && alivet == 1 && !bombplanted)
{
CreateTimer(0.5, VerifyConditions, any:0, 0);
}
}
}
return 0;
}
public EventPlayerSpawn(Handle:event, String:name[], bool:dontBroadcast)
{
if (g_enabled)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client && IsClientInGame(client))
{
if (isFighting)
{
CreateTimer(0.1, KillPlayer, client, 0);
}
if (g_winnerid == client)
{
if (g_winnerhealth > 0 || g_winnermoney > 0 || g_winnerspeed > 0.0)
{
new String:buffer[256];
Format(buffer, 256, "%T", "Items won", client);
StrCat(itemswon, 256, buffer);
if (0 < g_winnerhealth)
{
SetEntData(client, g_iHealth, g_winnerhealth, 4, true);
Format(buffer, 256, "\n%T: %i", "Health", client, g_winnerhealth);
StrCat(itemswon, 256, buffer);
}
if (0 < g_winnermoney)
{
new totalmoney = GetEntData(client, g_iAccount, 4) + g_winnermoney;
SetEntData(client, g_iAccount, totalmoney, 4, true);
Format(buffer, 256, "\n%T: $%i", "Money", client, g_winnermoney);
StrCat(itemswon, 256, buffer);
}
if (g_winnerspeed > 0.0)
{
SetEntDataFloat(client, g_iSpeed, g_winnerspeed, true);
Format(buffer, 256, "\n%T: %.2fx", "Speed", client, g_winnerspeed);
StrCat(itemswon, 256, buffer);
}
CreateTimer(1.0, ItemsWon, client, 1);
g_winnerid = 0;
}
}
}
}
return 0;
}
public Action:DissolveRagdoll(Handle:timer, any:client)
{
if (IsClientConnected(client) && IsClientInGame(client) && !IsPlayerAlive(client) && IsValidEntity(client))
{
new ragdoll = GetEntPropEnt(client, PropType:0, "m_hRagdoll", 0);
if (0 > ragdoll)
{
return Action:0;
}
new String:dname[32];
Format(dname, 32, "dis_%i", client);
new entid = CreateEntityByName("env_entity_dissolver", -1);
if (0 < entid)
{
DispatchKeyValue(ragdoll, "targetname", dname);
DispatchKeyValue(entid, "dissolvetype", "0");
DispatchKeyValue(entid, "target", dname);
AcceptEntityInput(entid, "Dissolve", -1, -1, 0);
AcceptEntityInput(entid, "kill", -1, -1, 0);
}
}
return Action:0;
}
public SendFightMenus(ct, t)
{
ctagree = -1;
tagree = -1;
new String:msg[192];
if (IsFakeClient(ct) || g_fightPrefs[ct] == 1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', ctname, '\x04', "Player agrees", i);
PrintMsg(i, ct, msg);
}
i++;
}
ctagree = 1;
}
else
{
if (g_fightPrefs[ct] == -1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', ctname, '\x04', "Player disagrees", i);
PrintMsg(i, ct, msg);
}
i++;
}
ctagree = 0;
if (IsSoundPrecached(g_declinesound))
{
EmitSoundToAll(g_declinesound, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
}
SendKnifeMenu(ct);
}
if (IsFakeClient(t) || g_fightPrefs[t] == 1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', tname, '\x04', "Player agrees", i);
PrintMsg(i, t, msg);
}
i++;
}
tagree = 1;
}
else
{
if (g_fightPrefs[t] == -1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', tname, '\x04', "Player disagrees", i);
PrintMsg(i, t, msg);
}
i++;
}
tagree = 0;
EmitSoundToAll(g_declinesound, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
SendKnifeMenu(t);
}
if (ctagree == 1 && tagree == 1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x04', "Both agree", i);
PrintMsg(i, 0, msg);
}
i++;
}
CreateTimer(0.5, DelayFight, any:0, 0);
}
return 0;
}
public SendKnifeMenu(client)
{
new String:sBuffer[128];
new Handle:panel = CreatePanel(Handle:0);
Format(sBuffer, 128, "%T", "Menu title", client);
SetPanelTitle(panel, sBuffer, false);
DrawPanelItem(panel, " ", 10);
Format(sBuffer, 128, "%T", "Question", client);
DrawPanelText(panel, sBuffer);
DrawPanelText(panel, "-----------------------------");
Format(sBuffer, 128, "%T", "Yes option", client);
DrawPanelItem(panel, sBuffer, 0);
Format(sBuffer, 128, "%T", "No option", client);
DrawPanelItem(panel, sBuffer, 0);
DrawPanelText(panel, "-----------------------------");
SendPanelToClient(panel, client, PanelHandler, 15);
CloseHandle(panel);
return 0;
}
public PanelHandler(Handle:menu, MenuAction:action, client, item)
{
new String:msg[192];
if (action == MenuAction:4)
{
if (item == 1 && client)
{
if (GetClientTeam(client) == 3 && ctid == client && IsClientInGame(tid) && IsPlayerAlive(tid))
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', ctname, '\x04', "Player agrees", i);
PrintMsg(i, client, msg);
}
i++;
}
ctagree = 1;
}
else
{
if (GetClientTeam(client) == 2 && tid == client && IsClientInGame(ctid) && IsPlayerAlive(ctid))
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', tname, '\x04', "Player agrees", i);
PrintMsg(i, client, msg);
}
i++;
}
tagree = 1;
}
}
}
else
{
if (item == 2 && client)
{
if (GetClientTeam(client) == 3 && ctid == client && IsClientInGame(tid) && IsPlayerAlive(tid))
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', ctname, '\x04', "Player disagrees", i);
PrintMsg(i, client, msg);
}
i++;
}
ctagree = 0;
EmitSoundToAll(g_declinesound, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
if (GetClientTeam(client) == 2 && tid == client && IsClientInGame(ctid) && IsPlayerAlive(ctid))
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%s %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x03', tname, '\x04', "Player disagrees", i);
PrintMsg(i, client, msg);
}
i++;
}
tagree = 0;
EmitSoundToAll(g_declinesound, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
}
}
}
else
{
if (action == MenuAction:8)
{
if (IsClientInGame(client) && IsPlayerAlive(client))
{
Format(msg, 192, "%c[%c%T%c] %c%T", '\x04', '\x01', "Weapon Fight", client, '\x04', '\x04', "Restore fight menu", client);
PrintMsg(client, 0, msg);
}
}
}
if (ctagree == 1 && tagree == 1)
{
new i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
Format(msg, 192, "%c[%c%T%c] %c%T", '\x04', '\x01', "Weapon Fight", i, '\x04', '\x04', "Both agree", i);
PrintMsg(i, 0, msg);
}
i++;
}
StartFight();
}
return 0;
}
public Lightning()
{
if (!IsClientInGame(winner) || !IsPlayerAlive(winner))
{
return 0;
}
new Float:playerpos[3] = 0.0;
GetClientAbsOrigin(winner, playerpos);
new Float:toppos[3] = 0.0;
toppos[0] = playerpos[0];
toppos[1] = playerpos[1];
toppos[2] = playerpos[2] + 1000;
new lightningcolor[4];
lightningcolor[0] = 255;
lightningcolor[1] = 255;
lightningcolor[2] = 255;
lightningcolor[3] = 255;
new Float:lightninglife = 0.1;
new Float:lightningwidth = 40.0;
new Float:lightningendwidth = 10.0;
new lightningstartframe;
new lightningframerate = 20;
new lightningfadelength = 1;
new Float:lightningamplitude = 20.0;
new lightningspeed = 250;
TE_SetupBeamPoints(toppos, playerpos, g_lightning, g_lightning, lightningstartframe, lightningframerate, lightninglife, lightningwidth, lightningendwidth, lightningfadelength, lightningamplitude, lightningcolor, lightningspeed);
TE_SendToAll(0.0);
return 0;
}
public RemoveWeapon(client, String:weapon[])
{
new slot;
new curr_weapon;
GetTrieValue(g_WeaponSlots, weapon, slot);
curr_weapon = GetPlayerWeaponSlot(client, slot);
if (!client || !IsValidEntity(curr_weapon))
{
return 0;
}
RemovePlayerItem(client, curr_weapon);
return 0;
}
public OnClientPutInServer(client)
{
g_soundPrefs[client] = GetConVarInt(g_Cvar_SoundPrefDefault);
g_fightPrefs[client] = 0;
if (!IsFakeClient(client))
{
if (AreClientCookiesCached(client))
{
loadClientCookies(client);
}
}
}
public OnClientCookiesCached(client)
{
if (IsClientInGame(client) && !IsFakeClient(client))
{
loadClientCookies(client);
}
}
public loadClientCookies(client)
{
decl String:buffer[8];
GetClientCookie(client, g_Cookie_SoundPref, buffer, 5);
if (!StrEqual(buffer, "", true))
{
g_soundPrefs[client] = StringToInt(buffer, 10);
}
GetClientCookie(client, g_Cookie_FightPref, buffer, 5);
if (!StrEqual(buffer, "", true))
{
g_fightPrefs[client] = StringToInt(buffer, 10);
}
return 0;
}
public MenuHandlerKnifeFight(Handle:menu, MenuAction:action, client, item)
{
if (action == MenuAction:4)
{
if (item)
{
if (item == 1)
{
if (!isFighting && (client != tid && client != ctid) && alivect == 1 && alivet == 1 && GetClientCount(true) >= g_minplayers)
{
SendKnifeMenu(client);
}
else
{
MenuKnifeFight(client, 0);
}
}
if (item == 2 || item == 3)
{
if ((item == 2 && g_fightPrefs[client] == 1) || (item == 3 && g_fightPrefs[client] == -1))
{
g_fightPrefs[client] = 0;
}
else
{
new var8;
if (item == 2)
{
var8 = 1;
}
else
{
var8 = -1;
}
g_fightPrefs[client] = var8;
}
decl String:buffer[8];
IntToString(g_fightPrefs[client], buffer, 5);
SetClientCookie(client, g_Cookie_FightPref, buffer);
MenuKnifeFight(client, 0);
}
}
else
{
new var1;
if (g_soundPrefs[client])
{
var1 = 0;
}
else
{
var1 = 1;
}
g_soundPrefs[client] = var1;
decl String:buffer[8];
IntToString(g_soundPrefs[client], buffer, 5);
SetClientCookie(client, g_Cookie_SoundPref, buffer);
MenuKnifeFight(client, 0);
}
}
else
{
if (action == MenuAction:16)
{
CloseHandle(menu);
}
}
return 0;
}
public Action:MenuKnifeFight(client, args)
{
new Handle:menu = CreateMenu(MenuHandlerKnifeFight, MenuAction:28);
decl String:sBuffer[128];
Format(sBuffer, 128, "%T", "WeaponFight settings", client);
SetMenuTitle(menu, sBuffer);
if (g_soundPrefs[client])
{
Format(sBuffer, 128, "%T %T", "Play fight songs", client, "Selected", client);
}
else
{
Format(sBuffer, 128, "%T %T", "Play fight songs", client, "NotSelected", client);
}
AddMenuItem(menu, "Play fight songs", sBuffer, 0);
Format(sBuffer, 128, "%T", "Show fight panel", client);
new var3;
if (!isFighting && (client != tid && client != ctid) && alivect == 1 && alivet == 1 && GetClientCount(true) >= g_minplayers)
{
var3 = 0;
}
else
{
var3 = 1;
}
AddMenuItem(menu, "Show fight panel", sBuffer, var3);
new var4;
if (g_fightPrefs[client] == 1)
{
var4 = 12332;
}
else
{
var4 = 12344;
}
Format(sBuffer, 128, "%T %T", "Always agree to weapon fight", client, var4, client);
AddMenuItem(menu, "Always agree to weapon fight", sBuffer, 0);
new var5;
if (g_fightPrefs[client] == -1)
{
var5 = 12428;
}
else
{
var5 = 12440;
}
Format(sBuffer, 128, "%T %T", "Always disagree to weapon fight", client, var5, client);
AddMenuItem(menu, "Always disagree to weapon fight", sBuffer, 0);
SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 32);
return Action:3;
}
public RemoveAllWeapons()
{
new maxent = GetMaxEntities();
new String:weapon[64];
new i = MaxClients;
while (i < maxent)
{
if (IsValidEdict(i) && IsValidEntity(i) && GetEntDataEnt2(i, g_WeaponParent) == -1)
{
GetEdictClassname(i, weapon, 64);
if (StrContains(weapon, "weapon_", true) == -1 && StrEqual(weapon, "hostage_entity", true) && StrContains(weapon, "item_", true) == -1)
{
RemoveEdict(i);
}
}
i++;
}
return 0;
}
public ParsFile(String:file[], bool:sound)
{
new String:sBuffer[256];
new iBuffer;
BuildPath(PathType:0, sBuffer, 256, "configs/%s", file);
new Handle:hFile = OpenFile(sBuffer, "r");
if (hFile)
{
while (!IsEndOfFile(hFile))
{
if (ReadFileLine(hFile, sBuffer, 256))
{
iBuffer = StrContains(sBuffer, "//", true);
if (iBuffer != -1)
{
sBuffer[iBuffer] = 0;
}
iBuffer = StrContains(sBuffer, "#", true);
if (iBuffer != -1)
{
sBuffer[iBuffer] = 0;
}
iBuffer = StrContains(sBuffer, ";", true);
if (iBuffer != -1)
{
sBuffer[iBuffer] = 0;
}
TrimString(sBuffer);
if (sBuffer[0])
{
if (sound)
{
if (StrContains(sBuffer, "=NoZoom", true) != -1)
{
ReplaceString(sBuffer, 256, "=NoZoom", "", true);
if (StrContains(sBuffer, "=AutoSwitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=AutoSwitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
else
{
if (StrContains(sBuffer, "=autoswitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=autoswitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 0;
}
}
}
else
{
if (StrContains(sBuffer, "=nozoom", true) != -1)
{
ReplaceString(sBuffer, 256, "=nozoom", "", true);
if (StrContains(sBuffer, "=AutoSwitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=AutoSwitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
else
{
if (StrContains(sBuffer, "=autoswitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=autoswitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 1;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 0;
}
}
}
if (StrContains(sBuffer, "=AutoSwitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=AutoSwitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 0;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
if (StrContains(sBuffer, "=autoswitch", true) != -1)
{
ReplaceString(sBuffer, 256, "=autoswitch", "", true);
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 0;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 1;
}
}
if (ParsWeapon(sBuffer))
{
g_bFightRoundNoZoom[g_iWeaponsArray] = 0;
g_bFightRoundAutoSwitch[g_iWeaponsArray] = 0;
}
}
}
else
{
if (PrecacheSound(sBuffer, true))
{
songsfound += 1;
PushArrayString(g_hSoundsArray, sBuffer);
Format(sBuffer, 256, "sound/%s", sBuffer);
AddFileToDownloadsTable(sBuffer);
}
LogError("[WeaponFight] Could not pre-cache sound: %s", sBuffer);
}
}
}
}
CloseHandle(hFile);
}
return 0;
}
public bool:ParsWeapon(String:weapon[])
{
decl String:sBuffer[64];
decl iBuffer;
if (GetTrieValue(g_hWeaponsTrie, weapon, iBuffer) && g_iWeaponsArray < 32)
{
Format(sBuffer, 64, "weapon_%s", weapon);
PushArrayString(g_hWeaponsArray, sBuffer);
g_iWeaponsArray += 1;
return true;
}
return false;
}
public PrintMsg(client, author, String:message[])
{
new Handle:buffer = StartMessageOne("SayText2", client, 0);
BfWriteByte(buffer, author);
BfWriteByte(buffer, 1);
BfWriteString(buffer, message);
EndMessage();
return 0;
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
if (attacker && attacker <= MaxClients && attacker == victim)
{
return Action:3;
}
return Action:0;
}
This error become because this plugin is compile in sm 1.8 and i am using 1.7 than this error comes.
i update my sourcemod version to 1.10 and its works error gone