Raised This Month: $32 Target: $400
 8% 

EDIT Abner Duel HELP ME ;(


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sHoC
Senior Member
Join Date: Nov 2015
Location: Italy
Old 12-10-2015 , 13:03   EDIT Abner Duel HELP ME ;(
Reply With Quote #1

I want m8 Revolver DUEL and also I want it to be Shot4shot, to give 1 bullet for everyone and then, when they shoot it, they can reload and get again 1 bulet.

Code:
/*
	AbNeR Duel v3.0
	-Fixed server crashs
	-Weapons returned correctly when duel ends.
	-Added duel_iammo - 1/0  Enable/Disable Infinity Ammo in Duel
	-Added duel_ignore_bots - 1/0 1 - Dont't start the duel with alive bots, 2 - Start duel with alive bots
*/

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <colors>
#include <clientprefs>
#include <cstrike>
#pragma semicolon 1

#define MAX_EDICTS		2048
#define MAX_SOUNDS		1024

#pragma newdecls required // 2015 rules 

int g_iSoundEnts[MAX_EDICTS];
int g_iNumSounds;

#define ABNER_ADMINFLAG ADMFLAG_SLAY
#define PLUGIN_VERSION "3.0"

int g_S = 0, g_N = 0;
int  trid = 0;
int  ctid = 0;
float teleloc[3];
int  seconds = 0;

Handle g_VoteMenu = INVALID_HANDLE;
Handle g_hSemMira;
Handle g_hSound;
Handle g_hSemMiraArma;
Handle g_hSemMiraPath;
Handle g_NoscopeCookie;
Handle g_hPlayType;
Handle g_hStop;
Handle g_hTP;
Handle g_hRefuseSound;
Handle g_hFightTime;
Handle g_hIammo;
Handle g_hTimeDuel = INVALID_HANDLE;
Handle g_IgnoreBots;

bool SemMiraEnabled;
bool VoteProgress = false;
bool DueloSemMira;
bool SoundsSucess;
bool CSGO = false;
char ArmaName[32];

int  g_Sounds = 0;
char sound[MAX_SOUNDS][PLATFORM_MAX_PATH];
char ct_weapon[32][64];
char tr_weapon[32][64];

int  ctcount = 0;
int  trcount = 0;
int ct_weapon_index[MAXPLAYERS+1];
int tr_weapon_index[MAXPLAYERS+1];

char sCookieValue[11];
bool g_bClientPreference[MAXPLAYERS+1];
int  m_flNextSecondaryAttack;




public Plugin myinfo =
{
	name = "ABNER DUEL",
	author = "AbNeR",
	description = "duel 1 vs 1",
	version = PLUGIN_VERSION,
	url = "www.bluegames.ro/forum"
}

char csgoWeapons[][] = {
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_c4", "weapon_cz75a", "weapon_deagle",
"weapon_decoy", "weapon_elite", "weapon_famas", "weapon_fiveseven", "weapon_flashbang", "weapon_g3sg1", "weapon_galil", "weapon_galilar",
"weapon_glock", "weapon_hegrenade", "weapon_incgrenade", "weapon_hkp2000", "weapon_knife", "weapon_m249", "weapon_m3",
"weapon_m4a1", "weapon_m4a1_silencer", "weapon_mac10", "weapon_mag7", "weapon_molotov", "weapon_mp5navy", "weapon_mp7",
"weapon_mp9", "weapon_negev", "weapon_nova", "weapon_p228", "weapon_p250", "weapon_p90", "weapon_sawedoff", "weapon_scar17",
"weapon_scar20", "weapon_sg550", "weapon_sg552", "weapon_sg556", "weapon_ssg08", "weapon_smokegrenade",
"weapon_taser", "weapon_tec9", "weapon_tmp", "weapon_ump45", "weapon_usp", "weapon_usp_silencer", "weapon_xm1014", 
"item_assaultsuit", "item_defuser", "item_kevlar"
};

char noScopeWeapons[][] = {
	"weapon_scout", "weapon_ssg08", "weapon_aug", "weapon_sg550", "weapon_sg552", "weapon_sg556",  "weapon_awp",
	"weapon_scar20", "weapon_g3sg1"
};

bool isNoScopeWeapon(char[] weapon)
{
	bool found = false;
	for(int i = 0;i < sizeof(noScopeWeapons);i++)
	{
		if(StrEqual(weapon, noScopeWeapons[i]))
		{
			found = true;
			break;
		}
	}
	return found;
}

public void OnPluginStart()
{  

	CreateConVar("abner_duel_version", PLUGIN_VERSION, "Plugin Version", FCVAR_NOTIFY|FCVAR_REPLICATED);
	g_hSemMira = CreateConVar("duel_1x1", "1", "0 - Disabled, 1 - Vote, 2 - Force duel ");
	g_hSound = CreateConVar("duel_music", "1", "Enable/Disable 1x1 Music");
	g_hSemMiraArma = CreateConVar("duel_weapon", "weapon_ssg08", "Weapon used in 1x1");
	g_hSemMiraPath = CreateConVar("duel_music_path", "misc/hgduel", "Sounds Path");
	g_hPlayType = CreateConVar("duel_music_play_type", "1", "1 - Random, 2- Play in queue");
	g_hStop = CreateConVar("duel_stop_map_music", "0", "Stop map musics ");
	g_hTP = CreateConVar("duel_teleport", "1", "Teleport players in 1x1.");
	g_hRefuseSound = CreateConVar("duel_refuse_sound", "misc/DoITjustDoIT.mp3", "Refuse sound path.");
	g_hFightTime = CreateConVar("duel_fight_time", "20", "Max duel time in seconds.");
	g_hIammo = CreateConVar("duel_iammo", "1", "Infinity Ammo in Duel");
	g_IgnoreBots = CreateConVar("duel_ignore_bots", "1", "Dont't start the duel with alive bots");
	m_flNextSecondaryAttack = FindSendPropOffs("CBaseCombatWeapon", "m_flNextSecondaryAttack");
	
	//ClientPrefs
	g_NoscopeCookie = RegClientCookie("AbNeR Duel Settings", "", CookieAccess_Private);
	int  info;
	SetCookieMenuItem(NoScopeCookieHandler, info, "AbNeR Duel");
	
	AutoExecConfig(true, "abner_duel");
	
	LoadTranslations("common.phrases");
	LoadTranslations("abner_duel.phrases");
		
	RegAdminCmd("sm_noscope", CommandSemMira, ABNER_ADMINFLAG);
	RegAdminCmd("duel_load", CommandLoad, ABNER_ADMINFLAG);
	RegConsoleCmd("abnerduel", abnermenu);
	
	GetConVarString(g_hSemMiraArma, ArmaName, sizeof(ArmaName));
	HookConVarChange(g_hSemMiraPath, PathChange);
	HookConVarChange(g_hSemMiraArma, ArmaChange);
	HookEvent("player_death", PlayerDeath); 
	HookEvent("round_start", Event_RoundStart);
	HookEvent("round_end", AtivarMira);

	SemMiraEnabled = false;
	DueloSemMira = false;
	
	char theFolder[40];
	GetGameFolderName(theFolder, sizeof(theFolder));
	CSGO = StrEqual(theFolder, "csgo");
	
	for (int  i = MaxClients; i > 0; --i)
	{
		if (!AreClientCookiesCached(i) || !IsValidClient(i))
		{
			continue;
		}
		SDKHook(i, SDKHook_WeaponEquipPost, OnWeaponEquipPost);
		SDKHook(i, SDKHook_PreThink, PreThink);
		OnClientCookiesCached(i);
	}
	char soundpath[PLATFORM_MAX_PATH];
	GetConVarString(g_hRefuseSound, soundpath, sizeof(soundpath));
	if(!StrEqual(soundpath, ""))
	{
		char download[PLATFORM_MAX_PATH];
		Format(download, sizeof(download), "sound/%s", soundpath);
		AddFileToDownloadsTable(download);
	}
}

public void OnClientPutInServer(int client)
{
	CreateTimer(3.0, msg, client);
	SDKHook(client, SDKHook_WeaponEquipPost, OnWeaponEquipPost);
	SDKHook(client, SDKHook_PreThink, PreThink);
}

public Action msg(Handle timer, any client)
{
	if(IsValidClient(client))
	{
		CPrintToChat(client, "\x04[AbNeR Duel]\x01 %t", "command");
	}
}

stock bool IsValidClient(int client)
{
	if(client <= 0 ) return false;
	if(client > MaxClients) return false;
	if(!IsClientConnected(client)) return false;
	return IsClientInGame(client);
}

public void OnWeaponEquipPost(int client, int weapon)
{
	if(IsValidEdict(weapon))
	{
		char item[64];
		GetEdictClassname(weapon, item, sizeof(item)); 
		if(DueloSemMira)
		{
			if (!StrEqual(item, ArmaName) && !StrEqual(item, "weapon_knife"))
			{
				RemovePlayerItem(client, weapon);
				CreateTimer(0.1, deleteWeapon, weapon);
			}
		}
	}
}


public Action PreThink(int client)
{
	if(IsValidClient(client) && IsPlayerAlive(client))
	{
		int  weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
		if(IsValidEdict(weapon) && IsValidEntity(weapon))
		{
			char item[64];
			GetEdictClassname(weapon, item, sizeof(item)); 
			if(DueloSemMira && !StrEqual(item, "weapon_knife") && GetConVarInt(g_hIammo) == 1)
			{
				int clip1Offset = FindSendPropOffs("CBaseCombatWeapon", "m_iClip1");
				SetEntData(weapon, clip1Offset, 200, 4, true);
			}
			if(SemMiraEnabled)
			{
				if (isNoScopeWeapon(item))
				{
					SetEntDataFloat(weapon, m_flNextSecondaryAttack, GetGameTime() + 9999.9);
				}
			}
		}
	}
	return Plugin_Continue;
}

public void NoScopeCookieHandler(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
{
	OnClientCookiesCached(client);
	abnermenu(client, 0);
} 

public void OnClientCookiesCached(int client)
{
    char sValue[8];
    GetClientCookie(client, g_NoscopeCookie, sValue, sizeof(sValue));
    
    g_bClientPreference[client] = (sValue[0] != '\0' && StringToInt(sValue));
} 

public Action abnermenu(int client, int args)
{
	char text[60];
	GetClientCookie(client, g_NoscopeCookie, sCookieValue, sizeof(sCookieValue));
	int  cookievalue = StringToInt(sCookieValue);
	Handle g_AbNeRMenu = CreateMenu(AbNeRMenuHandler);
	SetMenuTitle(g_AbNeRMenu, "AbNeR Duel Settings");
	if(cookievalue == 0)
	{
		Format(text,sizeof(text),"%t", "Always Accept");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t", "Always Refuse");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t (Enabled)", "None");
		AddMenuItem(g_AbNeRMenu, text, text);
	}
	if(cookievalue == 1)
	{
		Format(text,sizeof(text),"%t (Enabled)", "Always Accept");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t", "Always Refuse");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t", "None");
		AddMenuItem(g_AbNeRMenu, text, text);
	}
	if(cookievalue == 2)
	{
		Format(text,sizeof(text),"%t", "Always Accept");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t (Enabled)", "Always Refuse");
		AddMenuItem(g_AbNeRMenu, text, text);
		Format(text,sizeof(text),"%t", "None");
		AddMenuItem(g_AbNeRMenu, text, text);
	}
	SetMenuExitBackButton(g_AbNeRMenu, true);
	SetMenuExitButton(g_AbNeRMenu, true);
	DisplayMenu(g_AbNeRMenu, client, 30);
}

public int AbNeRMenuHandler(Handle menu, MenuAction action, int param1, int param2)
{
	Handle g_AbNeRMenu = CreateMenu(AbNeRMenuHandler);
	if (action == MenuAction_DrawItem)
	{
		return ITEMDRAW_DEFAULT;
	}
	else if(param2 == MenuCancel_ExitBack)
	{
		ShowCookieMenu(param1);
	}
	else if (action == MenuAction_Select)
	{
		switch (param2)
		{
			case 0:
			{
				SetClientCookie(param1, g_NoscopeCookie, "1");
				abnermenu(param1, 0);
			}
			case 1:
			{
				SetClientCookie(param1, g_NoscopeCookie, "2");
				abnermenu(param1, 0);
			}
			case 2:
			{
				SetClientCookie(param1, g_NoscopeCookie, "0");
				abnermenu(param1, 0);
			}
		}
		CloseHandle(g_AbNeRMenu);
	}
	return 0;
}


public void OnMapStart()
{
	LoadSounds(0);
}


public Action deleteWeapon(Handle timer, any weapon)
{
	if (weapon && IsValidEdict(weapon) && IsValidEntity(weapon))
		RemoveEdict(weapon);
}  

public void ArmaChange(Handle cvar, const char[] oldVa, const char[] newVal)
{       
	GetConVarString(g_hSemMiraArma, ArmaName, sizeof(ArmaName));
}

public void PathChange(Handle cvar, const char[] oldVa, const char[] newVal)
{       
	LoadSounds(0);
}

public void LoadSounds(int client)
{
	int  namelen;
	FileType type;
	char name[64];
	char soundname[64];
	char soundname2[64];
	char soundpath[32];
	char soundpath2[32];
	GetConVarString(g_hSemMiraPath, soundpath, sizeof(soundpath));
	Format(soundpath2, sizeof(soundpath2), "sound/%s/", soundpath);
	Handle pluginsdir = OpenDirectory(soundpath2);
	g_Sounds = 0;
	if(pluginsdir != INVALID_HANDLE)
	{
		while(ReadDirEntry(pluginsdir,name,sizeof(name),type))
		{
			namelen = strlen(name) - 4;
			if(StrContains(name,".mp3",false) == namelen)
			{
				Format(soundname, sizeof(soundname), "sound/%s/%s", soundpath, name);
				AddFileToDownloadsTable(soundname);
				Format(soundname2, sizeof(soundname2), "%s/%s", soundpath, name);
				sound[g_Sounds++] = soundname2;
				if(IsValidClient(client)) CPrintToChat(client, "{green}[AbNeR Duel] \x01%t", "Loaded", soundname2);
				PrintToServer("[AbNeR Duel] \x01%t", "Loaded", soundname2);
			}
		}
		SoundsSucess = g_Sounds > 0;
	}
	else
	{
		SoundsSucess = false;
		if(IsValidClient(client)) CPrintToChat(client, "\x04[AbNeR Duel] \x01%t", "Invalid", soundname2);
	}
}

public void DeleteSound(int rnd_sound)
{
	for (int i = 0; i < g_Sounds; i++)
	{
		if(i >= rnd_sound)
			sound[i] = sound[i+1];
	}
	if(--g_Sounds == 0)
		LoadSounds(0);
}

public void PlaySoundCSGO()
{
	int soundToPlay;
	if(GetConVarInt(g_hPlayType) == 1)
	{
		soundToPlay = GetRandomInt(0, g_Sounds-1);
	}
	else
	{
		soundToPlay = 0;
	}
	for (int i = 1; i <= MaxClients; i++)
	{
		GetClientCookie(i, g_NoscopeCookie, sCookieValue, sizeof(sCookieValue));
		int cookievalue = StringToInt(sCookieValue);
		if(IsValidClient(i) && cookievalue == 0)
		{
			ClientCommand(i, "playgamesound Music.StopAllMusic");
			ClientCommand(i, "play *%s", sound[soundToPlay]);
		}
	}
	DeleteSound(soundToPlay);
}

public void PlaySound()
{
	int soundToPlay;
	if(GetConVarInt(g_hPlayType) == 1)
	{
		soundToPlay = GetRandomInt(0, g_Sounds-1);
	}
	else
	{
		soundToPlay = 0;
	}
	for (int i = 1; i <= MaxClients; i++)
	{
		GetClientCookie(i, g_NoscopeCookie, sCookieValue, sizeof(sCookieValue));
		int cookievalue = StringToInt(sCookieValue);
		if(IsValidClient(i) && cookievalue == 0)
		{
			ClientCommand(i, "play %s", sound[soundToPlay]);
		}
	}
	DeleteSound(soundToPlay);
}

public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
{
	VoteProgress = false;
	SemMiraEnabled = false;
	DueloSemMira = false;
	g_N = 0, g_S = 0;
	if(g_VoteMenu != INVALID_HANDLE)
	{
		CloseHandle(g_VoteMenu);
		g_VoteMenu = INVALID_HANDLE;
	}
	if(GetConVarInt(g_hStop) == 1)
	{
		// Ents are recreated every round.
		g_iNumSounds = 0;

		// Find all ambient sounds played by the map.
		char sSound[PLATFORM_MAX_PATH];
		int  entity = INVALID_ENT_REFERENCE;

		while ((entity = FindEntityByClassname(entity, "ambient_generic")) != INVALID_ENT_REFERENCE)
		{
			GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
			
			int  len = strlen(sSound);
			if (len > 4 && (StrEqual(sSound[len-3], "mp3") || StrEqual(sSound[len-3], "wav")))
			{
				g_iSoundEnts[g_iNumSounds++] = EntIndexToEntRef(entity);
			}
		}
	}
}

stock void Client_StopSound(int client, int entity, int channel, const char[] name)
{
	EmitSoundToClient(client, name, entity, channel, SNDLEVEL_NONE, SND_STOP, 0.0, SNDPITCH_NORMAL, _, _, _, true);
}


public void StopMapMusic()
{
	char sSound[PLATFORM_MAX_PATH];
	int  entity = INVALID_ENT_REFERENCE;
	for(int  i=1;i<=MaxClients;i++){
		if(!IsClientInGame(i)){ continue; }
		for (int  u=0; u<g_iNumSounds; u++){
			entity = EntRefToEntIndex(g_iSoundEnts[u]);
			if (entity != INVALID_ENT_REFERENCE){
				GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
				Client_StopSound(i, entity, SNDCHAN_STATIC, sSound);
			}
		}
	}
}

public int VoteMenuHandler(Handle menu, MenuAction action, int param1, int param2)
{
	if (action == MenuAction_DrawItem)
	{
		return ITEMDRAW_DEFAULT;
	}
	else if (action == MenuAction_Select)
	{
		if(VoteProgress)
		{
			switch (param2)
			{
				case 0:
				{
					sim(param1);
				}
				case 1:
				{
					nao(param1);
				}
			}
		}
	}
	return 0;
}

public void Command_VoteMenu(int client)
{
		VoteProgress = true;
		GetClientCookie(client, g_NoscopeCookie, sCookieValue, sizeof(sCookieValue));
		int  cookievalue = StringToInt(sCookieValue);
		g_VoteMenu = CreateMenu(VoteMenuHandler);
		char text[128];
		Format(text,sizeof(text),"%t", "Duel Ask");
		SetMenuTitle(g_VoteMenu, text);
		AddMenuItem(g_VoteMenu, "Yes", "Yes");
		AddMenuItem(g_VoteMenu, "No", "No");
		if (!IsFakeClient(client))
		{
			if(cookievalue == 1)
			{
				sim(client);
			}
			if(cookievalue == 2)
			{
				nao(client);
			}
			if(cookievalue == 0)
			{
				DisplayMenu(g_VoteMenu, client, 10);
			}
		}
		else
		{
			sim(client);
		}
}

public void sim(int client)
{
	char nome[MAX_TARGET_LENGTH];
	GetClientName(client, nome, sizeof(nome));
	g_S++;
	
	if(GetClientTeam(client) == 2)
	{
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Accepted Red", nome);
	}
	
	if(GetClientTeam(client) == 3)
	{
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Accepted Blue", nome);
	}
	check_votes();
}

public void nao(int client)
{
	char nome[MAX_TARGET_LENGTH];
	GetClientName(client, nome, sizeof(nome));
	g_N++;
	if(GetClientTeam(client) == 2)
	{
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Refused Red", nome);
	}
	if(GetClientTeam(client) == 3)
	{
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Refused Blue", nome);
	}
	char soundpath[32];
	GetConVarString(g_hRefuseSound, soundpath, sizeof(soundpath));
	if(!StrEqual(soundpath, ""))
	{
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i))
			{
				ClientCommand(i, "play %s", soundpath);
			}
		}
	}
	check_votes();
}

public void check_votes()
{
	if (g_S == 2)
	{
		duelosemmira();
	}
	if (g_N >= 1)
	{
		g_N = 0, g_S = 0;
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Canceled");
	}
	
}

public Action CommandLoad(int client, int args)
{   
	LoadSounds(0);
	return Plugin_Handled;
}

public Action CommandSemMira(int client, int args)
{   
	if(SemMiraEnabled)
	{
		SemMiraEnabled = false;
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Scope On");
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i) && IsPlayerAlive(i))
			{
				for (int  j = 0; j <5; j++)
				{
					int  weapon = GetPlayerWeaponSlot(i, j);
					if(weapon == -1)
					{
						continue;
					}
					char item[128];
					GetEdictClassname(weapon, item, sizeof(item)); 
					if (StrEqual(item[7], "ssg08")  || StrEqual(item[7], "aug") || StrEqual(item[7], "sg550") || StrEqual(item[7], "sg552") || StrEqual(item[7], "sg556")  || StrEqual(item[7], "awp") || StrEqual(item[7], "scar20") || StrEqual(item[7], "g3sg1"))
					{
						SetEntDataFloat(weapon, m_flNextSecondaryAttack, 0.0);
					}
				}
			}
		}
		return Plugin_Handled;
	}
	else if(!SemMiraEnabled)
	{
		SemMiraEnabled = true;
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Scope Off");
		return Plugin_Handled;
	}
	return Plugin_Handled;
}

public Action PlayerDeath(Handle event, const char[] name, bool dontBroadcast) 
{ 
	if(CSGO && GameRules_GetProp("m_bWarmupPeriod") == 1)
	{
		return Plugin_Continue;
	}
	if(trs_vivos() == 1 && cts_vivos() == 1)
	{
		if(GetConVarInt(g_hSemMira) == 1)
		{
			for (int  i = 1; i <= MaxClients; i++)
			{
				if(IsValidClient(i) && IsPlayerAlive(i))
				{
					Command_VoteMenu(i);
				}
			}
		}
		else if(GetConVarInt(g_hSemMira) == 2)
		{
			duelosemmira();
		}
	}
	return Plugin_Continue;
}

public Action AtivarMira(Handle event, const char[] name, bool dontBroadcast) 
{ 
	if(DueloSemMira)
	{
		delweapons2();
		if(IsValidClient(ctid) && IsPlayerAlive(ctid))
		{
			CreateTimer(1.0, GiveCt);
		}
		else if(IsValidClient(trid) && IsPlayerAlive(trid))
		{
			CreateTimer(1.0, GiveTr);
		}
	}
	
	VoteProgress = false;
	SemMiraEnabled = false;
	DueloSemMira = false;
	g_N = 0, g_S = 0;
	if(g_VoteMenu != INVALID_HANDLE)
	{
		CloseHandle(g_VoteMenu);
		g_VoteMenu = INVALID_HANDLE;
	}
	if(g_hTimeDuel != INVALID_HANDLE)
	{
		KillTimer(g_hTimeDuel);
		g_hTimeDuel = INVALID_HANDLE;
	}
}


public Action GiveCt(Handle timer)
{
	if(IsValidClient(ctid) && IsPlayerAlive(ctid))
	{
		for (int  i = 0; i < ctcount; i++)
		{
			if(!StrEqual(ct_weapon[i], ""))
			{
				int weapon = GiveItem(ctid, ct_weapon[i], ct_weapon_index[i]); 
				CS_DropWeapon(ctid, weapon, false); //Prevent Animation Bugs when change weapon index
				EquipPlayerWeapon(ctid, weapon);
			}
		}
	}
}

public Action GiveTr(Handle timer)
{
	if(IsValidClient(trid) && IsPlayerAlive(trid))
	{
		for (int  i = 0; i < trcount; i++)
		{
			if(!StrEqual(tr_weapon[i], ""))
			{
				int weapon = GiveItem(trid, tr_weapon[i], tr_weapon_index[i]);
				CS_DropWeapon(trid, weapon, false); //Prevent Animation Bugs when change weapon index
				EquipPlayerWeapon(trid, weapon);
			}
		}
	}
}

public void delweapons()
{
	ctcount = 0;
	trcount = 0;
	for(int  i=0;i<2048;++i)
	{
		if(IsValidEdict(i))
		{
			char strName[64];
			GetEntityClassname(i, strName, sizeof(strName));
			if(StrContains(strName, "weapon_", false) == -1 && StrContains(strName, "item_", false) == -1)
				continue;

			int index = 0;
			if(CSGO && StrContains(strName, "weapon_", false) != -1)
				index = GetEntProp(i, Prop_Send, "m_iItemDefinitionIndex");
				
			if(GetEntPropEnt(i, Prop_Send, "m_hOwnerEntity") == ctid && IsValidClient(ctid) && IsPlayerAlive(ctid))
			{
				ct_weapon_index[ctcount] = index;
				ct_weapon[ctcount++] = strName;
				RemovePlayerItem(ctid, i);
			}
			else if(GetEntPropEnt(i, Prop_Send, "m_hOwnerEntity") == trid && IsValidClient(trid) && IsPlayerAlive(trid))
			{
				tr_weapon_index[trcount] = index;
				tr_weapon[trcount++] = strName;
				RemovePlayerItem(trid, i);
			}
			AcceptEntityInput(i, "kill");
		}
	}
}

public void delweapons2()
{
	for(int  i=0;i<2048;++i)
	{
		if(IsValidEdict(i))
		{
			char strName[64];
			GetEntityClassname(i, strName, sizeof(strName));
			
			if(StrContains(strName, "weapon_", false) == -1 && StrContains(strName, "item_", false) == -1)
				continue;

			AcceptEntityInput(i, "kill");
		}
	}
}


public void duelosemmira()
{
	SemMiraEnabled = true;
	if(GetConVarInt(g_hSound) == 1)
	{	
		if(GetConVarInt(g_hStop) == 1) StopMapMusic();
		if(SoundsSucess)
			CSGO ? PlaySoundCSGO() : PlaySound();  //PRETTY COOL IF-ELSE METHOD
		else
			PrintToServer("[AbNeR Duel] %t", "Sound Error");
	}
	
	g_N = 0, g_S = 0;
	for (int  i = 1; i <= MaxClients; i++)
	{
		if(IsValidClient(i) && IsPlayerAlive(i))
		{
			if(GetClientTeam(i) == 2)
			{
				trid = i;
				SetEntProp(i, Prop_Data, "m_takedamage", 0, 1);
			}
			else if(GetClientTeam(i) == 3)
			{
				ctid = i;
				SetEntProp(i, Prop_Data, "m_takedamage", 0, 1);
			}
		}
	}
		
	if(GetConVarInt(g_hTP) == 1)
	{
		CreateTimer(0.1, TeleportPlayers);
	}

	delweapons();
	CreateTimer(3.0, GiveWeapon);
	ServerCommand("sm_beacon @all");
	DueloSemMira = true;
	VoteProgress = false;
}


int GiveItem(int client, char[] weapon, int index=0)
{
	bool found = false;
	for(int i = 0;i < sizeof(csgoWeapons);i++)
	{
		if(StrEqual(weapon, csgoWeapons[i]))
		{
			found = true;
			break;
		}
	}
	if(!found && CSGO)
		return -1;
	
	int entity = GivePlayerItem(client, weapon);
	if(CSGO && index > 0)
	{
		SetEntProp(entity, Prop_Send, "m_iItemDefinitionIndex", index);
	}
	
	return entity;
}


public Action cmsg(Handle timer, any client)
{
	if(seconds > 0 && g_hTimeDuel != INVALID_HANDLE)
	{
		PrintCenterTextAll("%d %t", seconds, "Fight Time");
		seconds--;
	}
	else if(g_hTimeDuel != INVALID_HANDLE)
	{
		KillTimer(g_hTimeDuel);
		g_hTimeDuel = INVALID_HANDLE;
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i) && IsPlayerAlive(i))
			{
				ForcePlayerSuicide(i);
			}
		}
		CPrintToChatAll("\x04[AbNeR Duel] \x01%t", "Duel Canceled");
	}
}

public Action TeleportPlayers(Handle timer, any client)
{
	if(DueloSemMira)
	{
		float ctvec[3];
		float tvec[3];
		float distance[1];
		GetClientAbsOrigin(ctid, ctvec);
		GetClientAbsOrigin(trid, tvec);
		distance[0] = GetVectorDistance(ctvec, tvec, true);
		if (distance[0] >= 600000.0)
		{
			teleloc = ctvec;
			CreateTimer(1.0, DoTp);
		}
	}
}

public Action DoTp(Handle timer)
{
	if(DueloSemMira && IsValidClient(trid))
	{
		TeleportEntity(trid, teleloc, NULL_VECTOR, NULL_VECTOR);
	}
}

public Action GiveWeapon(Handle timer)
{
	if(DueloSemMira)
	{
		GiveDuelWeapon(trid, ArmaName);
		GiveDuelWeapon(ctid, ArmaName);
		
		char fighttime[32];
		GetConVarString(g_hFightTime, fighttime, sizeof(fighttime));
		if(!StrEqual(fighttime, ""))
		{
			seconds = StringToInt(fighttime);
			g_hTimeDuel = CreateTimer(1.0, cmsg, _, TIMER_REPEAT);  
		}
	}
}

public void GiveDuelWeapon(int client, char[] weapon)
{
	if(!IsValidClient(client))
		return;
		
	GiveItem(client, "weapon_knife");
	if(!StrEqual(weapon, "weapon_knife") && !StrEqual(weapon, ""))
	{
		int ent = GiveItem(client, weapon);
		if(ent == -1)
		{	
				CPrintToChatAll("\x04[AbNeR Duel] \x01Invalid Weapon  \x04\"%s\"", weapon);
		}
	}
	
	SetEntProp(client, Prop_Send, "m_iHealth", 100, 1);
	SetEntData(client, FindSendPropOffs("CBaseEntity", "m_CollisionGroup"), 2, 4, true);
	SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
}

public int trs_vivos()
{
	if(GetConVarInt(g_IgnoreBots) == 0)
	{
		int g_TRs = 0;
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
			{
				g_TRs++;
			}
		}
		return g_TRs;
	}
	else
	{
		int g_TRs, g_Bots;
		g_TRs = 0;
		g_Bots = 0;
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
			{
				IsFakeClient(i) ? g_Bots++ : g_TRs++;
			}
		}
		if(g_TRs == 1 && g_Bots > 0)
			return g_TRs + g_Bots;
		return g_TRs;
	}
}

public int cts_vivos()
{
	if(GetConVarInt(g_IgnoreBots) == 0)
	{
		int g_CTs = 0;
		for (int  i = 1; i <= MaxClients; i++)
		{
			if(IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
			{
				g_CTs++;
			}
		}
		return g_CTs;
	}
	else
	{
		int g_CTs, g_Bots;
		g_CTs = 0;
		g_Bots = 0;
		for (int  i = 1; i <= MaxClients; i++)
		{
			if (IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
			{
				IsFakeClient(i) ? g_Bots++ : g_CTs++;
			}
		}
		if(g_CTs == 1 && g_Bots > 0)
			return g_CTs + g_Bots;
		return g_CTs;
	}
}
__________________

Last edited by sHoC; 12-10-2015 at 13:04.
sHoC is offline
sHoC
Senior Member
Join Date: Nov 2015
Location: Italy
Old 12-12-2015 , 07:46   Re: EDIT Abner Duel HELP ME ;(
Reply With Quote #2

Up someone please?
__________________
sHoC is offline
supreeda
Senior Member
Join Date: Jul 2015
Old 12-13-2015 , 13:42   Re: EDIT Abner Duel HELP ME ;(
Reply With Quote #3

Quote:
Originally Posted by sHoC View Post
Up someone please?
not sure it easy or not you must insert "weapon_revolver"

idk what command give revolver !
supreeda is offline
sHoC
Senior Member
Join Date: Nov 2015
Location: Italy
Old 12-13-2015 , 17:57   Re: EDIT Abner Duel HELP ME ;(
Reply With Quote #4

Quote:
Originally Posted by supreeda View Post
not sure it easy or not you must insert "weapon_revolver"

idk what command give revolver !
I know insert revolver in revolver in plugin, but i dont know how can i give only one bullet
__________________
sHoC is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode