Raised This Month: $12 Target: $400
 3% 

Stripping guns & setting active weapon to knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-05-2007 , 09:56   Stripping guns & setting active weapon to knife
Reply With Quote #1

Stuck trying to find a working way to do this

I've tried so many diffrent methods with no luck (always has some type of bug)

Currently I'm doing it this way but i can't get the knife set as active weapon (RemoveAllItems & GiveNameItem made my teammate nearly die from laughter when he could see 4 dancing knives on his side )

Code:
UTIL_RemoveAllButKnife (client)
{
    static iWeaponSlot = 0, iEntIndex = 0;
    decl String:szClassName[64] = "";
    
    for (iWeaponSlot = 0; iWeaponSlot <= (32 * 4); iWeaponSlot += 4)
    {
        iEntIndex = GetEntDataEnt (client, (g_iMyWeapons + iWeaponSlot));
        if (iEntIndex != 0)
        {
            GetEdictClassname (iEntIndex, szClassName, sizeof (szClassName));
            if (!strcmp (szClassName, "worldspawn", false))
                continue;
            if (!strcmp (szClassName, "weapon_knife", false) || !strcmp (szClassName, "knife", false))
            {
                SetEntData (client, g_iActiveWeapon, iEntIndex);
                continue;
            }

            RemovePlayerItem (client, iEntIndex);
            RemoveEdict (iEntIndex);
        }
    }
}

/* called at on plugin start */
UTIL_SetupOffsets ()
{
    g_iMyWeapons = FindSendPropOffs ("CBaseCombatCharacter", "m_hMyWeapons");
    if (g_iMyWeapons == -1)
        SetFailState ("[YGMSM] Error - Unable to get offset for CBaseCombatCharacter::m_hMyWeapons");
    
    g_iActiveWeapon = FindSendPropOffs ("CBaseCombatCharacter", "m_hActiveWeapon");
    if (g_iActiveWeapon == -1)
        SetFailState ("[YGMSM] Error - Unable to get offset for CBaseCombatCharacter::m_hActiveWeapon");
}
It manages to strip all the weapons but doesnt set the knife as active weapon & makes everyone look like jesus

Thanks for any help

dubbeh
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-05-2007 , 10:08   Re: Stripping guns & setting active weapon to knife
Reply With Quote #2

I do this in Sell! and in 1v1(Knife Fight) if you want to take a look.

I strip the weapons first and then after I am done stripping I assign the appropriate into there current slot

This:

Code:
public EquipAvailableWeapon(client)
{
    // Find a new weapon to equip
    new pos = 0;
    new weaponEntity = -1;
    do {
        weaponEntity = GetPlayerWeaponSlot(client, pos);
        pos++;
    } while(weaponEntity == -1 && pos < 5);
    if(weaponEntity != -1)
        SDKCall(hEquipWeapon, client, weaponEntity);
}
Is a function I use to find the most appropriate weapon. It could easily be adapted to go straight to the knife something like this.

Code:
public EquipKnife(client)
{
    new weaponEntity = -1;
    weaponEntity = GetPlayerWeaponSlot(client, 2);
    if(weaponEntity != -1)
        SDKCall(hEquipWeapon, client, weaponEntity);
}
Here is the setup for the SDKCall

Code:
    StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "Weapon_Equip");
    PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
    hEquipWeapon = EndPrepSDKCall();
Code:
"Games"
{
    "cstrike"
    {
        "Offsets"
        {
            "Weapon_Equip"
            {
                "windows"    "217"
                "linux"        "218"
            }
        }
    }
}
dalto is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-05-2007 , 10:23   Re: Stripping guns & setting active weapon to knife
Reply With Quote #3

Thanks a lot dalto - spent so long trying to get this working
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-06-2007 , 07:11   Re: Stripping guns & setting active weapon to knife
Reply With Quote #4

You can simply remove all weapons and give a knife.
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-06-2007 , 08:09   Re: Stripping guns & setting active weapon to knife
Reply With Quote #5

Tryed that & had a weird side effect with knives dancing on screen :O
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh 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 12:24.


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