View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-18-2018 , 16:05   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #4

I made example to your first post, because you would get healtshots in spawn every round start.

This check first, does player have healt shot or how many (follow cvar ammo_item_limit_healthshot value)

PHP Code:
#include <sdktools>

ConVar ammo_item_limit_healthshot;

public 
void OnPluginStart()
{
    
ammo_item_limit_healthshot FindConVar("ammo_item_limit_healthshot");
    if(
ammo_item_limit_healthshot == INVALID_HANDLESetFailState("No Cvar ammo_item_limit_healthshot found");

    
HookEvent("player_spawn"player_spawn);
}

public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if(
GetClientTeam(client) <= 1) return; // player need to be in right team


    
char classname[35];
    
int m_hMyWeapons_size GetEntPropArraySize(clientProp_Send"m_hMyWeapons"); // array size
    
int item;
    
bool m_bHasHealthShot;

    for(
int index 0index m_hMyWeapons_sizeindex++) // look player items
    
{
        
item GetEntPropEnt(clientProp_Send"m_hMyWeapons"index);

        if(
item == -1) continue; // skip invalid

        
GetEntityClassname(itemclassnamesizeof(classname));

        
// Health Shot
        
if(StrEqual(classname"weapon_healthshot"false))
        {
            
m_bHasHealthShot true;

            
int ammotype GetEntProp(itemProp_Send"m_iPrimaryAmmoType");

            if(
ammotype == -1) continue; // skip if ammo type offset invalid

            
int ammo GetEntProp(clientProp_Send"m_iAmmo"_ammotype);
            if(
ammo ammo_item_limit_healthshot.IntValue)
            {
                
SetEntProp(clientProp_Send"m_iAmmo"ammo 1_ammotype);
                
//GivePlayerItem(client, "weapon_healthshot");
            
}
        }
    }


    if(!
m_bHasHealthShot && ammo_item_limit_healthshot.IntValue 0GivePlayerItem(client"weapon_healthshot");





There is https://sm.alliedmods.net/new-api/cs...OnCSWeaponDrop

I look another time, I go sleep
__________________
Do not Private Message @me

Last edited by Bacardi; 12-18-2018 at 16:05.
Bacardi is offline