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

Check if player has grenade/equip on spawn


Post New Thread Reply   
 
Thread Tools Display Modes
MatoBoost
Junior Member
Join Date: Apr 2016
Old 04-06-2019 , 17:43   Re: Check if player has grenade/equip on spawn
Reply With Quote #11

Now I have another problem: I am having trouble with removing healthshot from inventory. There is no weapon slot for healthshot, and I have no idea how to remove it.

Also AcceptEntityInput(ent, "Kill"); kicked people from server on round start, so I changed it back to RemoveEntity(ent);

I found this post here, but it did not help me at all :/ https://forums.alliedmods.net/showthread.php?p=2629285
MatoBoost is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-06-2019 , 20:19   Re: Check if player has grenade/equip on spawn
Reply With Quote #12

acceptentityinput kill shouldnt be kicking any players unless your targeting the player and not the entity your removing....
MasterMind420 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 04-07-2019 , 05:49   Re: Check if player has grenade/equip on spawn
Reply With Quote #13

Quote:
Originally Posted by MasterMind420 View Post
acceptentityinput kill shouldnt be kicking any players unless your targeting the player and not the entity your removing....
+1

post here the entire code and I will fix it for you.
__________________
Ilusion9 is offline
MatoBoost
Junior Member
Join Date: Apr 2016
Old 04-07-2019 , 14:39   Re: Check if player has grenade/equip on spawn
Reply With Quote #14

Code:
public void OnPluginStart() 
{ 
    HookEvent("round_end", RoundEnd, EventHookMode_Pre); 
} 


public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)  
{  
    for( new client=1; client<=MaxClients; client++) 
    { 
        new i = 3; 
        {   
            new ent;  
              
            while((ent = GetPlayerWeaponSlot(client, i)) != -1)  
            {  
                RemovePlayerItem(client, ent);  
                AcceptEntityInput(ent, "Kill"); 
            }  
        }  
    }     
}
I copied this, but I modified it a little but, though I kept while cycle as it is, here is the code I am using right now (tried to do something with medishot, it worked, but suddenly stopped working for some reason).

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

public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast){

    int client = GetClientOfUserId(event.GetInt("userid"));
    
    if (client)
    {
        if (CheckCommandAccess(client, "", ADMFLAG_RESERVATION, true))
        {
            RemoveClientGrenades(client);
        }
    }
}

void RemoveClientGrenades(int client)
{
	int ent = -1;
	int enthealth = -1;
    
	while ((ent = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE)) != -1)
	{
		RemovePlayerItem(client, ent);
		RemoveEntity(ent);
	}
	
	while ((enthealth = GetPlayerWeaponSlot(client, 57)) != -1)
	{
		RemovePlayerItem(client, enthealth);
		RemoveEntity(enthealth);
	}
}

Last edited by MatoBoost; 04-07-2019 at 14:41.
MatoBoost is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 04-07-2019 , 14:51   Re: Check if player has grenade/equip on spawn
Reply With Quote #15

PHP Code:

void RemoveClientGrenades
(int client)
{
    
int length GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    
    for (
int i 0lengthi++) 
    { 
        
int ent GetEntPropEnt(clientProp_Send"m_hMyWeapons"i); 

        if (
ent != -1
        {
            
int def GetEntProp(entProp_Send"m_iItemDefinitionIndex"); 
            
            
/* flashbang - he - smoke - molotov - incendiary - healthshot */
            
if (def == 43 || def == 44 || def == 45 || def == 46 || def == 48 || def == 57)
            {
                
RemovePlayerItem(clientent);
                
AcceptEntityInput(ent"Kill");
            }
        } 
    } 

__________________
Ilusion9 is offline
sazonische
Senior Member
Join Date: Dec 2013
Old 04-13-2019 , 13:08   Re: Check if player has grenade/equip on spawn
Reply With Quote #16

HTML Code:
#define GetClientGrenades(%0,%1) GetEntProp(%0, Prop_Send, "m_iAmmo", _, %1)

enum
{
	nade_he = 14,
	nade_flash,
	nade_smoke,
	nade_inc, 	// Molotovs
	nade_decoy
};


if(!GetClientGrenades(client, nade_smoke))
   RUN CODE
__________________
my steam LINK
sazonische is offline
Send a message via Skype™ to sazonische
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 17:01.


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