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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-06-2010 , 17:11   drop pistol while having shield [SOLVED! Post #9]
Reply With Quote #1

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

Last edited by Hunter-Digital; 07-06-2010 at 18:55.
Hunter-Digital is offline
NzGamers
Member
Join Date: Jul 2009
Old 07-06-2010 , 17:17   Re: drop pistol while having shield
Reply With Quote #2

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");
    }

NzGamers is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-06-2010 , 17:20   Re: drop pistol while having shield
Reply With Quote #3

Yeah, you're a genious test that for me would ya
__________________
Hunter-Digital is offline
NzGamers
Member
Join Date: Jul 2009
Old 07-06-2010 , 17:22   Re: drop pistol while having shield
Reply With Quote #4

Quote:
Originally Posted by Hunter-Digital View Post
Yeah, you're a genious 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
NzGamers is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-06-2010 , 17:31   Re: drop pistol while having shield
Reply With Quote #5

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

Last edited by Hunter-Digital; 07-06-2010 at 18:54. Reason: added number 4.
Hunter-Digital is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 07-06-2010 , 17:56   Re: drop pistol while having shield
Reply With Quote #6

You could force the player to drop shield, remove the weaponbox for the shield, drop the pistol, then give the player a shield.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-06-2010 , 18:11   Re: drop pistol while having shield
Reply With Quote #7

Or you can simply execute strip_user_weapons and give them a shield, but its not recommended becouse of other user items loss.
Lure.d is offline
Send a message via Skype™ to Lure.d
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 07-06-2010 , 18:48   Re: drop pistol while having shield
Reply With Quote #8

Quote:
Originally Posted by Lure.d View Post
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.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-06-2010 , 18:53   Re: drop pistol while having shield
Reply With Quote #9

Quote:
Originally Posted by Emp` View Post
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 ?
__________________

Last edited by Hunter-Digital; 07-06-2010 at 18:56.
Hunter-Digital is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-06-2010 , 18:56   Re: drop pistol while having shield
Reply With Quote #10

Haha nvm
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 07-06-2010 at 19:05.
GXLZPGX is offline
Reply



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 21:28.


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