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

Removing a weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 12-16-2018 , 08:21   Removing a weapon
Reply With Quote #1

Hey, what's the condition to not remove grenades for the player

HTML Code:
public Action RemoveClientWeapons(client)
{
	for(new slot = 0; slot < 4; slot ++)
	{
		if(slot == 2)
			continue;

		new weapon_index = -1;
		while((weapon_index = GetPlayerWeaponSlot(client, slot)) != -1)
		{
			if(IsValidEntity(weapon_index))
			{
				RemovePlayerItem(client, weapon_index);
				AcceptEntityInput(weapon_index, "Kill");
			}
		}
	}
}
szogun is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-16-2018 , 09:28   Re: Removing a weapon
Reply With Quote #2

PHP Code:

Indexes
:
primary weapons
secondary
knifezeus
grenades
c4 
I see you remove weapons before slot 4 (c4) and skip slot 2 (knife). Just change slot < 4 to slot < 2

PHP Code:
public Action RemoveClientWeapons(client)
{
    for(new 
slot 0slot 2slot ++)
    {
        
int weapon_index = -1;

        while ((
weapon_index GetPlayerWeaponSlot(clientslot)) != -1)
        {
            if (
IsValidEntity(weapon_index))
            {
                
RemovePlayerItem(clientweapon_index);
                
AcceptEntityInput(weapon_index"Kill");
            }
        }
    }

__________________
Ilusion9 is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-16-2018 , 10:41   Re: Removing a weapon
Reply With Quote #3

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

Indexes
:
primary weapons
secondary
knifezeus
grenades
c4 
I see you remove weapons before slot 4 (c4) and skip slot 2 (knife). Just change slot < 4 to slot < 2

PHP Code:
public Action RemoveClientWeapons(client)
{
    for(new 
slot 0slot 2slot ++)
    {
        
int weapon_index = -1;

        while ((
weapon_index GetPlayerWeaponSlot(clientslot)) != -1)
        {
            if (
IsValidEntity(weapon_index))
            {
                
RemovePlayerItem(clientweapon_index);
                
AcceptEntityInput(weapon_index"Kill");
            }
        }
    }

hi!
how i get index for Medic kit or tablet and ... ??

HTML Code:
Indexes:
0 - primary weapons
1 - secondary
2 - knife, zeus
3 - grenades
4 - c4
? - Medic kit
? - tablet
and all new iteams??
Dr.Mohammad is offline
szogun
Senior Member
Join Date: Apr 2016
Old 12-16-2018 , 11:11   Re: Removing a weapon
Reply With Quote #4

Okay, I corrected it but the player still has the grenade removed on the aim map

Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
	name = "[CS:GO] VIP",
	author = "xBonio & Avgariat & Vasto_Lorde",
	description = "VIP Generator by cs-plugin.com",
	version = "1.0",
	url = "http://cs-plugin.com"
};

char tag[64] = "VIP";

int offsetHe;

public void OnPluginStart()
{
	HookEvent("player_spawn", PlayerSpawn);
	HookEvent("player_death", PlayerDeath);
}

public void OnMapStart()
{	
	int entindex;
	entindex = CreateEntityByName("weapon_hegrenade");
	DispatchSpawn(entindex);
	offsetHe = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
	AcceptEntityInput(entindex, "Kill");

}

public Action PlayerSpawn(Event event, const char[] name, bool dontBroadcast) 
{
	int client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(IsValidPlayer(client) && IsPlayerVIP(client))
	{
		if(IsPlayerAlive(client))
		{
			CreateTimer(0.1, GiveEquipment, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
		}
	}
}
public Action GiveEquipment(Handle timer, any userid) {
	int client = GetClientOfUserId(userid);
   
	if(!IsPlayerAlive(client) || !IsValidPlayer(client)) return;
    
	{  
		SetEntProp(client, Prop_Send, "m_ArmorValue", 100);

		if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetHe) < 1) 
			GivePlayerItem(client, "weapon_hegrenade");
	}
}
public Action PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
	int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	if(!IsValidPlayer(attacker) || !IsPlayerVIP(attacker)) return;
	int health = GetClientHealth(attacker);
	if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0)
	SetEntityHealth(attacker, health+5);

	bool headshot = GetEventBool(event, "headshot", false);
	if(headshot)
	{
		health = GetClientHealth(attacker);
		SetEntityHealth(attacker, health+5);
	}
	if(GetClientHealth(attacker) > 100)
				SetEntityHealth(attacker, 100);
}

public void OnClientPostAdminCheck(int client)
{
	if(IsPlayerVIP(client))
	{
			
		PrintToChatAll(" %s \x03%N\x01 \x01", tag, client);
	}
}

stock bool IsValidPlayer(int client)
{
    if(client >= 1 && client <= MaxClients && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client) && !IsClientReplay(client) && !IsClientSourceTV(client))
        return true;
    return false;
}

stock bool IsPlayerVIP(int client)
{
	if(GetUserFlagBits(client) & ADMFLAG_CUSTOM6)
		return true;
	return false;
}
szogun is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-16-2018 , 13:43   Re: Removing a weapon
Reply With Quote #5

Quote:
Originally Posted by szogun View Post
Okay, I corrected it but the player still has the grenade removed on the aim map
Only on aim map? maybe that map has a game_player_equip entitiy that strips weapons on player spawn
__________________
Ilusion9 is offline
szogun
Senior Member
Join Date: Apr 2016
Old 12-16-2018 , 16:16   Re: Removing a weapon
Reply With Quote #6

Quote:
Originally Posted by Ilusion9 View Post
Only on aim map? maybe that map has a game_player_equip entitiy that strips weapons on player spawn
Yes.
Unfortunately, the grenade is removed on all the aim maps for the player
szogun is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-17-2018 , 07:38   Re: Removing a weapon
Reply With Quote #7

Quote:
Originally Posted by szogun View Post
Yes.
Unfortunately, the grenade is removed on all the aim maps for the player
Just force "Use only" flag on game_player_equip entities.

PHP Code:

public void OnEntityCreated(int entity, const char[] classname)
{
    
/* game_player_equip entities will not be activated until players will trigger them */
    
    
if (StrEqual(classname"game_player_equip"))
    {
        
SDKHook(entitySDKHook_SpawnPostOnGamePlayerEquipSpawn);
    }
}

public 
void OnGamePlayerEquipSpawn(int entity)
{
    
int flags GetEntProp(entityProp_Data"m_spawnflags");

    if (
flags 1// "Use Only" flag
    
{
        return;
    }

    
SetEntProp(entityProp_Data"m_spawnflags"flags 1);

__________________
Ilusion9 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