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

AWP only & abner noscope duel fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slowww
Member
Join Date: Mar 2017
Old 10-14-2017 , 04:33   AWP only & abner noscope duel fix
Reply With Quote #1

Hello, I have this AWP & knife only plugin but I have a bug with Abner Duel, after noscope duel, in the next round the player can't use his scope until he dies.
I think if I will give the player another AWP every round maybe he will no longer have this issue.
How can I do this?


AWPonly source:
Code:
 #include <sourcemod>
#include <sdktools>
#include <sdkhooks>

char allowedWeapons[] = {"weapon_awp", "weapon_knife"};

public void OnPluginStart()
{
	HookEvent("player_spawn", Event_PlayerSpawn);
}

public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse_Callback);
}

public Action WeaponCanUse_Callback(int client, int weapon)
{
	if (!IsValidClient(client))
	{
		return Plugin_Continue;
	}
	
	char classname[32];
	GetEntityClassname(weapon, classname, sizeof(classname));
	
	if (!IsWeaponAllowed(classname))
	{
		return Plugin_Handled;
	}
	else
	{
		return Plugin_Continue;
	}
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	RequestFrame(RequestFrame_Callback, event.GetInt("userid"));
}

public void RequestFrame_Callback(int userid)
{
	LoopWeapons(GetClientOfUserId(userid));
}

void LoopWeapons(int client)
{
    for (int i = 0; i < 5; i++)
    {
        int entity = GetPlayerWeaponSlot(client, i);
        if (IsValidEntity(entity))
		{
			char classname[32];
			GetEntityClassname(entity, classname, sizeof(classname));

			if (!IsWeaponAllowed(classname))
			{
				AcceptEntityInput(entity, "Kill");
			}
		}
    }
}

bool IsWeaponAllowed(char[] classname)
{
	bool found = false;
	int index = 0;
	while (!found && index < sizeof(allowedWeapons))
	{
		if (StrEqual(classname, allowedWeapons[index]))
		{
			found = true;
		}
		else
		{
			index++;
		}
	}
	
	return found;
}

bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
{
	if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
	{
		return false;
	}
	return true;
}
slowww is offline
[email protected]
BANNED
Join Date: Nov 2015
Old 10-14-2017 , 05:13   Re: AWP only & abner noscope duel fix
Reply With Quote #2

Quote:
Originally Posted by slowww View Post
Hello, I have this AWP & knife only plugin but I have a bug with Abner Duel, after noscope duel, in the next round the player can't use his scope until he dies.
I think if I will give the player another AWP every round maybe he will no longer have this issue.
How can I do this?


AWPonly source:
Code:
 #include <sourcemod>
#include <sdktools>
#include <sdkhooks>

char allowedWeapons[] = {"weapon_awp", "weapon_knife"};

public void OnPluginStart()
{
	HookEvent("player_spawn", Event_PlayerSpawn);
}

public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse_Callback);
}

public Action WeaponCanUse_Callback(int client, int weapon)
{
	if (!IsValidClient(client))
	{
		return Plugin_Continue;
	}
	
	char classname[32];
	GetEntityClassname(weapon, classname, sizeof(classname));
	
	if (!IsWeaponAllowed(classname))
	{
		return Plugin_Handled;
	}
	else
	{
		return Plugin_Continue;
	}
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	RequestFrame(RequestFrame_Callback, event.GetInt("userid"));
}

public void RequestFrame_Callback(int userid)
{
	LoopWeapons(GetClientOfUserId(userid));
}

void LoopWeapons(int client)
{
    for (int i = 0; i < 5; i++)
    {
        int entity = GetPlayerWeaponSlot(client, i);
        if (IsValidEntity(entity))
		{
			char classname[32];
			GetEntityClassname(entity, classname, sizeof(classname));

			if (!IsWeaponAllowed(classname))
			{
				AcceptEntityInput(entity, "Kill");
			}
		}
    }
}

bool IsWeaponAllowed(char[] classname)
{
	bool found = false;
	int index = 0;
	while (!found && index < sizeof(allowedWeapons))
	{
		if (StrEqual(classname, allowedWeapons[index]))
		{
			found = true;
		}
		else
		{
			index++;
		}
	}
	
	return found;
}

bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
{
	if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
	{
		return false;
	}
	return true;
}
for awp only this may be needed

https://forums.alliedmods.net/showpo...82&postcount=6

him got ban for license requirements of missle plugin

for 3 days

this is old private plugin but working

Last edited by [email protected]; 10-14-2017 at 05:15. Reason: :) rasta.
sourcemodcfg@gmail.com is offline
slowww
Member
Join Date: Mar 2017
Old 10-14-2017 , 05:17   Re: AWP only & abner noscope duel fix
Reply With Quote #3

it's too complicated, I want something simple like this one
slowww is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 10-15-2017 , 04:57   Re: AWP only & abner noscope duel fix
Reply With Quote #4

Quote:
I have a bug with Abner Duel, after noscope duel, in the next round the player can't use his scope until he dies.
Sounds to me like you should be fixing that bug in Abner Duel...
headline is offline
slowww
Member
Join Date: Mar 2017
Old 10-15-2017 , 06:23   Re: AWP only & abner noscope duel fix
Reply With Quote #5

Or to awponly plugin
slowww 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 19:11.


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