|
Senior Member
Join Date: Jul 2022
Location: Poland
|
11-12-2022
, 10:46
Re: [CSGO] How to disable pick up Nades
|
#5
|
Quote:
Originally Posted by Bacardi
You have not tell us, do players still need collect grenades when round start ?
This example follow weapon drop by player,
when weapon is grenade, it store that entity in array and will block pickup.
On round start plugin clear array of stored entities.
PHP Code:
#include <sdkhooks>
#include <cstrike>
ArrayList blockpick;
public void OnPluginStart()
{
blockpick = new ArrayList();
HookEvent("round_start", round_start);
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i)) OnClientPutInServer(i);
}
}
public void round_start(Event event, const char[] name, bool dontBroadcast)
{
blockpick.Clear();
}
public void OnClientPutInServer(int client)
{
//SDKHook(client, SDKHook_OnTakeDamage, ontakedamage);
//SDKHook(client, SDKHook_WeaponCanSwitchTo, weapon_cb1);
SDKHook(client, SDKHook_WeaponCanUse, weapon_cb2);
SDKHook(client, SDKHook_WeaponDrop, weapon_cb3);
}
public Action ontakedamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype)
{
PrintToServer("%i %f %i",
inflictor,
damage,
damagetype);
return Plugin_Continue;
}
public Action weapon_cb1(int client, int weapon)
{
PrintToServer("weapon_cb1 %i %i",
client,
weapon);
return Plugin_Continue;
}
public Action weapon_cb2(int client, int weapon)
{
if(weapon == -1)
return Plugin_Continue;
int entref = EntIndexToEntRef(weapon);
if(entref != -1 && blockpick.FindValue(entref) != -1)
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action weapon_cb3(int client, int weapon)
{
if(weapon == -1 || !HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
return Plugin_Continue;
int entref = EntIndexToEntRef(weapon);
if(entref != -1 && blockpick.FindValue(entref) == -1)
{
int m_iItemDefinitionIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
CSWeaponID weaponid = CS_ItemDefIndexToID(m_iItemDefinitionIndex);
switch(weaponid)
{
case CSWeapon_HEGRENADE, CSWeapon_SMOKEGRENADE, CSWeapon_FLASHBANG,\
CSWeapon_MOLOTOV, CSWeapon_DECOY, CSWeapon_INCGRENADE, CSWeapon_TAGGRENADE, CSWeapon_FRAGGRENADE:
{
blockpick.Push(entref);
}
}
}
return Plugin_Continue;
}
|
Code:
C:\Users\ja\Desktop\blocknade.sp(74) : error 017: undefined symbol "CS_ItemDefIndexToID"
C:\Users\ja\Desktop\blocknade.sp(74) : warning 213: tag mismatch
C:\Users\ja\Desktop\blocknade.sp(79) : error 017: undefined symbol "CSWeapon_TAGGRENADE"
|
|
|
|