PHP Code:
#include <basecomm>
#include <cstrike>
#include <clientprefs>
#include <geoip>
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <sdktools_functions>
#include <smlib>
#include <sourcemod>
#include <sdktools_sound>
#include <console>
#include <string>
// Compiler Options
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_NAME "test"
#define PLUGIN_AUTHOR "test"
#define PLUGIN_DESCRIPTION "test"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_URL "test"
bool
DuelEnabled = false,
DuelDeagle = false,
DuelHe = false,
DuelDecoy = false,
DuelRevolver = false,
DuelPumni = false,
PlayerDuelGuard[MAXPLAYERS+1] = false,
PlayerDuelPrisonier[MAXPLAYERS+1] = false;
char
DuelDeagleBlock[][] =
{
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_hegrenade","weapon_incgrenade","weapon_molotov",
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
},
DuelRevolverBlock[][] =
{
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
"weapon_tec9","weapon_cz75a","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_hegrenade","weapon_incgrenade","weapon_molotov",
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
},
DuelHeBlock[][] =
{
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_deagle","weapon_incgrenade","weapon_molotov",
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
},
DuelDecoyBlock[][] =
{
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_hegrenade","weapon_deagle","weapon_incgrenade","weapon_molotov",
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
},
DuelPumniBlock[][] =
{
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_hegrenade","weapon_deagle","weapon_incgrenade","weapon_molotov",
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_decoy","weapon_melee"
};
Handle
attack_timer = INVALID_HANDLE,
trie_armas;
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = PLUGIN_URL
};
// Stocks
stock bool IsValidClient(int client)
{
if(client <= 0) return false;
if(client > MaxClients) return false;
if(!IsClientConnected(client)) return false;
if(IsFakeClient(client)) return false;
if(IsClientSourceTV(client)) return false;
return IsClientInGame(client);
}
stock void ClearTimer(Handle &timer)
{
if(timer != INVALID_HANDLE)
{
KillTimer(timer);
}
timer = INVALID_HANDLE;
}
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
HookEvent("weapon_fire", ClientWeaponReload);
HookEvent("round_start", Event_RoundStart);
//HookEvent("player_spawn", Event_PlayerSpawn);
RegConsoleCmd("sm_lr", Command_Duel);
RegConsoleCmd("sm_duel", Command_Duel);
DuelEnabled = false;
DuelDeagle = false;
DuelRevolver = false;
DuelHe = false;
DuelDecoy = false;
DuelPumni = false;
trie_armas = CreateTrie();
}
public void OnMapStart()
{
AddFileToDownloadsTable("sound/music/lrnew.mp3");
PrecacheSound("music/lrnew.mp3", true);
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid")), attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
char cname[32], aname[32];
GetClientName(client, cname, 32);
GetClientName(attacker, aname, 32);
int weapon;
if (!attacker)
{
return;
}
if (attacker == client)
{
return;
}
int Prisoners;
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
if (GetClientTeam(i) == CS_TEAM_T)
{
Prisoners++;
}
}
}
if(DuelEnabled)
{
if(GetClientTeam(attacker) == 2 && GetClientTeam(client) == 3 && attacker != client)
{
DuelEnabled = false;
DuelDeagle = false;
DuelRevolver = false;
DuelHe = false;
DuelDecoy = false;
DuelPumni = false;
PlayerDuelGuard[client] = false;
PlayerDuelPrisonier[client] = false;
FakeClientCommand(attacker, "sm_lr");
}
}
else
{
if(Prisoners == 1)
{
for(int idx = 1; idx <= MaxClients; idx++)
{
if (IsValidClient (idx) && IsPlayerAlive(idx) && GetClientTeam(idx) == CS_TEAM_T )
{
FakeClientCommand(idx, "sm_lr");
}
}
}
DuelEnabled = false;
DuelDeagle = false;
DuelRevolver = false;
DuelHe = false;
DuelDecoy = false;
DuelPumni = false;
PlayerDuelGuard[client] = false;
PlayerDuelPrisonier[client] = false;
}
if(GetClientTeam(client) == 2)
{
weapon = GivePlayerItem(client, "weapon_fists");
EquipPlayerWeapon(client, weapon);
}
else if(GetClientTeam(client) == 3)
{
weapon = GivePlayerItem(client, "weapon_fists");
EquipPlayerWeapon(client, weapon);
}
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
DuelEnabled = false;
DuelDeagle = false;
DuelRevolver = false;
DuelHe = false;
DuelDecoy = false;
DuelPumni = false;
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
int weapon;
RemoveAllWeapons(x);
weapon = GivePlayerItem(x, "weapon_fists");
EquipPlayerWeapon(x, weapon);
}
}
}
public Action Command_Duel(int client, int args)
{
if(!IsPlayerAlive(client) && GetClientTeam(client) == 2)
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Trebuie să fii în viată pentru a face duel.");
return Plugin_Handled;
}
if(!DuelEnabled)
{
int availabletargetsG = 0;
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i))
{
++availabletargetsG;
}
}
if(availabletargetsG > 0) // Verificare gardieni
{
int availabletargets = 0;
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
{
++availabletargets;
}
}
if(availabletargets > 1)
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Nu ești ultimul deținut să poți face duel.");
return Plugin_Handled;
}
else
{
if(IsPlayerAlive(client) && GetClientTeam(client) == 2)
{
Menu meniu_duel = new Menu(DuelMenuHandler);
meniu_duel.SetTitle("----------------\nUltima Dorință\n----------------");
meniu_duel.AddItem("", "Duel Cuțite");
meniu_duel.AddItem("", "Duel Mâini Goale");
meniu_duel.AddItem("", "Duel Pistoale");
meniu_duel.AddItem("", "Duel Grenade");
meniu_duel.ExitButton = false;
meniu_duel.Display(client, MENU_TIME_FOREVER);
}
else
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Doar deținuții pot să foloască comanda \x06/lr\x01.");
}
}
}
else if(GetClientTeam(client) == 3)
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Doar deținuții pot să foloască comanda \x06/lr\x01.");
}
else
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Trebuie să fie cel puțin un Gardian în viată pentru a începe un duel.");
}
}
else
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Ești deja în duel.");
}
return Plugin_Handled;
}
public int DuelMenuHandler(Menu menu, MenuAction action, int client, int param)
{
int availabletargets = 0;
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
{
++availabletargets;
}
}
if(IsValidClient(client) && !IsPlayerAlive(client) && GetClientTeam(client) == 2)
{
delete menu;
PrintToChat(client, " \x0F[BOT]JBGO\x01: Trebuie să fii în viată pentru a face duel.");
}
else if(availabletargets > 1)
{
delete menu;
PrintToChat(client, " \x0F[BOT]JBGO\x01: Nu ești ultimul deținut să poți face duel.");
}
else if(action == MenuAction_Select)
{
char select[1024];
GetMenuItem(menu, param, select, sizeof(select));
switch (param)
{
case 0:
{
char target[50];
Menu meniu_cutit = new Menu(CutitMenuHandler);
meniu_cutit.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_cutit.AddItem(target, target);
}
}
meniu_cutit.Display(client, MENU_TIME_FOREVER);
}
case 1:
{
char target[50];
Menu meniu_pumni = new Menu(PumniMenuHandler);
meniu_pumni.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_pumni.AddItem(target, target);
}
}
meniu_pumni.Display(client, MENU_TIME_FOREVER);
}
case 2:
{
DuelPistoale(client);
}
case 3:
{
DuelGrenade(client);
}
}
}
}
public int CutitMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
RemoveAllWeapons(client);
int weapon = GivePlayerItem(client, "weapon_knife_stiletto");
EquipPlayerWeapon(client, weapon);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 100);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
RemoveAllWeapons(target);
int weapon = GivePlayerItem(target, "weapon_knife_stiletto");
EquipPlayerWeapon(target, weapon);
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 100);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
public int PumniMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
DuelPumni = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
RemoveAllWeapons(client);
int weapon = GivePlayerItem(client, "weapon_fists");
EquipPlayerWeapon(client, weapon);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 100);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
RemoveAllWeapons(target);
int weapon = GivePlayerItem(target, "weapon_fists");
EquipPlayerWeapon(target, weapon);
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 100);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
stock bool DuelGrenade(int client)
{
if (IsPlayerAlive(client) && GetClientTeam(client) == 2)
{
Menu meniu_duelgrenade = new Menu(DuelGrenadeMenuHandler);
meniu_duelgrenade.SetTitle("----------------\nDuel Grenade\n----------------");
meniu_duelgrenade.AddItem("", "Duel cu HE");
meniu_duelgrenade.AddItem("", "Duel cu Decoy");
meniu_duelgrenade.ExitBackButton = true;
meniu_duelgrenade.Display(client, MENU_TIME_FOREVER);
return true;
}
return false;
}
public int DuelGrenadeMenuHandler(Menu menu, MenuAction action, int client, int param)
{
if (action == MenuAction_Cancel && param == MenuCancel_ExitBack)
{
FakeClientCommand(client, "sm_lr");
}
else if(action == MenuAction_Select)
{
char select[1024];
GetMenuItem(menu, param, select, sizeof(select));
switch (param)
{
case 0:
{
char target[50];
Menu meniu_he = new Menu(HeMenuHandler);
meniu_he.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_he.AddItem(target, target);
}
}
meniu_he.Display(client, MENU_TIME_FOREVER);
}
case 1:
{
char target[50];
Menu meniu_decoy = new Menu(DecoyMenuHandler);
meniu_decoy.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_decoy.AddItem(target, target);
}
}
meniu_decoy.Display(client, MENU_TIME_FOREVER);
}
}
}
}
public int DecoyMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
DuelDecoy = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
RemoveAllWeapons(client);
GivePlayerItem(client, "weapon_decoy");
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 1);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
RemoveAllWeapons(target);
GivePlayerItem(target, "weapon_decoy");
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 1);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
public int HeMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
DuelHe = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
RemoveAllWeapons(client);
GivePlayerItem(client, "weapon_hegrenade");
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 100);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
RemoveAllWeapons(target);
GivePlayerItem(target, "weapon_hegrenade");
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 100);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
public void OnEntityCreated(int iEntity, const char[] szClassname)
{
if(DuelEnabled)
{
if(DuelHe)
{
if (!StrEqual(szClassname, "hegrenade_projectile"))
return;
SDKHook(iEntity, SDKHook_Spawn, OnEntitySpawned);
}
else if(DuelDecoy)
{
if (!StrEqual(szClassname, "decoy_projectile"))
return;
SDKHook(iEntity, SDKHook_Spawn, OnEntitySpawned);
}
}
}
public int OnEntitySpawned(int iEntity)
{
int iClient = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
if (iClient == -1 || !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
return;
if(DuelHe)
{
CreateTimer(1.4, Timer_GiveHe, GetClientUserId(iClient), TIMER_FLAG_NO_MAPCHANGE);
}
else if(DuelDecoy)
{
CreateTimer(0.0, Timer_RemoveThinkTick, EntIndexToEntRef(iEntity), TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action Timer_RemoveThinkTick(Handle hTimer, int iRef)
{
int iEntity = EntRefToEntIndex(iRef);
if (iEntity == INVALID_ENT_REFERENCE || !IsValidEntity(iEntity))
return;
SetEntProp(iEntity, Prop_Data, "m_nNextThinkTick", -1);
CreateTimer(1.4, Timer_RemoveDecoy, EntIndexToEntRef(iEntity), TIMER_FLAG_NO_MAPCHANGE);
}
public Action Timer_RemoveDecoy(Handle hTimer, int iRef)
{
int iEntity = EntRefToEntIndex(iRef);
if (iEntity == INVALID_ENT_REFERENCE || !IsValidEntity(iEntity))
return;
int iClient = GetEntPropEnt(iEntity, Prop_Data, "m_hOwnerEntity");
AcceptEntityInput(iEntity, "Kill");
if (iClient == -1 || !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
return;
GivePlayerItem(iClient, "weapon_decoy");
}
public Action Timer_GiveHe(Handle hTimer, int iUserid)
{
int iClient = GetClientOfUserId(iUserid);
if (iClient == -1 || !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
return;
GivePlayerItem(iClient, "weapon_hegrenade");
}
stock bool DuelPistoale(int client)
{
if (IsPlayerAlive(client) && GetClientTeam(client) == 2)
{
Menu meniu_duelpistoale = new Menu(DuelPistoaleMenuHandler);
meniu_duelpistoale.SetTitle("----------------\nDuel Pistoale\n----------------");
meniu_duelpistoale.AddItem("", "Duel Deagle");
meniu_duelpistoale.AddItem("", "Duel Revolver");
meniu_duelpistoale.ExitBackButton = true;
meniu_duelpistoale.Display(client, MENU_TIME_FOREVER);
return true;
}
return false;
}
public int DuelPistoaleMenuHandler(Menu menu, MenuAction action, int client, int param)
{
if (action == MenuAction_Cancel && param == MenuCancel_ExitBack)
{
FakeClientCommand(client, "sm_lr");
}
else if(action == MenuAction_Select)
{
char select[1024];
GetMenuItem(menu, param, select, sizeof(select));
switch (param)
{
case 0:
{
char target[50];
Menu meniu_deagle = new Menu(DeagleMenuHandler);
meniu_deagle.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_deagle.AddItem(target, target);
}
}
meniu_deagle.Display(client, MENU_TIME_FOREVER);
}
case 1:
{
char target[50];
Menu meniu_revolver = new Menu(RevolverMenuHandler);
meniu_revolver.SetTitle("----------------\nAlege Oponentul\n----------------");
for (int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i) )
{
GetClientName(i, target, sizeof(target));
meniu_revolver.AddItem(target, target);
}
}
meniu_revolver.Display(client, MENU_TIME_FOREVER);
}
}
}
}
public int DeagleMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
DuelDeagle = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
char weaponclassname[MAX_WEAPON_STRING];
RemoveAllWeapons(client);
int iWeapon = GivePlayerItem(client, "weapon_deagle");
SetEntProp(iWeapon, Prop_Send, "m_iClip1", 1);
Client_GetActiveWeaponName(client, weaponclassname, MAX_WEAPON_STRING);
SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
Client_SetWeaponPlayerAmmo(client, weaponclassname, 0);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 100);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
char weaponclassname[MAX_WEAPON_STRING];
RemoveAllWeapons(target);
int iWeapon = GivePlayerItem(target, "weapon_deagle");
SetEntProp(iWeapon, Prop_Send, "m_iClip1", 1);
Client_GetActiveWeaponName(target, weaponclassname, MAX_WEAPON_STRING);
SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
Client_SetWeaponPlayerAmmo(target, weaponclassname, 0);
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 100);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
public int RevolverMenuHandler(Menu menu, MenuAction action, int client, int param2)
{
if(action == MenuAction_Select)
{
DuelEnabled = true;
DuelRevolver = true;
char arg1[50];
GetMenuItem(menu, param2, arg1, sizeof(arg1));
int target = FindTarget(client, arg1, true, false);
if (target != -1)
{
for(int x = 1; x <= MaxClients; x++)
{
if(IsClientInGame(x))
{
ClientCommand( x, "play \"music/lrnew.mp3\"" );
}
}
if(GetClientTeam(client) == 2)
{
char weaponclassname[MAX_WEAPON_STRING];
RemoveAllWeapons(client);
int iWeapon = GivePlayerItem(client, "weapon_revolver");
SetEntProp(iWeapon, Prop_Send, "m_iClip1", 1);
Client_GetActiveWeaponName(client, weaponclassname, MAX_WEAPON_STRING);
SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
Client_SetWeaponPlayerAmmo(client, weaponclassname, 0);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, 255, 0, 0, 255);
SetEntityHealth(client, 100);
SetEntProp(client, Prop_Send, "m_ArmorValue", 0);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelPrisonier[client] = true;
}
if(GetClientTeam(target) == 3)
{
char weaponclassname[MAX_WEAPON_STRING];
RemoveAllWeapons(target);
int iWeapon = GivePlayerItem(target, "weapon_revolver");
SetEntProp(iWeapon, Prop_Send, "m_iClip1", 1);
Client_GetActiveWeaponName(target, weaponclassname, MAX_WEAPON_STRING);
SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
Client_SetWeaponPlayerAmmo(target, weaponclassname, 0);
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 0, 0, 255, 255);
SetEntityHealth(target, 100);
SetEntProp(target, Prop_Send, "m_ArmorValue", 0);
SetEntProp(target, Prop_Send, "m_bHasHelmet", 0);
PlayerDuelGuard[target] = true;
}
}
}
}
public void RemoveAllWeapons(int client)
{
if(IsValidClient(client))
{
int weapon;
for(int i = 0; i < 5; i++)
{
while((weapon = GetPlayerWeaponSlot(client, i)) != -1)
{
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
}
}
}
}
public Action ClientWeaponReload(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
Darm(client);
}
public void Darm(int client)
{
if(IsPlayerAlive(client) && DuelEnabled)
{
int weapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
if(weapon > 0 && (weapon == GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY) || weapon == GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY)))
{
int warray;
char classname[4];
//GetEdictClassname(weapon, classname, sizeof(classname));
Format(classname, 4, "%i", GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"));
if(GetTrieValue(trie_armas, classname, warray))
{
if(GetReserveAmmo(weapon) != warray) SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 1);
}
}
}
}
public Action CS_OnCSWeaponDrop(int client, int weapon)
{
char weapon_name[30];
GetEntityClassname(weapon, weapon_name, sizeof(weapon_name));
if(DuelEnabled)
{
PrintToChat(client, " \x0F[BOT]JBGO\x01: Nu poți arunca armele în timpul unui duel.");
return Plugin_Handled;
}
return Plugin_Continue;
}
stock int GetReserveAmmo(int weapon)
{
return GetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount");
}
public Action EventItemPickup2(int client, int weapon)
{
if(weapon == GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY) || weapon == GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY) && DuelEnabled)
{
int warray;
char classname[4];
//GetEdictClassname(weapon, classname, sizeof(classname));
Format(classname, 4, "%i", GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"));
if(!GetTrieValue(trie_armas, classname, warray))
{
warray = GetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount");
SetTrieValue(trie_armas, classname, warray);
}
}
}
public void OnClientPutInServer(int client)
{
if(!IsValidClient(client))
{
return;
}
SDKHook(client, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
SDKHook(client, SDKHook_WeaponCanUse, Hook_WeaponCanUse);
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
SDKHook(client, SDKHook_WeaponEquipPost, EventItemPickup2);
}
public Action Hook_OnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if(!DuelEnabled)
{
if(IsValidClient(attacker) && GetClientTeam(attacker) == 2 && GetClientTeam(client) == 3 && attacker != client)
{
if(attack_timer == INVALID_HANDLE)
{
//for(int x = 1; x <= MaxClients; x++)
//{
//if(IsValidClient(x))
//{
//ClientCommand( x, "play \"*xsag/jbgo/revolt_xsag.mp3\"" );
//}
//}
SetEntityRenderColor(attacker, 255, 0, 0, 255);
PrintCenterTextAll("%N a devenit agresiv", attacker);
attack_timer = CreateTimer(10.0, AttackTimerEnd);
}
}
}
else if(DuelEnabled)
{
if(IsValidClient(attacker) && GetClientTeam(attacker) == 3 && GetClientTeam(client) == 2 && !PlayerDuelGuard[attacker] && !PlayerDuelPrisonier[client] && attacker != client)
{
damage = 0.0;
return Plugin_Changed;
}
else if(IsValidClient(attacker) && GetClientTeam(attacker) == 2 && GetClientTeam(client) == 3 && !PlayerDuelGuard[client] && !PlayerDuelPrisonier[attacker] && attacker != client)
{
damage = 0.0;
return Plugin_Changed;
}
}
return Plugin_Continue;
}
public void OnClientDisconnect(int client)
{
SDKUnhook(client, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
}
public Action Hook_WeaponCanUse(int client, int weapon)
{
char classname[64];
GetEntityClassname(weapon, classname, sizeof classname);
if(DuelDeagle)
{
for(int i = 0; i < 44; i++)
{
if(StrEqual(classname, DuelDeagleBlock[i]))
{
return Plugin_Handled;
}
}
}
if(DuelRevolver)
{
for(int i = 0; i < 43; i++)
{
if(StrEqual(classname, DuelRevolverBlock[i]))
{
return Plugin_Handled;
}
}
}
if(DuelHe)
{
for(int i = 0; i < 44; i++)
{
if(StrEqual(classname, DuelHeBlock[i]))
{
return Plugin_Handled;
}
}
}
if(DuelDecoy)
{
for(int i = 0; i <44; i++)
{
if(StrEqual(classname, DuelDecoyBlock[i]))
{
return Plugin_Handled;
}
}
}
if(DuelPumni)
{
for(int i = 0; i < 45; i++)
{
if(StrEqual(classname, DuelPumniBlock[i]))
{
return Plugin_Handled;
}
}
}
if(StrEqual(classname, "weapon_melee") && !(HasWeapon(client, "weapon_melee") || HasWeapon(client, "weapon_knife")))
{
EquipPlayerWeapon(client, weapon);
}
return Plugin_Continue;
}
public void OnPostThinkPost(int client)
{
SetEntProp(client, Prop_Send, "m_iAddonBits", 0);
}
public Action AttackTimerEnd(Handle timer)
{
ClearTimer(attack_timer);
}
stock bool HasWeapon(int client, const char[] classname)
{
int index;
int weapon;
char sName[64];
while((weapon = GetNextWeapon(client, index)) != -1)
{
GetEdictClassname(weapon, sName, sizeof(sName));
if (StrEqual(sName, classname))
{
return true;
}
}
return false;
}
stock int GetNextWeapon(int client, int &weaponIndex)
{
static int weaponsOffset = -1;
if (weaponsOffset == -1)
{
weaponsOffset = FindDataMapInfo(client, "m_hMyWeapons");
}
int offset = weaponsOffset + (weaponIndex * 4);
int weapon;
while (weaponIndex < 48)
{
weaponIndex++;
weapon = GetEntDataEnt2(client, offset);
if (IsValidEdict(weapon))
{
return weapon;
}
offset += 4;
}
return -1;
}
I have this plugin and it causes me to crash quite often, would you have any idea why?