AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   drop pistol while having shield [SOLVED! Post #9] (https://forums.alliedmods.net/showthread.php?t=131579)

Hunter-Digital 07-06-2010 17:11

drop pistol while having shield [SOLVED! Post #9]
 
Hello,

I've searched for this and found nothing.

I need to drop the pistol from a player having a shield.

engclient_cmd(id, "drop", "weapon_usp") doesn't work, nethider "drop weapon_usp" in console, it works for the rest of weapons but for shield, drops the shield :/

Anyone know any other method ?
... besides removing the pistol from player's inventory and creating a fake dropped one ^^

NzGamers 07-06-2010 17:17

Re: drop pistol while having shield
 
PHP Code:

public client_prethink(id)
{
    if(
is_user_alive(id) && user_has_weapon(idCSW_SHIELD)
    {
        
strip_user_weapons(id);
        
give_item(id"weapon_knife" );
        
give_item(id"weapon_shield");
    }



Hunter-Digital 07-06-2010 17:20

Re: drop pistol while having shield
 
Yeah, you're a genious :roll: test that for me would ya :)

NzGamers 07-06-2010 17:22

Re: drop pistol while having shield
 
Quote:

Originally Posted by Hunter-Digital (Post 1230250)
Yeah, you're a genious :roll: test that for me would ya :)

i got no time to test atm. just paste that into ur code. u dont need to register client_prethink

Hunter-Digital 07-06-2010 17:31

Re: drop pistol while having shield
 
You either don't know how to script or you're messing with me :}

1. "client_prethink()" doesn't exist, it's "client_PreThink()"
2. if that would actually BE the prethink function, it would do an infinite loop and crash
3. I said I wanted to DROP the pistol, not to remove it.
4. CSW_SHIELD does not exist, shield is detectable via cs_get_user_shield()

Either way, it's no help.

So, anyone know a way to DROP a pistol while having a shield ? :crab:

Emp` 07-06-2010 17:56

Re: drop pistol while having shield
 
You could force the player to drop shield, remove the weaponbox for the shield, drop the pistol, then give the player a shield.

Lure.d 07-06-2010 18:11

Re: drop pistol while having shield
 
Or you can simply execute strip_user_weapons and give them a shield, but its not recommended becouse of other user items loss.

Jelle 07-06-2010 18:48

Re: drop pistol while having shield
 
Quote:

Originally Posted by Lure.d (Post 1230308)
Or you can simply execute strip_user_weapons and give them a shield, but its not recommended becouse of other user items loss.

You could just find what weapons the player has, and store it somewhere, and then set the weapons back, just without the pistol.

Hunter-Digital 07-06-2010 18:53

Re: drop pistol while having shield
 
Quote:

Originally Posted by Emp` (Post 1230295)
You could force the player to drop shield, remove the weaponbox for the shield, drop the pistol, then give the player a shield.

Yes, that's it... but it came to me after I replied earlier... done it and quickly tested, works.

PHP Code:

/* CSW_SHIELD is defined to 2 (it's empty anyway so why not use it)
and g_szWeaponEntity has weapon_* stored */

stock player_shieldDropSecondary(idiSecondary)
{
    
engclient_cmd(id"drop""weapon_shield"/* drop the shield... "weapon_shield" is kinda useless anyway */

    
new ent find_ent_by_owner(-1g_szWeaponEntity[CSW_SHIELD], id/* find the shield */

    
entity_set_int(entEV_INT_flagsFL_KILLME/* kill the shield */
    
call_think(ent/* make the shield realise that it's gonna die */

    
engclient_cmd(id"drop"g_szWeaponEntity[iSecondary]) /* drop the secondary */

    
give_item(id"weapon_shield"/* give back the shield */


Now, I don't know in what situations this function may fail, has anyone experienced this style of removing and re-adding before ?

GXLZPGX 07-06-2010 18:56

Re: drop pistol while having shield
 
Haha nvm


All times are GMT -4. The time now is 07:14.

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